Should analytical decompositions return an empty list when decomposing identity operation? #4831
Labels
area/decomposition
area/transformers
kind/design-issue
A conversation around design
triage/accepted
A consensus emerged that this bug report, feature request, or other action should be worked on
Milestone
We have many analytical decompositions in https://github.com/quantumlib/Cirq/tree/master/cirq-core/cirq/transformers/analytical_decompositions which are used to decompose a given unitary matrix / operation into a specific target gateset (eg: cz/fsim/sqrt_iswap etc.). The behavior of these decompositions when trying to decompose an identity operation currently differs across implementations -- some return an empty list while some return only single qubit ops and others return a longer decomposition. Eg:
There are also other inconsistencies in the API's of these analytical decompositions. For example:
two_qubit_matrix_to_operations
has a defaultclean_operations=True
flag in the constructor which calls a long list of cleanup operations on the list of final decomposed operations.two_qubit_matrix_to_ion_operations
does not have a configurablecleanup_operations=True
flag and always calls the same list of cleanup operations on the final decomposed operationstwo_qubit_matrix_to_sqrt_iswap_operations
has no flag and does not call the cleanup operations on the final decomposed operations.two_qubit_matrix_to_*
versions expect aq0, q1, mat
decompose_two_qubit_interaction_into_four_fsim_gates
expects asUnion['cirq.Operation', 'cirq.Gate', np.ndarray, Any]
and aqubits: Sequence['cirq.Qid'] = None
instead ofq0, q1
etc.decompose_cphase_into_two_fsim
expectsCZPowGate
andFSimGate
s (not operations or matrices)The text was updated successfully, but these errors were encountered: