Skip to content

bloqade.stim.parse.lowering.loads

← Module overview

functionloadssource

bloqade.stim.parse.lowering.loads

Signature
def loads(stim_str: str, *, kernel_name: str = 'main', ignore_unknown_stim: bool = False, error_unknown_nonstim: bool = False, nonstim_noise_ops: dict[str, type[kirin.ir.Statement]] = {}, dialects: ir.DialectGroup | None = None, globals: dict[str, Any] | None = None, file: str | None = None, lineno_offset: int = 0, col_offset: int = 0, compactify: bool = True) -> ir.Method[[], None]

Loads a STIM string and returns the corresponding kernel object.

Example:

from bloqade.stim.lowering import loads
method = loads('''
X 0 2 4
DEPOLARIZE1(0.01) 0
I_ERROR[CUSTOM_ERROR](0.02) 2 4
M 0 2 4
DETECTOR rec[-1] rec[-2]
''')

Parameters

NameTypeDefaultDescription
stim_strstrrequiredThe string representation of a STIM circuit to load.
kernel_namestr'main'
ignore_unknown_stimboolFalse
error_unknown_nonstimboolFalse
nonstim_noise_opsdict[str, type[kirin.ir.Statement]]{}
dialectsir.DialectGroup | NoneNone
globalsdict[str, Any] | NoneNone
filestr | NoneNone
lineno_offsetint0
col_offsetint0
compactifyboolTrue

Other Parameters

NameTypeDescription
kernel_namestrThe name of the kernel to load. Defaults to "main".
ignore_unknown_stimboolIf True, don't throw a build error on an unimplemented stim instruction.
error_unknown_nonstimboolIf True, throw a build error if an unknown tag is used on the `I_ERROR` instruction.
nonstim_noise_opsdict[str, kirin.ir.Statement]Additional statements to represent non-standard stim operations. The dictionary key should match the tag used to identify it in stim (stim format `I_ERROR[MY_NOISE](0.05) 0 1 2 3` or `I_ERROR[MY_CORRELATED_NOISE:2417696374](0.03) 1 3 5`).
dialectsir.DialectGroup | NoneThe dialects to use. Defaults to `stim.main`.
globalsdict[str, Any] | NoneThe global variables to use. Defaults to None.
filestr | NoneThe file name for error reporting. Defaults to None.
lineno_offsetintThe line number offset for error reporting. Defaults to 0.
col_offsetintThe column number offset for error reporting. Defaults to 0.
compactifyboolWhether to compactify the output. Defaults to True.

Returns

ir.Method[[], None]

source