Skip to content

Commit 93ef3c8

Browse files
committed
Fix order of glob.u decorator yet again (to match original UGate class args)
1 parent 7f03965 commit 93ef3c8

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/bloqade/qasm2/dialects/glob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
class UGate(ir.Statement):
1515
name = "ugate"
1616
traits = frozenset({lowering.FromPythonCall()})
17+
registers: ir.SSAValue = info.argument(ilist.IListType[QRegType])
1718
theta: ir.SSAValue = info.argument(types.Float)
1819
phi: ir.SSAValue = info.argument(types.Float)
1920
lam: ir.SSAValue = info.argument(types.Float)
20-
registers: ir.SSAValue = info.argument(ilist.IListType[QRegType])
2121

2222

2323
@dialect.register(key="qasm2.schedule.dag")

src/bloqade/qasm2/glob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@wraps(glob.UGate)
1313
def u(
14-
theta: float, phi: float, lam: float, registers: ilist.IList[QReg, Any] | list
14+
registers: ilist.IList[QReg, Any] | list, theta: float, phi: float, lam: float
1515
) -> None:
1616
"""Apply a U gate to all qubits in the input registers.
1717

test/pyqrack/test_target.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def global_h():
4646
q = qasm2.qreg(3)
4747

4848
# rotate around Y by pi/2, i.e. perform a hadamard
49-
qasm2.glob.u(math.pi / 2.0, 0, 0, [q])
49+
qasm2.glob.u([q], math.pi / 2.0, 0, 0)
5050

5151
return q
5252

@@ -72,13 +72,28 @@ def multiple_registers():
7272
q3 = qasm2.qreg(2)
7373

7474
# hadamard on first register
75-
qasm2.glob.u(math.pi / 2.0, 0, 0, [q1])
75+
qasm2.glob.u(
76+
[q1],
77+
math.pi / 2.0,
78+
0,
79+
0,
80+
)
7681

7782
# apply hadamard to the other two
78-
qasm2.glob.u(math.pi / 2.0, 0, 0, [q2, q3])
83+
qasm2.glob.u(
84+
[q2, q3],
85+
math.pi / 2.0,
86+
0,
87+
0,
88+
)
7989

8090
# rotate all of them back down
81-
qasm2.glob.u(-math.pi / 2.0, 0, 0, [q1, q2, q3])
91+
qasm2.glob.u(
92+
[q1, q2, q3],
93+
-math.pi / 2.0,
94+
0,
95+
0,
96+
)
8297

8398
return q1
8499

test/qasm2/passes/test_heuristic_noise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_global_noise():
265265
def test_method():
266266
q0 = qasm2.qreg(1)
267267
q1 = qasm2.qreg(1)
268-
glob.UGate([q0, q1], 0.1, 0.2, 0.3)
268+
qasm2.glob.u([q0, q1], 0.1, 0.2, 0.3)
269269

270270
px = 0.01
271271
py = 0.01

0 commit comments

Comments
 (0)