microquantum.ir.nodes¶
MicroQuantum IR node types.
Nodes are immutable (frozen dataclasses) so IR passes can share structure freely and memoize comparisons. Each node understands the qubits, classical bits and symbolic parameters it touches — the minimal data required for inspection, validation and transformation.
The IR is intentionally NumPy-free: gate identity is structural (gate name + qubits + parameters), not matrix-based.
Node hierarchy:
IRNode
├── Gate
├── Measurement
├── Reset
├── Barrier
└── ConditionalBlock (contains a Condition + nested IRNode list)
Module Contents¶
- microquantum.ir.nodes.param_to_dict(param)[source]¶
Serialize an IR parameter to a JSON-safe dictionary.
- microquantum.ir.nodes.param_to_str(param)[source]¶
Render a parameter for human-readable IR strings.
- class microquantum.ir.nodes.Condition[source]¶
A classical condition guarding an operation or block.
- Variables:
bit – Classical bit index tested.
value – Value the bit must equal (0 or 1).
register – Optional classical register name.
- class microquantum.ir.nodes.IRNode[source]¶
Bases:
abc.ABCBase class for all MicroQuantum IR nodes.
Every concrete node must provide
qubits— either as a dataclass field (Gate, Barrier) or as a property (Measurement, Reset, ConditionalBlock). Thecbits/parametersresult properties declared here give conservative defaults.- property kind: str[source]¶
- Abstractmethod:
- Return type:
Node kind identifier (e.g. ‘gate’, ‘measure’, ‘reset’, …).
- class microquantum.ir.nodes.Gate[source]¶
Bases:
IRNodeA quantum gate operation in the IR.
- Variables:
name – Gate name from the SDK gate library (h, x, y, z, s, sdg, t, tdg, rx, ry, rz, cnot, cz, swap) or a custom operator name.
qubits – Target qubit indices (deterministic order).
params – Gate parameters. Numeric rotation angles are stored as plain floats; symbolic angles as Parameter/ParameterExpression.
condition – Optional
Conditionguarding the gate.source – Optional source/debug metadata (e.g. originating circuit gate index) attached by the builder.
- class microquantum.ir.nodes.Measurement[source]¶
Bases:
IRNodeA (mid-circuit or terminal) measurement of one qubit.
- Variables:
qubit – Qubit index measured.
classical – Classical bit index the outcome is stored into, or None when the outcome is only observed.
- class microquantum.ir.nodes.Reset[source]¶
Bases:
IRNodeReset a qubit to the |0> computational basis state.
Prepares the IR for dynamic-circuit and QEC workflows.
- class microquantum.ir.nodes.Barrier[source]¶
Bases:
IRNodeA synchronization barrier across a set of qubits.
- class microquantum.ir.nodes.ConditionalBlock[source]¶
Bases:
IRNodeA classically-controlled block of IR operations.
- Variables:
condition – The classical condition that gates the block.
operations – Ordered operations executed when the condition holds.