Skip to content

Commit 5137de0

Browse files
committed
add in QASM2 adjoint to squin adjoint equivalents I missed the first round
1 parent 045fa00 commit 5137de0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/bloqade/squin/rewrite/qasm2/uop_1q_to_squin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
uop_stmts.Z: squin.z,
1212
uop_stmts.H: squin.h,
1313
uop_stmts.S: squin.s,
14-
uop_stmts.T: squin.t,
14+
uop_stmts.Sdag: squin.s_adj,
1515
uop_stmts.SX: squin.sqrt_x,
16+
uop_stmts.SXdag: squin.sqrt_x_adj,
17+
uop_stmts.Tdag: squin.t_adj,
18+
uop_stmts.T: squin.t,
1619
}
1720

1821

test/squin/passes/test_qasm2_to_squin.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ def non_parametric_gates():
7171
qasm2.z(q[0])
7272
qasm2.h(q[0])
7373
qasm2.s(q[0])
74+
qasm2.sdg(q[0])
7475
qasm2.t(q[0])
76+
qasm2.tdg(q[0])
7577
qasm2.sx(q[0])
78+
qasm2.sxdg(q[0])
7679

7780
# 2q gates
7881
qasm2.cx(q[0], q[1])
@@ -105,15 +108,35 @@ def non_parametric_gates():
105108
squin.gate.stmts.Z,
106109
squin.gate.stmts.H,
107110
squin.gate.stmts.S,
111+
squin.gate.stmts.S, # adjoint=True
108112
squin.gate.stmts.T,
113+
squin.gate.stmts.T, # adjoint=True
109114
squin.gate.stmts.SqrtX,
115+
squin.gate.stmts.SqrtX, # adjoint=True
110116
squin.gate.stmts.CX,
111117
squin.gate.stmts.CY,
112118
squin.gate.stmts.CZ,
113119
]
114120

115121
assert [type(stmt) for stmt in actual_stmts] == expected_stmts
116122

123+
has_s_adj = False
124+
has_t_adj = False
125+
has_sqrtx_adj = False
126+
127+
for stmt in actual_stmts:
128+
129+
if type(stmt) is squin.gate.stmts.S and stmt.adjoint:
130+
has_s_adj = True
131+
elif type(stmt) is squin.gate.stmts.T and stmt.adjoint:
132+
has_t_adj = True
133+
elif type(stmt) is squin.gate.stmts.SqrtX and stmt.adjoint:
134+
has_sqrtx_adj = True
135+
136+
assert has_s_adj
137+
assert has_t_adj
138+
assert has_sqrtx_adj
139+
117140

118141
def test_parametric_gates():
119142

0 commit comments

Comments
 (0)