dialects
auxiliary
stmts
const
ConstBool
Bases: Statement
IR Statement representing a constant float value.
result
class-attribute
instance-attribute
result: ResultValue = result(Bool)
result (Float): The result value.
value
class-attribute
instance-attribute
value: bool = attribute(Bool)
value (float): The constant float value.
ConstFloat
Bases: Statement
IR Statement representing a constant float value.
result
class-attribute
instance-attribute
result: ResultValue = result(Float)
result (Float): The result value.
value
class-attribute
instance-attribute
value: float = attribute(Float)
value (float): The constant float value.
ConstInt
Bases: Statement
IR Statement representing a constant integer value.
result
class-attribute
instance-attribute
result: ResultValue = result(Int)
result (Int): The result value.
value
class-attribute
instance-attribute
value: int = attribute(Int)
value (int): The constant integer value.
ConstStr
Bases: Statement
IR Statement representing a constant str value.
result
class-attribute
instance-attribute
result: ResultValue = result(String)
result (str): The result value.
value
class-attribute
instance-attribute
value: str = attribute(String)
value (str): The constant str value.
Neg
Bases: Statement
IR Statement representing a negation operation.
collapse
stmts
measure
Measurement
Bases: Statement
p
class-attribute
instance-attribute
p: SSAValue = argument(Float)
probability of noise introduced by measurement. For example 0.01 means 1% the measurement will be flipped
pp_measure
PPMeasurement
Bases: Statement
p
class-attribute
instance-attribute
p: SSAValue = argument(Float)
probability of noise introduced by measurement. For example 0.01 means 1% the measurement will be flipped
parse
lowering
One-to-one lowering routine from stim circuit to a stim-dialect kirin kernel.
loads
loads(
stim_str: str,
*,
kernel_name: str = "main",
ignore_unknown_stim: bool = False,
error_unknown_nonstim: bool = False,
nonstim_noise_ops: dict[str, type[Statement]] = {},
dialects: 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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stim_str
|
str
|
The string representation of a STIM circuit to load. |
required |
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 |
nonstim_noise_ops |
dict[str, Statement]
|
Additional statements to
represent non-standard stim operations. The dictionary key should match the
tag used to identify it in stim (stim format
|
dialects |
DialectGroup | None
|
The dialects to use. Defaults to |
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. |
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]
''')
Source code in .venv/lib/python3.12/site-packages/bloqade/stim/parse/lowering.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|