Skip to content

Commit 7c01627

Browse files
committed
Change pyqrack default of binary decision tree to fix measurements (#421)
Fixes strange issue where you'd get the wrong state vector if `isBinaryDecisionTree = True`.
1 parent 57c6f16 commit 7c01627

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/bloqade/pyqrack/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _default_pyqrack_args() -> PyQrackOptions:
4848
isSchmidtDecomposeMulti=True,
4949
isSchmidtDecompose=True,
5050
isStabilizerHybrid=False,
51-
isBinaryDecisionTree=True,
51+
isBinaryDecisionTree=False,
5252
isPaged=True,
5353
isCpuGpuHybrid=True,
5454
isOpenCL=True,

test/pyqrack/squin/test_kernel.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,35 @@ def main():
519519

520520
assert math.isclose(abs(ket[3]), 1, abs_tol=1e-6)
521521
assert ket[0] == ket[1] == ket[2] == 0
522+
523+
524+
def test_feed_forward():
525+
@squin.kernel
526+
def main():
527+
q = squin.qubit.new(3)
528+
h = squin.op.h()
529+
squin.qubit.apply(h, q[0])
530+
squin.qubit.apply(h, q[1])
531+
532+
cx = squin.op.cx()
533+
squin.qubit.apply(cx, q[0], q[2])
534+
squin.qubit.apply(cx, q[1], q[2])
535+
536+
squin.qubit.measure(q[2])
537+
538+
sim = StackMemorySimulator(min_qubits=3)
539+
540+
ket = sim.state_vector(main)
541+
542+
print(ket)
543+
544+
zero_count = 0
545+
half_count = 0
546+
547+
for k in ket:
548+
k_abs2 = abs(k) ** 2
549+
zero_count += k_abs2 == 0
550+
half_count += math.isclose(k_abs2, 0.5, abs_tol=1e-4)
551+
552+
assert zero_count == 6
553+
assert half_count == 2

0 commit comments

Comments
 (0)