We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 551b87d commit 416bafdCopy full SHA for 416bafd
cirq-core/cirq/ops/controlled_gate.py
@@ -163,8 +163,12 @@ def _decompose_with_context_(
163
self.num_controls(), self.control_values, self.control_qid_shape
164
)
165
# Prefer the subgate controlled version if available
166
- if controlled_sub_gate.__class__ != self.__class__:
167
- return controlled_sub_gate.on(*qubits)
+ if self != controlled_sub_gate:
+ # Prevent 2-cycle from appearing in recursive decomposition
168
+ if not isinstance(controlled_sub_gate, ControlledGate) or not isinstance(
169
+ controlled_sub_gate.sub_gate, common_gates.CZPowGate
170
+ ):
171
+ return controlled_sub_gate.on(*qubits)
172
if (
173
protocols.has_unitary(self.sub_gate)
174
and protocols.num_qubits(self.sub_gate) == 1
0 commit comments