Skip to content

bloqade.stim.parse.lowering.Stim

← Module overview

classStimsource

bloqade.stim.parse.lowering.Stim

Bases: lowering.LoweringABC[Node]

Signature
class Stim(*, max_lines: int = 3, hint_indent: int = 2, hint_show_lineno: bool = True, stacktrace: bool = True, nonstim_noise_ops: dict[str, kirin.ir.Statement] = dict(), ignore_unknown_stim: bool = False, error_unknown_nonstim: bool = False)

Parameters

NameTypeDefaultDescription
max_linesint3
hint_indentint2
hint_show_linenoboolTrue
stacktraceboolTrue
nonstim_noise_opsdict[str, kirin.ir.Statement]dict()
ignore_unknown_stimboolFalse
error_unknown_nonstimboolFalse

Attributes

NameTypeDefaultDescription
max_linesintfield(default=3, kw_only=True)
hint_indentintfield(default=2, kw_only=True)
hint_show_linenoboolfield(default=True, kw_only=True)
stacktraceboolfield(default=True, kw_only=True)
nonstim_noise_opsdict[str, kirin.ir.Statement]field(default_factory=dict, kw_only=True)
ignore_unknown_stimboolfield(default=False, kw_only=True)
error_unknown_nonstimboolfield(default=False, kw_only=True)

methodrunsource

bloqade.stim.parse.lowering.Stim.run

Signature
def run(stmt: Node, *, source: str | None = None, globals: dict[str, Any] | None = None, file: str | None = None, lineno_offset: int = 0, col_offset: int = 0, compactify: bool = True) -> ir.Region

Parameters

NameTypeDefaultDescription
stmtNoderequired
sourcestr | NoneNone
globalsdict[str, Any] | NoneNone
filestr | NoneNone
lineno_offsetint0
col_offsetint0
compactifyboolTrue

Returns

ir.Region

source

methodget_framesource

bloqade.stim.parse.lowering.Stim.get_frame

Signature
def get_frame(stmt: Node, source: str | None = None, globals: dict[str, Any] | None = None, file: str | None = None, lineno_offset: int = 0, col_offset: int = 0, compactify: bool = True) -> lowering.Frame

Parameters

NameTypeDefaultDescription
stmtNoderequired
sourcestr | NoneNone
globalsdict[str, Any] | NoneNone
filestr | NoneNone
lineno_offsetint0
col_offsetint0
compactifyboolTrue

Returns

lowering.Frame

source

methodlower_literalsource

bloqade.stim.parse.lowering.Stim.lower_literal

Signature
def lower_literal(state: lowering.State[Node], value: LiteralType) -> ir.SSAValue

Parameters

NameTypeDescription
statelowering.State[Node]
valueLiteralType

Returns

ir.SSAValue

source

methodlower_globalsource

bloqade.stim.parse.lowering.Stim.lower_global

Signature
def lower_global(state: lowering.State[Node], node: Node) -> lowering.LoweringABC.Result

Parameters

NameTypeDescription
statelowering.State[Node]
nodeNode

Returns

lowering.LoweringABC.Result

source

methodvisitsource

bloqade.stim.parse.lowering.Stim.visit

def visit(state: lowering.State[Node], node: Node) -> lowering.Result

Parameters

NameTypeDescription
statelowering.State[Node]
nodeNode

Returns

lowering.Result

source

methodvisit_RZsource

bloqade.stim.parse.lowering.Stim.visit_RZ

Signature
def visit_RZ(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_RXsource

bloqade.stim.parse.lowering.Stim.visit_RX

Signature
def visit_RX(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_RYsource

bloqade.stim.parse.lowering.Stim.visit_RY

Signature
def visit_RY(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MXsource

bloqade.stim.parse.lowering.Stim.visit_MX

Signature
def visit_MX(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MYsource

bloqade.stim.parse.lowering.Stim.visit_MY

Signature
def visit_MY(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MZsource

bloqade.stim.parse.lowering.Stim.visit_MZ

Signature
def visit_MZ(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MXXsource

bloqade.stim.parse.lowering.Stim.visit_MXX

Signature
def visit_MXX(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MYYsource

bloqade.stim.parse.lowering.Stim.visit_MYY

Signature
def visit_MYY(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MZZsource

bloqade.stim.parse.lowering.Stim.visit_MZZ

Signature
def visit_MZZ(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_MPPsource

bloqade.stim.parse.lowering.Stim.visit_MPP

Signature
def visit_MPP(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_TICKsource

bloqade.stim.parse.lowering.Stim.visit_TICK

Signature
def visit_TICK(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_DETECTORsource

bloqade.stim.parse.lowering.Stim.visit_DETECTOR

Signature
def visit_DETECTOR(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_OBSERVABLE_INCLUDEsource

bloqade.stim.parse.lowering.Stim.visit_OBSERVABLE_INCLUDE

Signature
def visit_OBSERVABLE_INCLUDE(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_QUBIT_COORDSsource

bloqade.stim.parse.lowering.Stim.visit_QUBIT_COORDS

Signature
def visit_QUBIT_COORDS(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Xsource

bloqade.stim.parse.lowering.Stim.visit_X

Signature
def visit_X(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Ysource

bloqade.stim.parse.lowering.Stim.visit_Y

Signature
def visit_Y(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Zsource

bloqade.stim.parse.lowering.Stim.visit_Z

Signature
def visit_Z(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Isource

bloqade.stim.parse.lowering.Stim.visit_I

Signature
def visit_I(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Hsource

bloqade.stim.parse.lowering.Stim.visit_H

Signature
def visit_H(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Ssource

bloqade.stim.parse.lowering.Stim.visit_S

Signature
def visit_S(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_S_DAGsource

bloqade.stim.parse.lowering.Stim.visit_S_DAG

Signature
def visit_S_DAG(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SQRT_Xsource

bloqade.stim.parse.lowering.Stim.visit_SQRT_X

Signature
def visit_SQRT_X(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SQRT_Ysource

bloqade.stim.parse.lowering.Stim.visit_SQRT_Y

Signature
def visit_SQRT_Y(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SQRT_X_DAGsource

bloqade.stim.parse.lowering.Stim.visit_SQRT_X_DAG

Signature
def visit_SQRT_X_DAG(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SQRT_Y_DAGsource

bloqade.stim.parse.lowering.Stim.visit_SQRT_Y_DAG

Signature
def visit_SQRT_Y_DAG(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SWAPsource

bloqade.stim.parse.lowering.Stim.visit_SWAP

Signature
def visit_SWAP(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_CXsource

bloqade.stim.parse.lowering.Stim.visit_CX

Signature
def visit_CX(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_CYsource

bloqade.stim.parse.lowering.Stim.visit_CY

Signature
def visit_CY(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_CZsource

bloqade.stim.parse.lowering.Stim.visit_CZ

Signature
def visit_CZ(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SPPsource

bloqade.stim.parse.lowering.Stim.visit_SPP

Signature
def visit_SPP(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_SPP_DAGsource

bloqade.stim.parse.lowering.Stim.visit_SPP_DAG

Signature
def visit_SPP_DAG(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_X_ERRORsource

bloqade.stim.parse.lowering.Stim.visit_X_ERROR

Signature
def visit_X_ERROR(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Y_ERRORsource

bloqade.stim.parse.lowering.Stim.visit_Y_ERROR

Signature
def visit_Y_ERROR(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_Z_ERRORsource

bloqade.stim.parse.lowering.Stim.visit_Z_ERROR

Signature
def visit_Z_ERROR(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_DEPOLARIZE1source

bloqade.stim.parse.lowering.Stim.visit_DEPOLARIZE1

Signature
def visit_DEPOLARIZE1(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_DEPOLARIZE2source

bloqade.stim.parse.lowering.Stim.visit_DEPOLARIZE2

Signature
def visit_DEPOLARIZE2(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_PAULI_CHANNEL_1source

bloqade.stim.parse.lowering.Stim.visit_PAULI_CHANNEL_1

Signature
def visit_PAULI_CHANNEL_1(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_PAULI_CHANNEL_2source

bloqade.stim.parse.lowering.Stim.visit_PAULI_CHANNEL_2

Signature
def visit_PAULI_CHANNEL_2(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement

source

methodvisit_I_ERRORsource

bloqade.stim.parse.lowering.Stim.visit_I_ERROR

Signature
def visit_I_ERROR(state: lowering.State[Node], node: stim.CircuitInstruction) -> ir.Statement | None

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

ir.Statement | None

source

methodvisit_CircuitInstructionsource

bloqade.stim.parse.lowering.Stim.visit_CircuitInstruction

Signature
def visit_CircuitInstruction(state: lowering.State[Node], node: stim.CircuitInstruction) -> lowering.Result

Parameters

NameTypeDescription
statelowering.State[Node]
nodestim.CircuitInstruction

Returns

lowering.Result

source