Skip to content

Commit 4a91c20

Browse files
committed
use GlobalPhase bloq
1 parent bf194a0 commit 4a91c20

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

qualtran/bloqs/basic_gates/su2_rotation.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from numpy.typing import NDArray
2222

2323
from qualtran import bloq_example, BloqDocSpec, GateWithRegisters, Signature
24-
from qualtran.bloqs.basic_gates import Ry, ZPowGate
24+
from qualtran.bloqs.basic_gates import GlobalPhase, Ry, ZPowGate
2525
from qualtran.cirq_interop.t_complexity_protocol import TComplexity
2626
from qualtran.drawing import TextBox
2727

@@ -123,11 +123,7 @@ def _unitary_(self):
123123
def build_composite_bloq(self, bb: 'BloqBuilder', q: 'SoquetT') -> Dict[str, 'SoquetT']:
124124
pi = sympy.pi if self._is_parameterized_() else np.pi
125125

126-
# global phase of $-e^{i \alpha}$
127-
q = bb.add(
128-
ZPowGate(exponent=2, global_shift=0.5 + self.global_shift / (2 * pi), eps=self.eps / 4),
129-
q=q,
130-
)
126+
bb.add(GlobalPhase(coefficient=-np.exp(1j * self.global_shift), eps=self.eps / 4))
131127
q = bb.add(ZPowGate(exponent=1 - self.lambd / pi, global_shift=-1, eps=self.eps / 4), q=q)
132128
q = bb.add(Ry(angle=2 * self.theta, eps=self.eps / 4), q=q)
133129
q = bb.add(ZPowGate(exponent=-self.phi / pi, global_shift=-1, eps=self.eps / 4), q=q)

qualtran/cirq_interop/_cirq_to_bloq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def as_cirq_op(
120120
) -> Tuple[Union['cirq.Operation', None], Dict[str, 'CirqQuregT']]:
121121
if isinstance(self.cirq_gate, GateWithRegisters):
122122
return self.cirq_gate.as_cirq_op(qubit_manager, **in_quregs)
123-
qubits = in_quregs.get('q', ()).flatten()
123+
qubits = in_quregs.get('q', np.array([])).flatten()
124124
return self.cirq_gate.on(*qubits), in_quregs
125125

126126
# Delegate all cirq-style protocols to underlying gate

0 commit comments

Comments
 (0)