Fix circuit.append()
to use protocols.commute
to verify if two operations can be "crossed" or not.
#4882
Labels
area/circuits
area/classical/control
area/protocols/commutes
kind/bug-report
Something doesn't seem to work.
triage/accepted
A consensus emerged that this bug report, feature request, or other action should be worked on
Description of the issue
Since #4870 breaks the assumption that two operations acting on disjoint qubits always commute,
circuit.append()
should useprotocols.commute
to find the leftmost moment in which an operation can be inserted.As part of the work done for
CCO
, this was implemented by adding a special case of checking whether the current operation is a CCO and if yes, whether the previous moment has a measurement with matching control keys.Cirq/cirq-core/cirq/circuits/circuit.py
Lines 1972 to 1975 in 90679d2
This is problematic because it works only in one direction and breaks optimizers which relies on doing operations on the circuit in reverse order.
How to reproduce the issue
Cirq version
0.14.0.dev
The text was updated successfully, but these errors were encountered: