diff --git a/qualtran/bloqs/basic_gates/su2_rotation.py b/qualtran/bloqs/basic_gates/su2_rotation.py index 72d09a4a3..49711c03e 100644 --- a/qualtran/bloqs/basic_gates/su2_rotation.py +++ b/qualtran/bloqs/basic_gates/su2_rotation.py @@ -138,7 +138,7 @@ def wire_symbol(self, soq: 'Soquet') -> 'WireSymbol': ) def _t_complexity_(self) -> TComplexity: - return TComplexity(rotations=3, clifford=1) + return TComplexity(rotations=3) def _is_parameterized_(self) -> bool: return any( diff --git a/qualtran/cirq_interop/t_complexity_protocol.py b/qualtran/cirq_interop/t_complexity_protocol.py index c3f73697e..759ca1899 100644 --- a/qualtran/cirq_interop/t_complexity_protocol.py +++ b/qualtran/cirq_interop/t_complexity_protocol.py @@ -94,6 +94,11 @@ def _is_clifford_or_t(stc: Any, fail_quietly: bool) -> Optional[TComplexity]: if not isinstance(stc, (cirq.Gate, cirq.Operation)): return None + if isinstance(stc, cirq.GlobalPhaseGate) or ( + isinstance(stc, cirq.Operation) and isinstance(stc.gate, cirq.GlobalPhaseGate) + ): + return TComplexity() + if isinstance(stc, cirq.ClassicallyControlledOperation): stc = stc.without_classical_controls() diff --git a/qualtran/cirq_interop/t_complexity_protocol_test.py b/qualtran/cirq_interop/t_complexity_protocol_test.py index 12b79c9fd..1f9cdb2ce 100644 --- a/qualtran/cirq_interop/t_complexity_protocol_test.py +++ b/qualtran/cirq_interop/t_complexity_protocol_test.py @@ -132,6 +132,9 @@ def test_gates(): assert t_complexity(cirq.FREDKIN) == TComplexity(t=7, clifford=14) + # Global phase + assert t_complexity(cirq.GlobalPhaseGate(1j)) == TComplexity() + def test_operations(): q = cirq.NamedQubit('q') @@ -145,6 +148,8 @@ def test_operations(): op = gate.on_registers(**get_named_qubits(gate.signature)) assert t_complexity(op) == TComplexity(clifford=4) + assert t_complexity(cirq.global_phase_operation(1j)) == TComplexity() + def test_circuits(): q = cirq.NamedQubit('q') diff --git a/qualtran/resource_counting/t_counts_from_sigma_test.py b/qualtran/resource_counting/t_counts_from_sigma_test.py index 82fb75319..181002c9e 100644 --- a/qualtran/resource_counting/t_counts_from_sigma_test.py +++ b/qualtran/resource_counting/t_counts_from_sigma_test.py @@ -19,6 +19,7 @@ Rx, Ry, Rz, + SU2RotationGate, TGate, Toffoli, XPowGate, @@ -33,7 +34,16 @@ def test_all_rotation_types(): - assert set(_get_all_rotation_types()) == {CZPowGate, Rx, Ry, Rz, XPowGate, YPowGate, ZPowGate} + assert set(_get_all_rotation_types()) == { + CZPowGate, + Rx, + Ry, + Rz, + XPowGate, + YPowGate, + ZPowGate, + SU2RotationGate, + } def test_t_counts_from_sigma():