-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
Description
MWE:
from bloqade import squin
from bloqade.cirq_utils import emit_circuit
@squin.kernel
def subroutine():
q = squin.qubit.new(1)
squin.h(q[0])
return q[0]
@squin.kernel
def main():
q1 = subroutine()
q2 = subroutine()
squin.cx(q1, q2)
circuit = emit_circuit(main)
print(circuit)
raises an exception:
Traceback (most recent call last):
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/debug/circuit/qubit_refactor.py", line 19, in <module>
circuit = emit_circuit(main)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 114, in emit_circuit
return emitter.run(mt, args=args)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/interp/base.py", line 161, in run
raise e
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/interp/base.py", line 156, in run
_, results = self.run_method(mt, args)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 149, in run_method
return self.run_callable(method.code, args)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/interp/base.py", line 228, in run_callable
results = self.run_callable_region(frame, code, body, args)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 163, in run_callable_region
results = self.eval_stmt(frame, code)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/interp/base.py", line 377, in eval_stmt
results = method(self, frame, stmt)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/registry.py", line 25, in __call__
return self.impl(self.parent, interp, frame, stmt)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 185, in emit_func
emit.run_ssacfg_region(frame, stmt.body, ())
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/emit/abc.py", line 44, in run_ssacfg_region
block_header = self.emit_block(frame, succ.block)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 173, in emit_block
result = self.eval_stmt(frame, stmt)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/interp/base.py", line 377, in eval_stmt
results = method(self, frame, stmt)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/registry.py", line 25, in __call__
return self.impl(self.parent, interp, frame, stmt)
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 222, in emit_invoke
args = [frame.get(arg_) for arg_ in stmt.inputs]
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/bloqade-circuit/src/bloqade/cirq_utils/emit/base.py", line 222, in <listcomp>
args = [frame.get(arg_) for arg_ in stmt.inputs]
File "/Users/pweinberg/Documents/atom_compiler_dev/kirin-workspace/kirin/src/kirin/interp/frame.py", line 130, in get
raise err
kirin.interp.exceptions.InterpreterError: SSAValue <ResultValue[Qubit] q2, uses: 1> not found
I think we need to inline any subroutines that allocate qubits but this also effects the qubit refactor #518
cc: @Roger-luo