Skip to content

Commit 47d2ba5

Browse files
committed
fix TComplexity for cirq.GlobalPhaseGate and cirq.global_phase_operation
1 parent 162daef commit 47d2ba5

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

qualtran/bloqs/basic_gates/su2_rotation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def wire_symbol(self, soq: 'Soquet') -> 'WireSymbol':
138138
)
139139

140140
def _t_complexity_(self) -> TComplexity:
141-
return TComplexity(rotations=3, clifford=1)
141+
return TComplexity(rotations=3)
142142

143143
def _is_parameterized_(self) -> bool:
144144
return any(

qualtran/cirq_interop/t_complexity_protocol.py

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ def _is_clifford_or_t(stc: Any, fail_quietly: bool) -> Optional[TComplexity]:
9494
if not isinstance(stc, (cirq.Gate, cirq.Operation)):
9595
return None
9696

97+
if isinstance(stc, cirq.GlobalPhaseGate) or (
98+
isinstance(stc, cirq.Operation) and isinstance(stc.gate, cirq.GlobalPhaseGate)
99+
):
100+
return TComplexity()
101+
97102
if isinstance(stc, cirq.ClassicallyControlledOperation):
98103
stc = stc.without_classical_controls()
99104

qualtran/cirq_interop/t_complexity_protocol_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ def test_gates():
132132

133133
assert t_complexity(cirq.FREDKIN) == TComplexity(t=7, clifford=14)
134134

135+
# Global phase
136+
assert t_complexity(cirq.GlobalPhaseGate(1j)) == TComplexity()
137+
135138

136139
def test_operations():
137140
q = cirq.NamedQubit('q')
@@ -145,6 +148,8 @@ def test_operations():
145148
op = gate.on_registers(**get_named_qubits(gate.signature))
146149
assert t_complexity(op) == TComplexity(clifford=4)
147150

151+
assert t_complexity(cirq.global_phase_operation(1j)) == TComplexity()
152+
148153

149154
def test_circuits():
150155
q = cirq.NamedQubit('q')

qualtran/resource_counting/t_counts_from_sigma_test.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Rx,
2020
Ry,
2121
Rz,
22+
SU2RotationGate,
2223
TGate,
2324
Toffoli,
2425
XPowGate,
@@ -33,7 +34,16 @@
3334

3435

3536
def test_all_rotation_types():
36-
assert set(_get_all_rotation_types()) == {CZPowGate, Rx, Ry, Rz, XPowGate, YPowGate, ZPowGate}
37+
assert set(_get_all_rotation_types()) == {
38+
CZPowGate,
39+
Rx,
40+
Ry,
41+
Rz,
42+
XPowGate,
43+
YPowGate,
44+
ZPowGate,
45+
SU2RotationGate,
46+
}
3747

3848

3949
def test_t_counts_from_sigma():

0 commit comments

Comments
 (0)