mimiqcircuits.backends.compiled

Compiled-circuit types and the metadata they carry.

LocalBackend.compile() turns a Circuit into a backend-specific CompiledCircuit. The compile step must be pure: no RNG, no sampling. Stochastic per-trajectory work belongs in LocalBackend.prepare_trajectory().

Every compiled circuit carries a CompileMetadata (read via its metadata attribute) so generic drivers can read measurement analysis, qubit permutations, and other compile-time side effects without unpacking a tuple.

Concrete types:

  • DefaultCompiledCircuit — generic passthrough wrap when the backend’s lowering already returns its final compiled form.

  • CompiledParametricCircuit — compiled artifact that still holds free symbolic parameters; resolve them via LocalBackend.bind().

Classes

CompileMetadata([measures, active_qubits, ...])

Compile-time side effects carried alongside a CompiledCircuit.

CompiledCircuit()

Backend-specific deterministic representation of a circuit.

CompiledParametricCircuit(_source[, _metadata])

Compiled artifact that still carries free symbolic parameters.

DefaultCompiledCircuit(_source[, _metadata])

Generic passthrough wrapper.

Exceptions

UnboundSymbolicError(backend_name)

Raised when LocalBackend.compile() is handed a circuit that still has free symbolic parameters but the backend does not advertise the "parametric" capability.

class mimiqcircuits.backends.compiled.CompileMetadata(measures=<factory>, active_qubits=<factory>, qubit_flips=<factory>, qubit_permutation=None, measure_action_counts=<factory>, prefix_endpoint=0)[source]

Bases: object

Compile-time side effects carried alongside a CompiledCircuit.

measures

Measurement-analysis entries (classifies each classical bit as Unused / Direct / Flip / Const0 / Const1). Empty when analysis has not run.

Type:

list

active_qubits

Qubit indices that must be simulated; the others can be dropped because they are provably |0⟩ at measurement.

Type:

list[int]

qubit_flips

Per-qubit final NOT flag absorbed from trailing single-qubit X gates.

Type:

list[bool]

qubit_permutation

Composed permutation applied by the pass pipeline. None when the pipeline is identity on qubit indices.

Type:

list[int] or None

measure_action_counts

Frequency of each measurement-action branch (debug aid).

Type:

dict[str, int]

prefix_endpoint

Index of the last instruction folded into the deterministic prefix when the backend splits prefix from stochastic suffix; 0 when no split applies.

Type:

int

measures: list
active_qubits: list[int]
qubit_flips: list[bool]
qubit_permutation: list[int] | None = None
measure_action_counts: dict[str, int]
prefix_endpoint: int = 0
__init__(measures=<factory>, active_qubits=<factory>, qubit_flips=<factory>, qubit_permutation=None, measure_action_counts=<factory>, prefix_endpoint=0)
class mimiqcircuits.backends.compiled.CompiledCircuit[source]

Bases: object

Backend-specific deterministic representation of a circuit.

Returned by LocalBackend.compile(). Concrete backends subclass to carry whatever payload they need — an MPO for an MPS simulator, a plain Circuit for a state-vector backend, a streaming thunk for an out-of-core simulator, …

Every subclass exposes two attributes:

property metadata: CompileMetadata
property source

The backend-specific artifact wrapped by this compiled circuit (e.g. a Circuit, an MPO, a streaming thunk).

class mimiqcircuits.backends.compiled.DefaultCompiledCircuit(_source, _metadata=<factory>)[source]

Bases: CompiledCircuit

Generic passthrough wrapper.

Use this when your backend’s compile step is effectively the identity — for example a state-vector simulator that consumes the input Circuit directly.

property metadata: CompileMetadata
property source

The backend-specific artifact wrapped by this compiled circuit (e.g. a Circuit, an MPO, a streaming thunk).

__init__(_source, _metadata=<factory>)
class mimiqcircuits.backends.compiled.CompiledParametricCircuit(_source, _metadata=<factory>)[source]

Bases: CompiledCircuit

Compiled artifact that still carries free symbolic parameters.

Produced by LocalBackend.compile() when the input is symbolic and the backend advertises the "parametric" capability. Resolve the parameters by calling LocalBackend.bind().

property metadata: CompileMetadata
property source

The backend-specific artifact wrapped by this compiled circuit (e.g. a Circuit, an MPO, a streaming thunk).

__init__(_source, _metadata=<factory>)
exception mimiqcircuits.backends.compiled.UnboundSymbolicError(backend_name)[source]

Bases: Exception

Raised when LocalBackend.compile() is handed a circuit that still has free symbolic parameters but the backend does not advertise the "parametric" capability.

__init__(backend_name)[source]