Skip to content

Commit 0cf3d39

Browse files
committed
Check whether qubits are active before applying operator
1 parent b997c4a commit 0cf3d39

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/bloqade/pyqrack/squin/qubit.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ def new(self, interp: PyQrackInterpreter, frame: interp.Frame, stmt: qubit.New):
2525

2626
@interp.impl(qubit.Apply)
2727
def apply(self, interp: PyQrackInterpreter, frame: interp.Frame, stmt: qubit.Apply):
28-
operator: OperatorRuntimeABC = frame.get(stmt.operator)
2928
qubits: ilist.IList[PyQrackQubit, Any] = frame.get(stmt.qubits)
29+
30+
for qbit in qubits:
31+
if not qbit.is_active():
32+
return ()
33+
34+
operator: OperatorRuntimeABC = frame.get(stmt.operator)
3035
operator.apply(*qubits)
3136

3237
@interp.impl(qubit.Broadcast)

test/pyqrack/test_squin.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ def main():
314314
def test_wire():
315315
@squin.wired
316316
def main():
317-
w = squin.wire.unwrap(1)
317+
q = squin.qubit.new(1)
318+
w = squin.wire.unwrap(q[0])
318319
x = squin.op.x()
319320
squin.wire.apply(x, w)
320321
return w

0 commit comments

Comments
 (0)