Skip to content

Commit 83382ae

Browse files
Add documentation to cirq.decompose protocol regarding specific target gateset (#6439)
* Add documentation to cirq.decompose protocol regarding specific target gateset * Clarify docstring --------- Co-authored-by: Noureldin <[email protected]>
1 parent decf16d commit 83382ae

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

cirq-core/cirq/protocols/decompose_protocol.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,12 @@ class SupportsDecompose(Protocol):
9292
"""An object that can be decomposed into simpler operations.
9393
9494
All decomposition methods should ultimately terminate on basic 1-qubit and
95-
2-qubit gates included by default in Cirq. Cirq does not make any guarantees
96-
about what the final gate set is. Currently, decompositions within Cirq
97-
happen to converge towards the X, Y, Z, CZ, PhasedX, specified-matrix gates,
98-
and others. This set will vary from release to release. Because of this
99-
variability, it is important for consumers of decomposition to look for
100-
generic properties of gates, such as "two qubit gate with a unitary matrix",
101-
instead of specific gate types such as CZ gates (though a consumer is
102-
of course free to handle CZ gates in a special way, and consumers can
103-
give an `intercepting_decomposer` to `cirq.decompose` that attempts to
104-
target a specific gate set).
95+
2-qubit gates included by default in Cirq. If a custom decomposition is not
96+
specified, Cirq will decompose all operations to XPow/YPow/ZPow/CZPow/Measurement
97+
+ Global phase gateset. However, the default decomposition in Cirq should be a last resort
98+
fallback and it is recommended for consumers of decomposition to either not depend
99+
upon a specific target gateset, or give an `intercepting_decomposer` to `cirq.decompose`
100+
that attempts to target a specific gate set.
105101
106102
For example, `cirq.TOFFOLI` has a `_decompose_` method that returns a pair
107103
of Hadamard gates surrounding a `cirq.CCZ`. Although `cirq.CCZ` is not a

0 commit comments

Comments
 (0)