mqt.core.mlir

MQT Core MLIR compiler bindings.

Module Contents

class QIRProfile

Bases: enum.Enum

QIR target profiles.

BASE = 0

The QIR Base Profile.

ADAPTIVE = 1

The QIR Adaptive Profile.

class OutputFormat

Bases: enum.Enum

Default compiler output formats.

QC_IMPORT = 0

QC directly after frontend import.

QCO = 1

QCO immediately after conversion, before optimization.

QCO_OPTIMIZED = 2

QCO after the configured optimization pipeline.

QC = 3

QC after the optimized QCO round trip.

OPENQASM3 = 4

OpenQASM 3 after the optimized QCO round trip.

JEFF = 5

Serializable jeff MLIR.

QIR_BASE = 6

QIR for the Base Profile.

QIR_ADAPTIVE = 7

QIR for the Adaptive Profile.

class PayloadEncoding

Bases: enum.Enum

Payload representation encoding.

TEXT = 0
BINARY = 1
class PayloadFormat(format_id: str, version: str, profile: str = '', encoding: PayloadEncoding = PayloadEncoding.TEXT)

Exact payload identity.

property format_id: str
property version: str
property profile: str
property encoding: PayloadEncoding
class ProgramConstraint(constraint_id: str, value: int)

One payload capability constraint.

property constraint_id: str
property value: int
MAX_NESTING_DEPTH: str = 'max-control-flow-nesting-depth'
MAX_ITERATION_COUNT: str = 'max-iteration-count'
MAX_CASE_COUNT: str = 'max-case-count'
class ProgramCapability(capability_id: str, value: int = 0, constraints: Sequence[ProgramConstraint] = [])

One payload execution capability.

property capability_id: str
property value: int
property constraints: list[ProgramConstraint]
FORWARD_BRANCHING: str = 'forward-branching'
COUNTED_ITERATION: str = 'counted-iteration'
CONDITIONAL_LOOP: str = 'conditional-loop'
MULTIWAY_BRANCHING: str = 'multiway-branching'
class PayloadSpecification(payload_format: PayloadFormat, capabilities: Sequence[ProgramCapability] = [], optional_capabilities_known: bool = False)

Selected payload execution contract.

property format: PayloadFormat

The exact selected payload format.

property capabilities: list[ProgramCapability]

The effective payload capabilities.

property optional_capabilities_known: bool

Whether optional capability metadata is complete.

class CompilerTarget(num_sites: int, *, connectivity: CompilerTarget, native_operations: CompilerTarget, duration_unit: CompilerTarget | None = None)
class CompilerTarget(name: str, num_sites: int, *, connectivity: CompilerTarget, native_operations: CompilerTarget, duration_unit: CompilerTarget | None = None)
class CompilerTarget(sites: Sequence[CompilerTarget], *, connectivity: CompilerTarget, native_operations: CompilerTarget, duration_unit: CompilerTarget | None = None)
class CompilerTarget(name: str, sites: Sequence[CompilerTarget], *, connectivity: CompilerTarget, native_operations: CompilerTarget, duration_unit: CompilerTarget | None = None)

Immutable MQT compiler target.

Every target has either all-to-all or explicitly enumerated connectivity and either unrestricted or explicitly enumerated native-operation support.

class DurationUnit(unit: str, scale_factor: float)

Unit for raw target timing metadata.

property unit: str

The reported duration unit.

property scale_factor: float

The multiplier applied to raw timing values.

class Site(site_id: int, name: str | None = None, t1: int | None = None, t2: int | None = None)

A hardware site and its optional metadata.

property id: int

The target-defined nonnegative site identifier.

property name: str | None

The reported site name, if available.

property t1: int | None

The raw T1 coherence time, if available.

property t2: int | None

The raw T2 coherence time, if available.

class SiteTuple(sites: Sequence[int], duration: int | None = None, fidelity: float | None = None)

A supported ordered placement with optional calibration.

property sites: list[int]

The ordered target site identifiers.

property duration: int | None

The raw operation duration, if available.

property fidelity: float | None

The operation fidelity, if available.

class OperationArityKind

Bases: enum.Enum

How an operation capability accepts qubit widths.

FIXED = 0
VARIADIC = 1
class OperationArity

Accepted operation qubit widths.

static fixed(value: int) → CompilerTarget

Create an exact operation arity.

static variadic(minimum: int) → CompilerTarget

Create an operation arity with an inclusive minimum.

Capability construction requires a positive minimum.

property kind: CompilerTarget

The arity kind.

property value: int

The exact arity or inclusive variadic minimum.

accepts(width: int) → bool

Whether this arity accepts a concrete width.

class OperationCapability(name: str, arity: int | CompilerTarget, num_parameters: int, site_tuples: Sequence[CompilerTarget | Sequence[int]] | None = None, duration: int | None = None, fidelity: float | None = None, *, fixed_parameters: Sequence[float | None] = (), canonical_name: str | None = None, parameter_bounds: Sequence[tuple[float, float] | None] = ())

A target operation capability, calibration, and ordered applicability.

property name: str

The exact reported operation name.

property canonical_name: str

The normalized compiler operation name.

property arity: CompilerTarget

The accepted operation arity.

property num_parameters: int

The number of real-valued parameters.

property site_tuples: list[CompilerTarget]

Supported ordered placements with optional calibration; empty means general applicability.

property parameter_bounds: list[tuple[float, float] | None]

Inclusive parameter intervals; None leaves a parameter unbounded.

property fixed_parameters: list[float | None]

Fixed values or None per parameter; empty means unrestricted.

Constants use absolute tolerance 1e-15 without angle wrapping.

property duration: int | None

The raw default duration, if available.

property fidelity: float | None

The default fidelity, if available.

class GateKind

Bases: enum.Enum

Recognized native gate capability.

U = 0
X = 1
SX = 2
RZ = 3
RX = 4
RY = 5
R = 6
RXX = 7
RYY = 8
RZX = 9
RZZ = 10
ISWAP = 11
CZ = 12
CX = 13
ECR = 14
SQRTISWAP = 15
class SingleQubitBasis

Bases: enum.Enum

Recognized target-wide single-qubit synthesis basis.

U = 0
ZSXX = 1
R = 2
XZX = 3
XYX = 4
ZYZ = 5
ZXZ = 6
class AngleSupport

Bases: enum.Enum

Angle domain used by native entangler synthesis.

FIXED = 0
UNRESTRICTED = 1
ZERO_TO_HALF_PI = 2
class Entangler

A native synthesis entangler and its angle support.

property gate: CompilerTarget

The native gate kind.

property parameterized: bool

Whether synthesis can vary the entangler angle.

property angles: CompilerTarget

The angle domain used by synthesis.

class SynthesisBasis

One synthesis basis usable across the complete target.

property single_qubit: CompilerTarget

The single-qubit synthesis basis.

property entangler: CompilerTarget | None

The two-qubit entangler, or None when none is usable.

class ConnectivityKind

Bases: enum.Enum

The target connectivity model.

ALL_TO_ALL = 0
EXPLICIT = 1
class Connectivity(couplings: Sequence[tuple[int, int]])

A target connectivity model.

static all_to_all() → CompilerTarget

Create an all-to-all connectivity model.

property kind: CompilerTarget

The connectivity model.

property couplings: list[tuple[int, int]]

The explicit couplings, if present.

class NativeOperationsKind

Bases: enum.Enum

The native-operation support model.

UNRESTRICTED = 0
EXPLICIT = 1
class NativeOperations(operations: Sequence[CompilerTarget])

Native-operation support.

static from_qiskit(source: Target | BackendV2, *, operation_names: Iterable[str] | None = None) → CompilerTarget

Import gate capabilities and parameter constraints, ignoring physical placement.

Unsupported explicit selections raise ValueError; otherwise they warn and are omitted.

static unrestricted() → CompilerTarget

Create unrestricted native-operation support.

property kind: CompilerTarget

The native-operation support model.

property operations: list[CompilerTarget]

The explicit operations, if present.

static from_device(device: Device) → CompilerTarget

Snapshot a circuit-model QDMI device.

static from_qiskit(source: Target | BackendV2, *, operation_names: Iterable[str] | None = None, name: str | None = None) → CompilerTarget

Snapshot native operations and connectivity from Qiskit.

Parameters:
  • source – Qiskit Target or BackendV2. Physical import requires a known positive qubit count.

  • operation_names – Qiskit Target operation names to retain. By default, include every representable operation. Explicit selections must all be representable.

  • name – Override the target name. By default, use the backend name when source is a BackendV2; a Target produces an unnamed snapshot.

Returns:

An independent compiler target. Unrepresentable gates are omitted with warnings when operation_names is not set. Calibration and scheduling data are not included.

Raises:
  • TypeError – If source is neither a Target nor a BackendV2.

  • ValueError – If the selected operations or connectivity cannot be represented.

static from_device_id(device_id: str, **session_parameters: Unpack[QDMISessionParameters]) → CompilerTarget

Open a client-visible device and snapshot its compiler target.

property name: str | None

The target name, if available.

property duration_unit: CompilerTarget | None

The target timing unit, if available.

property num_sites: int

The number of target sites.

property sites: list[CompilerTarget]

Detailed sites in compiler-vertex order.

property connectivity_kind: CompilerTarget

The target connectivity model.

property couplings: list[tuple[int, int]]

Canonical undirected couplings in target site IDs.

property native_operations_kind: CompilerTarget

The target native-operation support model.

property operations: list[CompilerTarget]

Operation capabilities in reported order.

property supported_gates: list[CompilerTarget]

Recognized native gates supported by the target.

property synthesis_basis: CompilerTarget | None

A target-wide single-qubit basis with an optional entangler, or None when no single-qubit basis is usable.

supports_operation(name: str, arity: int, num_parameters: int | None = None, sites: Sequence[int] | None = None, *, parameters: Sequence[float | None] = ()) → bool

Check whether the target supports an operation.

Parameters:
  • name – Operation name. Recognized aliases are normalized.

  • arity – Number of qubits used by the operation.

  • num_parameters – Number of real-valued parameters. None accepts any count.

  • sites – Ordered target site IDs. None checks support on any placement.

  • parameters – Known parameter values. Omitted or None values require unrestricted support.

class TargetEnvironment(target: CompilerTarget, payload_specification: PayloadSpecification)

A compiler target and its selected payload specification.

property target: CompilerTarget

The compiler target.

property payload_specification: PayloadSpecification

The selected payload specification.

class Program

Base class for a typed MLIR compiler program.

Programs own their MLIR module. Conversions can consume a program; use is_valid to check whether it can still be used.

property is_valid: bool

Whether this program still owns its module.

operation_counts() → dict[str, int]

Count every operation by its full MLIR name.

Includes the root module, helper functions, modifier bodies, terminators, and nested modules.

property ir: str

The textual MLIR representation of this program.

class MappingOptions(*, trials: int | None = None, iterations: int = 1, lookahead: int = 20, search_memory_limit: int = 268435456)

Native mapping controls.

property trials: int | None

Positive trial count; None uses the available logical CPU count.

property iterations: int

Forward/backward refinement rounds; zero scores each start directly.

property lookahead: int

Additional two-qubit gates considered during routing; zero disables lookahead.

property search_memory_limit: int

Estimated node and layout bytes per routing search, per concurrent trial.

Zero disables node expansion. Container overhead, caches, and IR are extra.

class CompilationOptions(*, seed: int | None = None, enable_timing: bool = False, enable_statistics: bool = False, mapping: MappingOptions = ...)

Shared compiler controls.

An explicit seed overrides all compiler randomness; None preserves pass defaults and custom pipeline seeds.

property seed: int | None
property enable_timing: bool
property enable_statistics: bool
property mapping: MappingOptions
class QuantumProgramInfo

Quantum resources and static IR statistics.

Use QCProgram.inspect() or QCOProgram.inspect() to collect a snapshot.

property num_qubits: int | None

Declared quantum capacity.

Counts allocated qubits or distinct static site IDs. None means the width is unknown. Resource inspection includes helper functions and excludes nested modules; it describes declared capacity rather than peak live width.

property static_qubits: list[int]

Sorted distinct physical site IDs.

Includes declarations in helper functions and excludes nested modules.

property has_control_flow: bool

Whether the module contains control flow.

Includes branches and region-control operations in helper functions, but excludes nested modules.

property num_gates: int

Static entry-point gate count.

See QCProgram.num_gates().

property num_single_qubit_gates: int

Static single-qubit gate count.

See QCProgram.num_single_qubit_gates().

property num_two_qubit_gates: int

Static two-qubit gate count.

See QCProgram.num_two_qubit_gates().

property gate_counts: dict[str, int]

Entry-point gate histogram.

See QCProgram.gate_counts().

property control_flow_counts: dict[str, int]

Entry-point control-flow histogram.

See QCProgram.control_flow_counts().

property operation_counts: dict[str, int]

Full module operation histogram.

See Program.operation_counts().

class QCProgram

Bases: Program

A compiler program in the QC dialect.

QC programs use reference semantics and represent frontend quantum programs before conversion to QCO.

static from_mlir_str(source: str) → QCProgram

Parse a QC MLIR source string.

static from_mlir_file(path: str | PathLike) → QCProgram

Parse QC MLIR from a file.

static from_openqasm_str(source: str) → QCProgram

Translate supported OpenQASM to QC MLIR.

Accepts versionless input and versions 2.0, 3.0, and 3.1.

static from_openqasm_file(path: str | PathLike) → QCProgram

Translate a supported OpenQASM file to QC MLIR.

Accepts versionless input and versions 2.0, 3.0, and 3.1.

static from_qiskit(circuit: QuantumCircuit) → QCProgram

Translate a Qiskit {py:class}`~qiskit.circuit.QuantumCircuit` to QC MLIR.

Parameters:

circuit – Circuit to import. A complete transpiler layout is retained as metadata.

copy() → QCProgram

Return an independent copy of this program.

cleanup() → None

Run the standard QC cleanup pipeline in place.

normalize_global_phases() → None

Normalize scoped global phases in place.

to_openqasm3() → OpenQASMProgram

Clean up and emit this QC program as OpenQASM 3 without QCO optimization.

to_qiskit(*, target: CompilerTarget | None = None) → QuantumCircuit

Translate this QC program to a Qiskit {py:class}`~qiskit.circuit.QuantumCircuit` without consuming it.

The exporter restores attached layout metadata when it is compatible with the selected target.

Parameters:

target – Map static site IDs to qubit indices in target site order. All qubits must be static sites of the target. Select applicable standard gate names without checking device execution support. None applies no target site mapping.

to_qco(*, copy: bool = False) → QCOProgram

Convert this program to QCO.

Set copy=True to preserve it.

to_qir(profile: QIRProfile, *, copy: bool = False) → QIRProgram

Lower this program to QIR for the requested profile.

Set copy=True to preserve it.

inspect() → QuantumProgramInfo

Inspect quantum resources and static IR statistics.

Returns a QuantumProgramInfo snapshot with gate, control-flow, and full operation counts.

num_gates() → int

Return the static gate count of the entry-point IR.

Unitary operations, measurements, and resets each count once. Barriers are excluded. Modifiers and calls count atomically. Gates in every control-flow region count once, regardless of runtime paths or loop iterations.

num_single_qubit_gates() → int

Count gates acting on exactly one qubit.

Uses the counting rules of num_gates(), including measurements and resets.

num_two_qubit_gates() → int

Count gates acting on exactly two qubits.

Uses the counting rules of num_gates().

gate_counts() → dict[str, int]

Count entry-point gates by name.

Uses the counting rules of num_gates(). Controls on a single primitive gate add a c per control: cx, ccx. Other single-gate modifiers use inv(h), pow(rx), or ctrl(inv(x)); multiple controls use ctrl(2,inv(x)). Parameters do not split buckets. Composite bodies or unused modifier targets retain ctrl, inv, or pow. Calls use the callee name; explicit phases use gphase.

control_flow_counts() → dict[str, int]

Count entry-point control-flow operations.

Keys are full MLIR names such as scf.for and qco.if. Every region is visited once, without expanding calls. Region terminators such as scf.yield are excluded.

property parameters: list[str]

Named f64 entry-point inputs in function argument order.

bind_parameters(values: Mapping[str, float]) → None

Bind named f64 parameters in place without folding expressions.

Partial binding preserves unbound parameters and their source identities. Unknown names, non-finite values, and references to the entry point raise ValueError without changing the program. Call copy() first to preserve the input, and cleanup() afterwards if constant folding is needed.

class QCOProgram

Bases: Program

A compiler program in the QCO dialect.

QCO programs use value semantics and expose optimization and transformation operations.

static from_mlir_str(source: str) → QCOProgram

Parse a QCO MLIR source string.

static from_mlir_file(path: str | PathLike) → QCOProgram

Parse QCO MLIR from a file.

copy() → QCOProgram

Return an independent copy of this program.

cleanup() → None

Run the standard QCO cleanup pipeline in place.

normalize_global_phases() → None

Normalize scoped global phases in place.

run_pass_pipeline(pipeline: str, *, options: CompilationOptions = ...) → None

Run a textual MLIR pass pipeline in place.

merge_single_qubit_rotation_gates() → None

Merge compatible consecutive single-qubit rotation gates.

fuse_single_qubit_unitary_runs(*, basis: str = 'zyz') → None

Fuse single-qubit unitary runs into the chosen decomposition basis.

unroll_quantum_loops(*, unroll_factor: int = -1) → None

Unroll quantum loops, optionally using a maximum unroll factor.

lift_hadamards() → None

Move Hadamard gates through compatible operations.

reuse_qubits() → None

Reuse independent single-qubit allocations.

run_qubit_reuse_pipeline() → None

Prepare the program for qubit reuse and reuse eligible qubits.

decompose_multi_controlled(*, min_qubits: int = 3) → None

Decompose gates that act on at least min_qubits qubits.

Supports controlled X/Y/Z/SWAP and RX/RY/RZ gates, qco.rccx, and constant-angle phase gates. min_qubits must be at least 3; default 3 means wider than two-qubit.

compile_for_target(target_environment: TargetEnvironment, *, options: CompilationOptions = ...) → None

Compile for the target and attach layout metadata when possible.

Reject existing layout metadata. Do not rely on program contents if compilation fails. Failures raise RuntimeError with MLIR diagnostics.

synthesize_for_target(target_environment: TargetEnvironment, *, options: CompilationOptions = ...) → None

Synthesize native operations without routing.

Dynamic qubits require all-to-all connectivity and receive layout metadata when possible. Static qubits keep their device site IDs and must fit the target topology. Do not rely on the program contents if synthesis fails. Failures raise RuntimeError with the emitted MLIR diagnostics.

to_qiskit(*, target: CompilerTarget | None = None) → QuantumCircuit

Export a Qiskit circuit without consuming or modifying this program.

The exporter restores attached layout metadata when it is compatible with the selected target.

Parameters:

target – Map static site IDs to qubit indices in target site order. All qubits must be static sites of the target. Select applicable standard gate names without checking device execution support. None applies no target site mapping.

to_qc(*, copy: bool = False) → QCProgram

Convert this program to QC.

Set copy=True to preserve it.

to_jeff(*, copy: bool = False) → JeffProgram

Convert this program to jeff MLIR.

Set copy=True to preserve it.

inspect() → QuantumProgramInfo

Inspect quantum resources and static IR statistics.

Returns a QuantumProgramInfo snapshot with gate, control-flow, and full operation counts.

num_gates() → int

Return the static gate count of the entry-point IR.

Unitary operations, measurements, and resets each count once. Barriers are excluded. Modifiers and calls count atomically. Gates in every control-flow region count once, regardless of runtime paths or loop iterations.

num_single_qubit_gates() → int

Count gates acting on exactly one qubit.

Uses the counting rules of num_gates(), including measurements and resets.

num_two_qubit_gates() → int

Count gates acting on exactly two qubits.

Uses the counting rules of num_gates().

gate_counts() → dict[str, int]

Count entry-point gates by name.

Uses the counting rules of num_gates(). Controls on a single primitive gate add a c per control: cx, ccx. Other single-gate modifiers use inv(h), pow(rx), or ctrl(inv(x)); multiple controls use ctrl(2,inv(x)). Parameters do not split buckets. Composite bodies or unused modifier targets retain ctrl, inv, or pow. Calls use the callee name; explicit phases use gphase.

control_flow_counts() → dict[str, int]

Count entry-point control-flow operations.

Keys are full MLIR names such as scf.for and qco.if. Every region is visited once, without expanding calls. Region terminators such as scf.yield are excluded.

property parameters: list[str]

Named f64 entry-point inputs in function argument order.

bind_parameters(values: Mapping[str, float]) → None

Bind named f64 parameters in place without folding expressions.

Partial binding preserves unbound parameters and their source identities. Unknown names, non-finite values, and references to the entry point raise ValueError without changing the program. Call copy() first to preserve the input, and cleanup() afterwards if constant folding is needed.

build_functionality(dd_package: DDPackage) → MatrixDD

Build a matrix DD for a static unitary QCO program.

Parameters:

dd_package – DD package with enough qubits for the program.

Returns:

Matrix DD of the program functionality.

Raises:

ValueError – When the program is unsupported for functionality construction.

simulate(initial_state: VectorDD, dd_package: DDPackage, seed: int = 0) → VectorDD

Simulate a QCO program on a DD state.

Parameters:
  • initial_state – Input state DD that spans at least the program’s qubits and has a live reference in dd_package. Higher wires are preserved. A valid input reference is consumed.

  • dd_package – DD package with enough qubits for the program.

  • seed – RNG seed. 0 (default) selects nondeterministic seeding. Any other value produces reproducible measurement and reset results.

Returns:

Output state DD.

Raises:

ValueError – When initial_state has no live reference in dd_package, has too few qubits, or the program is unsupported for simulation.

sample(shots: int = 1024, seed: int = 0) → dict[str, int]

Sample the declared outputs of a QCO program.

Parameters:
  • shots – Number of shots (default 1024).

  • seed – RNG seed. 0 (default) selects nondeterministic seeding. Any other value produces reproducible results.

Returns:

Histogram keys use conventional count-string order. The last returned register comes first, and each register is MSB-first. If no CBit result exists, final measureAll bitstrings are used instead.

Raises:

ValueError – When the program is unsupported for sampling.

class JeffProgram

Bases: Program

A serializable compiler program in the jeff dialect.

jeff programs can be stored as bytes or files and converted back to QCO for further compilation.

static from_segments(segments: Sequence[bytes | bytearray | memoryview | ndarray]) → JeffProgram

Deserialize a jeff program from Cap’n Proto segments.

Each segment must be a contiguous one-dimensional byte buffer whose size is a multiple of eight. Keep the buffers unchanged until this call returns. Aligned buffers are borrowed; unaligned buffers are copied into aligned storage. The returned program does not retain the buffers.

static from_bytes(data: bytes) → JeffProgram

Deserialize a jeff program from bytes.

static from_file(path: str | PathLike) → JeffProgram

Read a jeff program from a file.

copy() → JeffProgram

Return an independent copy of this program.

cleanup() → None

Run the standard jeff cleanup pipeline in place.

to_segment_views() → list[memoryview]

Serialize this program into read-only Cap’n Proto segment views.

The views keep their message storage alive independently of this program. No segment data is copied or flattened.

to_bytes() → bytes

Serialize this program to its jeff byte representation.

write(path: str | PathLike) → None

Write this program to a jeff file.

to_qco(*, copy: bool = False) → QCOProgram

Convert this program to QCO.

Set copy=True to preserve it.

class OpenQASMProgram

An immutable compiler program containing OpenQASM 3 source.

property source: str

The emitted OpenQASM 3 source.

write(path: str | PathLike) → None

Write the emitted source to a file.

class QIRProgram

Bases: Program

A compiler program lowered to QIR.

QIR programs retain their target profile and can be emitted as LLVM IR or LLVM bitcode.

copy() → QIRProgram

Return an independent copy of this program.

cleanup() → None

Run the standard QIR cleanup pipeline in place.

property profile: QIRProfile

The QIR target profile used to produce this program.

property llvm_ir: str

The program as textual LLVM IR.

to_bitcode() → bytes

Serialize this program as LLVM bitcode.

write_bitcode(path: str | PathLike) → None

Write this program as LLVM bitcode.

build_functionality(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram) → Annotated[numpy.typing.NDArray[numpy.complex128], {'shape': (None, None)}]

Build the full unitary matrix of a supported compiler input.

The DD package is managed internally. The matrix is materialized directly into the returned NumPy array without an additional copy. The full matrix grows exponentially, and the caller is responsible for requesting a result that fits in memory.

Raises:
  • MemoryError – When the dense matrix does not fit in memory.

  • ValueError – When the program is unsupported or the matrix dimensions exceed addressable memory.

simulate(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram) → Annotated[numpy.typing.NDArray[numpy.complex128], {'shape': (None, )}]

Simulate a closed compiler input from the all-zero state.

The DD package is managed internally. Terminal measurements that only assemble returned classical registers do not collapse the state. Mid-circuit measurement feedback and resets are unsupported; use {py:meth}`QCOProgram.simulate` with an explicit DD package for those workflows or for a custom initial state.

Parameters:

program – Compiler input to lower directly to QCO.

Returns:

Full statevector, materialized directly into the returned NumPy array.

Raises:
  • MemoryError – When the dense statevector does not fit in memory.

  • ValueError – When the program is not closed, is unsupported for statevector simulation, or the statevector dimensions exceed addressable memory.

sample(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, shots: int = 1024, seed: int = 0) → dict[str, int]

Sample a supported input after translating or converting it to QCO.

An existing QCO program is used without copying. See {py:meth}`QCOProgram.sample` for the shot, seed, histogram, and error contracts.

compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, output: Literal[OutputFormat, OutputFormat] = ..., inplace: bool = False, qco_pipeline: str = 'mqt-qco-default', options: CompilationOptions = ...) → QCProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, output: Literal[OutputFormat, OutputFormat], inplace: bool = False, qco_pipeline: str = 'mqt-qco-default', options: CompilationOptions = ...) → QCOProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, output: Literal[OutputFormat], inplace: bool = False, qco_pipeline: str = 'mqt-qco-default', options: CompilationOptions = ...) → OpenQASMProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, output: Literal[OutputFormat], inplace: bool = False, qco_pipeline: str = 'mqt-qco-default', options: CompilationOptions = ...) → JeffProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, output: Literal[OutputFormat, OutputFormat], inplace: bool = False, qco_pipeline: str = 'mqt-qco-default', options: CompilationOptions = ...) → QIRProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, output: OutputFormat, inplace: bool = False, qco_pipeline: str = 'mqt-qco-default', options: CompilationOptions = ...) → QCProgram | QCOProgram | OpenQASMProgram | JeffProgram | QIRProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, target: str | Device, program_format: ProgramFormat | None = None, inplace: bool = False, options: CompilationOptions = ...) → CompiledProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, target: CompilerTarget, program_format: ProgramFormat, inplace: bool = False, options: CompilationOptions = ...) → CompiledProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, target: CompilerTarget, output: Literal[OutputFormat], inplace: bool = False, options: CompilationOptions = ...) → OpenQASMProgram
compile_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram, *, target: CompilerTarget, output: Literal[OutputFormat, OutputFormat], inplace: bool = False, options: CompilationOptions = ...) → QIRProgram
class CompiledProgram

A compiled program ready for QDMI submission.

property program_format: ProgramFormat

The exact QDMI program format.

property payload: str | bytes

The serialized program.

property target: CompilerTarget

The hardware snapshot used for compilation.

property payload_specification: PayloadSpecification

The payload format and capabilities used for compilation.

submit_program(program: str | PathLike[str] | QuantumCircuit | QCProgram | QCOProgram | JeffProgram | OpenQASMProgram | CompiledProgram, *, target: str | Device, num_shots: int = 1024, program_format: ProgramFormat | None = None, custom1: str | bool | float | bytes | None = None, custom2: str | bool | float | bytes | None = None, custom3: str | bool | float | bytes | None = None, custom4: str | bool | float | bytes | None = None, custom5: str | bool | float | bytes | None = None, options: CompilationOptions | None = None) → Job

Compile source or submit a compiled program to a device.

target accepts a registered device ID or an open device.