Skip to content

Commit 5a892c4

Browse files
authored
Fixing bug with wrong enum value (#219)
Note if you look at the definition of the Pauli enum https://github.com/unitaryfoundation/pyqrack/blob/819c58aed5a5695ee0a21f6274575b55deecb791/pyqrack/pauli.py#L17 y -> 3 and z -> 2 which is pretty weird lol. cc: @david-pl
1 parent 46a060c commit 5a892c4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/bloqade/pyqrack/qasm2/uop.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from kirin import interp
44

5+
from pyqrack.pauli import Pauli
56
from bloqade.pyqrack.reg import PyQrackQubit
67
from bloqade.qasm2.dialects import uop
78

@@ -26,7 +27,14 @@ class PyQrackMethods(interp.MethodTable):
2627
"tdg": "adjt",
2728
}
2829

29-
AXIS_MAP = {"rx": 1, "ry": 2, "rz": 3, "crx": 1, "cry": 2, "crz": 3}
30+
AXIS_MAP = {
31+
"rx": Pauli.PauliX,
32+
"ry": Pauli.PauliY,
33+
"rz": Pauli.PauliZ,
34+
"crx": Pauli.PauliX,
35+
"cry": Pauli.PauliY,
36+
"crz": Pauli.PauliZ,
37+
}
3038

3139
@interp.impl(uop.Barrier)
3240
def barrier(

test/pyqrack/runtime/test_qrack.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from kirin import ir
55

66
from bloqade import qasm2
7+
from pyqrack.pauli import Pauli
78
from bloqade.pyqrack.base import MockMemory, PyQrackInterpreter
89

910

@@ -63,9 +64,9 @@ def program():
6364

6465
sim_reg.assert_has_calls(
6566
[
66-
call.r(1, 0.5, 0),
67-
call.r(2, 0.5, 1),
68-
call.r(3, 0.5, 2),
67+
call.r(Pauli.PauliX, 0.5, 0),
68+
call.r(Pauli.PauliY, 0.5, 1),
69+
call.r(Pauli.PauliZ, 0.5, 2),
6970
]
7071
)
7172

@@ -130,7 +131,7 @@ def program():
130131
sim_reg = run_mock(program)
131132
sim_reg.assert_has_calls(
132133
[
133-
call.mcr(1, 0.5, [0], 1),
134+
call.mcr(Pauli.PauliX, 0.5, [0], 1),
134135
call.mcu([1], 2, 0, 0, 0.5),
135136
call.mcu([2], 0, 0.5, 0.2, 0.1),
136137
call.mcx([0, 1], 2),

0 commit comments

Comments
 (0)