File tree 2 files changed +12
-9
lines changed
src/bloqade/pyqrack/squin
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -217,8 +217,12 @@ class PhaseOpRuntime(MtrxOpRuntime):
217
217
218
218
def mat (self , adjoint : bool ) -> list [complex ]:
219
219
sign = (- 1 ) ** (not adjoint )
220
- phase = np .exp (sign * 1j * self .theta )
221
- return [self .global_ * phase , 0 , 0 , phase ]
220
+ local_phase = np .exp (sign * 1j * self .theta )
221
+
222
+ # NOTE: this is just 1 if we want a local shift
223
+ global_phase = np .exp (sign * 1j * self .theta * self .global_ )
224
+
225
+ return [global_phase , 0 , 0 , local_phase ]
222
226
223
227
224
228
@dataclass (frozen = True )
Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ def new():
23
23
assert out == [1.0 ] + [0.0 ] * (2 ** 3 - 1 )
24
24
25
25
@squin .kernel
26
- def measure ():
26
+ def m ():
27
27
q = squin .qubit .new (3 )
28
28
m = squin .qubit .measure (q )
29
29
squin .qubit .reset (q )
30
30
return m
31
31
32
32
target = PyQrack (3 )
33
- result = target .run (measure )
33
+ result = target .run (m )
34
34
assert isinstance (result , list )
35
35
assert result == [0 , 0 , 0 ]
36
36
@@ -157,17 +157,15 @@ def main():
157
157
h = squin .op .h ()
158
158
squin .qubit .apply (h , q )
159
159
160
- # rotate local phase by pi/2
161
- p = squin .op .shift (math .pi / 2 )
160
+ p = squin .op .shift (math .pi )
162
161
squin .qubit .apply (p , q )
163
162
164
- # the next hadamard should rotate it back to 0
165
163
squin .qubit .apply (h , q )
166
164
return squin .qubit .measure (q )
167
165
168
166
target = PyQrack (1 )
169
167
result = target .run (main )
170
- assert result == [0 ]
168
+ assert result == [1 ]
171
169
172
170
173
171
def test_sp ():
@@ -334,7 +332,8 @@ def main():
334
332
# test_mult()
335
333
# test_kron()
336
334
# test_scale()
337
- # test_phase()
335
+ # for i in range(100):
336
+ # test_phase()
338
337
# test_sp()
339
338
# test_adjoint()
340
339
# for i in range(100):
You can’t perform that action at this time.
0 commit comments