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
Name
Type
Default
Description
stim_str
str
required
The string representation of a STIM circuit to load.
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
Other Parameters
Name
Type
Description
kernel_name
str
The name of the kernel to load. Defaults to "main".
ignore_unknown_stim
bool
If True, don't throw a build error on an unimplemented stim instruction.
error_unknown_nonstim
bool
If True, throw a build error if an unknown tag is used on the `I_ERROR` instruction.
nonstim_noise_ops
dict[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`).
dialects
ir.DialectGroup | None
The dialects to use. Defaults to `stim.main`.
globals
dict[str, Any] | None
The global variables to use. Defaults to None.
file
str | None
The file name for error reporting. Defaults to None.
lineno_offset
int
The line number offset for error reporting. Defaults to 0.
col_offset
int
The column number offset for error reporting. Defaults to 0.
compactify
bool
Whether to compactify the output. Defaults to True.