Skip to content

Commit 56ccfaa

Browse files
committed
split up compilation from creating the task
1 parent 88203d9 commit 56ccfaa

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/bloqade/pyqrack/device.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,12 @@ class NoiseSimulatorBase(
207207
optimize_parallel_gates: bool = field(default=True, kw_only=True)
208208
decompose_native_gates: bool = field(default=True, kw_only=True)
209209

210-
def task(
210+
def _compile_kernel(
211211
self,
212212
kernel: ir.Method[Params, RetType],
213-
args: tuple[Any, ...] = (),
214-
kwargs: dict[str, Any] | None = None,
215-
):
216-
if kwargs is None:
217-
kwargs = {}
218-
213+
args: tuple[Any, ...],
214+
kwargs: dict[str, Any],
215+
) -> ir.Method[[], RetType]:
219216
if len(args) > 0 or len(kwargs) > 0:
220217
folded_kernel = _arg_closure(kernel, args, kwargs)
221218
args = ()
@@ -243,6 +240,19 @@ def task(
243240
folded_kernel.dialects.add(native.dialect)
244241
)
245242

243+
return folded_kernel
244+
245+
def task(
246+
self,
247+
kernel: ir.Method[Params, RetType],
248+
args: tuple[Any, ...] = (),
249+
kwargs: dict[str, Any] | None = None,
250+
):
251+
if kwargs is None:
252+
kwargs = {}
253+
254+
folded_kernel = self._compile_kernel(kernel, args, kwargs)
255+
246256
pyqrack_interp = PyQrackInterpreter(
247257
folded_kernel.dialects,
248258
memory=DynamicMemory(self.options.copy()),

0 commit comments

Comments
 (0)