-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
kind/bug-reportSomething doesn't seem to work.Something doesn't seem to work.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Description
Describe the issue
add-dynamical_decoupling
treats classically controlled operations as Clifford because _is_clifford_op
checks the operation directly:
def _is_clifford_op(op: ops.Operation) -> bool:
return has_unitary(op) and has_stabilizer_effect(op)
For a classically controlled op this passes, but later steps assumes a plain invertible gate/operation and crash.
Proposed fix: treat classically-controlled operations as non-Clifford:
def _is_clifford_op(op: ops.Operation) -> bool:
if op.gate:
return has_unitary(op.gate) and has_stabilizer_effect(op.gate)
return False
I’d like to work on this and will open a PR implementing the proposed fix.
Explain how to reproduce the bug or problem
from cirq import LineQubit, I, Circuit, measure
from cirq.transformers import add_dynamical_decoupling
q = LineQubit(0)
controlled = I(q).with_classical_controls("c")
circ = Circuit(measure(q, key="c"), controlled)
circ = add_dynamical_decoupling(circ)
Error
TypeError: object of type '<class 'list'>' isn't invertible. It has no __pow__ method (or the method returned NotImplemented) and it isn't an iterable of invertible objects.
Tell us the version of Cirq where this happens
Cirq version: 1.6.1
Metadata
Metadata
Assignees
Labels
kind/bug-reportSomething doesn't seem to work.Something doesn't seem to work.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on