Skip to content

Commit 46dfca9

Browse files
committed
Replace EmitError with InterpreterError in emit_circuit and related tests
1 parent 28461af commit 46dfca9

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/bloqade/cirq_utils/emit/base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import cirq
66
from kirin import ir, types, interp
7-
from kirin.emit import EmitABC, EmitError, EmitFrame
7+
from kirin.emit import EmitABC, EmitFrame
88
from kirin.interp import MethodTable, impl
99
from kirin.dialects import py, func
1010
from typing_extensions import Self
@@ -102,7 +102,7 @@ def main():
102102
and isinstance(mt.code, func.Function)
103103
and not mt.code.signature.output.is_subseteq(types.NoneType)
104104
):
105-
raise EmitError(
105+
raise interp.exceptions.InterpreterError(
106106
"The method you are trying to convert to a circuit has a return value, but returning from a circuit is not supported."
107107
" Set `ignore_returns = True` in order to simply ignore the return values and emit a circuit."
108108
)
@@ -116,12 +116,12 @@ def main():
116116

117117
symbol_op_trait = mt.code.get_trait(ir.SymbolOpInterface)
118118
if (symbol_op_trait := mt.code.get_trait(ir.SymbolOpInterface)) is None:
119-
raise EmitError("The method is not a symbol, cannot emit circuit!")
119+
raise interp.exceptions.InterpreterError("The method is not a symbol, cannot emit circuit!")
120120

121121
sym_name = symbol_op_trait.get_sym_name(mt.code).unwrap()
122122

123123
if (signature_trait := mt.code.get_trait(ir.HasSignature)) is None:
124-
raise EmitError(
124+
raise interp.exceptions.InterpreterError(
125125
f"The method {sym_name} does not have a signature, cannot emit circuit!"
126126
)
127127

@@ -135,7 +135,7 @@ def main():
135135

136136
assert first_stmt is not None, "Method has no statements!"
137137
if len(args_ssa) - 1 != len(args):
138-
raise EmitError(
138+
raise interp.exceptions.InterpreterError(
139139
f"The method {sym_name} takes {len(args_ssa) - 1} arguments, but you passed in {len(args)} via the `args` keyword!"
140140
)
141141

@@ -166,7 +166,7 @@ def _default_kernel():
166166

167167
@dataclass
168168
class EmitCirq(EmitABC[EmitCirqFrame, cirq.Circuit]):
169-
keys = ["emit.cirq", "main"]
169+
keys = ("emit.cirq", "emit.main")
170170
dialects: ir.DialectGroup = field(default_factory=_default_kernel)
171171
void = cirq.Circuit()
172172
qubits: Sequence[cirq.Qid] | None = None
@@ -226,7 +226,7 @@ def emit_func(self, emit: EmitCirq, frame: EmitCirqFrame, stmt: func.Function):
226226

227227
@impl(func.Invoke)
228228
def emit_invoke(self, emit: EmitCirq, frame: EmitCirqFrame, stmt: func.Invoke):
229-
raise EmitError(
229+
raise interp.exceptions.InterpreterError(
230230
"Function invokes should need to be inlined! "
231231
"If you called the emit_circuit method, that should have happened, please report this issue."
232232
)

test/cirq_utils/test_clifford_to_cirq.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import cirq
55
import numpy as np
66
import pytest
7-
from kirin.emit import EmitError
7+
from kirin.interp.exceptions import InterpreterError
88
from kirin.dialects import ilist
99

1010
from bloqade import squin
@@ -129,7 +129,7 @@ def main():
129129

130130
print(circuit)
131131

132-
with pytest.raises(EmitError):
132+
with pytest.raises(InterpreterError):
133133
emit_circuit(sub_kernel)
134134

135135
@squin.kernel

0 commit comments

Comments
 (0)