Open cdbf1 opened 2 months ago
cirq cync: This functionality works for pauli strings, but not for moments.
A naive solution would be to decompose the moments (if commutes is initially determined to be false via gate by gate comparison).
From the documentation: Either value has a commutes method that returns 'True', 'False', or 'None' (meaning indeterminate).
So, this should either return None (not sure) or should perform an alternative strategy like decomposing the moment into a unitary.
Description of the issue Cirq gives the wrong result when determining whether moments commute if the individual operators within the moments do not commute, but the moment as a whole still commutes. For example, take a pair of single qubit Z gates and a two qubit RXX gate. While [Z, RXX] !=0 (for either single qubit Z), we do in fact have [Z * Z, RXX] = 0. However, when using cirq we have
Gives
False
.Looking through the source code this seems to be because the the
commutes()
function compares pairs of operators form each moment but doesn't consider the case when the moment as a whole commutes even when the individual operators do not.How to reproduce the issue See above
Cirq version You can get the cirq version by printing
cirq.__version__
. From the command line: 1.5.0