You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix moment commutation detection for group-commuting operations (#6659) (#7082)
* Fix Moment.commutes_ to handle multi-qubit unitaries (#6659)
Add pairwise commuting checks and, when inconclusive, fall back to full
unitary commutator. Includes new tests showing Z⊗Z commutes with RXX.
Fixes#6659.
* Put back pre-existing commutation tests
* prune duplicate or redundant test cases
* reuse cirq.AmplitudeDampingChannel to test with non-unitary
* move commute-related test functions together
* Refactor `Moment._commutes_` to convert to CircuitOperation if necessary
Also check `measurement_key_objs` and `control_keys` active for checked
Moments as in the Operation commutes protocol.
* Test commutation of moments with measurement keys and controls
Adapt `cirq.ops.classically_controlled_operation_test.test_commute`
* Small tweak of docstring
* Add shared internal function _operations_commutes_impl
Generalize `Operation._commutes_` in a shared internal function
`_operations_commutes_impl`
* Sync module variable name with circuit module name
No change in code function.
* Use shared _operations_commutes_impl for Moment._commutes_
Also adjust `_operations_commutes_impl` to assume equal Moment-s
and Operation-s commute.
* Few optimizations in _operations_commutes_impl
- frozenset().union(*tuples) is faster than iterating over all
items in every tuple to construct a frozenset.
- base class Operation does not have `__hash__` method, therefore
we cannot use `set(operations)`.
---------
Co-authored-by: Pavol Juhas <[email protected]>
0 commit comments