Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

qamomile.quration

Quration target integration through its PyQret Python frontend.

Quration is the user-facing FTQC resource-estimation toolchain; PyQret is its Python construction API. The public transpiler is therefore named QurationTranspiler while the target-native materializer is explicitly named PyQretMaterializer.

This backend depends only on qamomile.circuit and optional pyqret. It consumes backend-neutral CircuitProgram artifacts and never reaches back into Qamomile’s semantic IR.

Overview

ClassDescription
PyQretMaterializerConvert a verified circuit program to pyqret.frontend.Circuit.
QurationExecutorExecute PyQret circuits with its full-quantum simulator.
QurationResourceResultPackage Quration FTQC compilation and resource information.
QurationTranspilerTranspile Qamomile programs to Quration through PyQret.

Classes

PyQretMaterializer [source]

class PyQretMaterializer

Convert a verified circuit program to pyqret.frontend.Circuit.

Parameters:

NameTypeDescription
rotation_precisionfloatAbsolute synthesis precision forwarded to PyQret rotation operations. Defaults to 1e-10.

Constructor

def __init__(self, rotation_precision: float = 1e-10) -> None

Initialize the PyQret materializer.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision. Defaults to 1e-10.

Raises:

Attributes

Methods

materialize
def materialize(
    self,
    program: CircuitProgram,
    parameter_names: tuple[str, ...] = (),
) -> MaterializedCircuit[Any]

Materialize one circuit program through PyQret’s definition context.

Parameters:

NameTypeDescription
programCircuitProgramVerified backend-neutral circuit program.
parameter_namestuple[str, ...]Public runtime-parameter ABI. Quration currently requires this to be empty. Defaults to an empty tuple.

Returns:

MaterializedCircuit[Any] — MaterializedCircuit[Any]: PyQret circuit without runtime parameter metadata.

Raises:


QurationExecutor [source]

class QurationExecutor(QuantumExecutor[Any])

Execute PyQret circuits with its full-quantum simulator.

Parameters:

NameTypeDescription
seedintBase simulator seed. Defaults to zero.

Constructor

def __init__(self, seed: int = 0) -> None

Initialize a deterministic-seed Quration executor.

Parameters:

NameTypeDescription
seedintBase simulator seed. Defaults to zero.

Attributes

Methods

estimate
def estimate(
    self,
    circuit: Any,
    hamiltonian: Any,
    params: Sequence[float] | None = None,
) -> float

Evaluate an observable against PyQret’s full state vector.

Parameters:

NameTypeDescription
circuitAnyState-preparation PyQret circuit.
hamiltonianAnyQamomile Hamiltonian observable.
paramsSequence[float] | NoneUnsupported runtime parameters. Defaults to None.

Returns:

float — Real expectation value.

Raises:

execute
def execute(self, circuit: Any, shots: int) -> dict[str, int]

Sample a PyQret circuit and return big-endian bitstring counts.

Parameters:

NameTypeDescription
circuitAnypyqret.frontend.Circuit to execute.
shotsintPositive number of samples.

Returns:

dict[str, int] — dict[str, int]: Big-endian bitstring counts.

Raises:


QurationResourceResult [source]

class QurationResourceResult

Package Quration FTQC compilation and resource information.

Parameters:

NameTypeDescription
circuitAnyMaterialized and compiled PyQret circuit.
compilerAnyOwning pyqret.backend.Compiler. PyQret compile information borrows native state from this object.
compile_resultAnypyqret.backend.CompileResult containing pass timing and ordering.
compile_infoAnypyqret.backend.ScLsFixedV0CompileInfo resource summary.

Constructor

def __init__(
    self,
    circuit: Any,
    compiler: Any,
    compile_result: Any,
    compile_info: Any,
) -> None

Attributes


QurationTranspiler [source]

class QurationTranspiler(Transpiler[Any])

Transpile Qamomile programs to Quration through PyQret.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision forwarded to PyQret. Defaults to 1e-10.

Constructor

def __init__(self, rotation_precision: float = 1e-10) -> None

Initialize the Quration transpiler.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision. Defaults to 1e-10.

Raises:

Attributes

Methods

compile_resources
def compile_resources(
    self,
    kernel: Any,
    option: Any,
    bindings: dict[str, Any] | None = None,
) -> QurationResourceResult

Compile a qkernel to a configured Quration FTQC target.

Parameters:

NameTypeDescription
kernelAnyQKernel or qkernel-like entrypoint.
optionAnypyqret.backend.CompileOption including the desired FTQC target configuration.
bindingsdict[str, Any] | NoneCompile-time bindings. Defaults to None.

Returns:

QurationResourceResult — Materialized circuit, compile pass result, and resource information.

Raises:

executor
def executor(self, **kwargs: Any = {}) -> QurationExecutor

Create a PyQret full-quantum simulator executor.

Parameters:

NameTypeDescription
**kwargsAnyReserved executor options. Unknown values are rejected except for integer seed.

Returns:

QurationExecutor — Quration simulator executor.

Raises:


qamomile.quration.materializer

Materialize backend-neutral circuit IR through the PyQret builder API.

Overview

FunctionDescription
evaluate_scalarEvaluate a concrete circuit scalar expression for PyQret.
ClassDescription
EmitErrorError during backend code emission.
GateKindClassification of gates for emission.
PyQretMaterializerConvert a verified circuit program to pyqret.frontend.Circuit.

Functions

evaluate_scalar [source]

def evaluate_scalar(
    expression: ScalarExpr,
    loop_values: dict[str, int] | None = None,
) -> bool | int | float

Evaluate a concrete circuit scalar expression for PyQret.

PyQret rotation constructors currently require concrete Python floats. Runtime parameters and measured-bit expressions therefore remain illegal at this materialization boundary.

Parameters:

NameTypeDescription
expressionScalarExprTarget-neutral expression to evaluate.
loop_valuesdict[str, int] | NoneActive structured-loop induction values keyed by loop-variable name. Defaults to an empty mapping.

Returns:

bool | int | float — bool | int | float: Concrete scalar value.

Raises:

Classes

EmitError [source]

class EmitError(QamomileCompileError)

Error during backend code emission.

Constructor
def __init__(self, message: str, operation: str | None = None)

Initialize a backend emission diagnosis.

Parameters:

NameTypeDescription
messagestrHuman-readable emission failure.
operationstr | NoneRelated operation description. Defaults to None.
Attributes

GateKind [source]

class GateKind(Enum)

Classification of gates for emission.

Attributes

PyQretMaterializer [source]

class PyQretMaterializer

Convert a verified circuit program to pyqret.frontend.Circuit.

Parameters:

NameTypeDescription
rotation_precisionfloatAbsolute synthesis precision forwarded to PyQret rotation operations. Defaults to 1e-10.
Constructor
def __init__(self, rotation_precision: float = 1e-10) -> None

Initialize the PyQret materializer.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision. Defaults to 1e-10.

Raises:

Attributes
Methods
materialize
def materialize(
    self,
    program: CircuitProgram,
    parameter_names: tuple[str, ...] = (),
) -> MaterializedCircuit[Any]

Materialize one circuit program through PyQret’s definition context.

Parameters:

NameTypeDescription
programCircuitProgramVerified backend-neutral circuit program.
parameter_namestuple[str, ...]Public runtime-parameter ABI. Quration currently requires this to be empty. Defaults to an empty tuple.

Returns:

MaterializedCircuit[Any] — MaterializedCircuit[Any]: PyQret circuit without runtime parameter metadata.

Raises:


qamomile.quration.transpiler

Quration transpiler, simulator executor, and FTQC resource compilation.

Overview

ClassDescription
EmitPassBase class for backend-specific emission passes.
PyQretMaterializerConvert a verified circuit program to pyqret.frontend.Circuit.
QuantumExecutorAbstract base class for quantum backend execution.
QurationExecutorExecute PyQret circuits with its full-quantum simulator.
QurationResourceResultPackage Quration FTQC compilation and resource information.
QurationTranspilerTranspile Qamomile programs to Quration through PyQret.
SegmentationPassSegment a block into a strategy-specific executable program plan.
TranspilerBase class for backend-specific transpilers.

Classes

EmitPass [source]

class EmitPass(Pass[ProgramPlan, ExecutableProgram[T]], Generic[T])

Base class for backend-specific emission passes.

Subclasses implement _emit_quantum_segment() to generate backend-specific quantum circuits.

Input: ProgramPlan Output: ExecutableProgram with compiled segments

Constructor
def __init__(
    self,
    bindings: dict[str, Any] | None = None,
    parameters: list[str] | None = None,
)

Initialize with optional parameter bindings.

Parameters:

NameTypeDescription
bindingsdict[str, Any] | NoneValues to bind parameters to. If not provided, parameters must be bound at execution time.
parameterslist[str] | NoneList of parameter names to preserve as backend parameters.

Raises:

Attributes
Methods
run
def run(self, input: ProgramPlan) -> ExecutableProgram[T]

Emit backend code from a program plan.

Parameters:

NameTypeDescription
inputProgramPlanSegmented plan whose quantum and classical steps should be compiled.

Returns:

ExecutableProgram[T] — ExecutableProgram[T]: Executable program containing all compiled segments and the public output contract.


PyQretMaterializer [source]

class PyQretMaterializer

Convert a verified circuit program to pyqret.frontend.Circuit.

Parameters:

NameTypeDescription
rotation_precisionfloatAbsolute synthesis precision forwarded to PyQret rotation operations. Defaults to 1e-10.
Constructor
def __init__(self, rotation_precision: float = 1e-10) -> None

Initialize the PyQret materializer.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision. Defaults to 1e-10.

Raises:

Attributes
Methods
materialize
def materialize(
    self,
    program: CircuitProgram,
    parameter_names: tuple[str, ...] = (),
) -> MaterializedCircuit[Any]

Materialize one circuit program through PyQret’s definition context.

Parameters:

NameTypeDescription
programCircuitProgramVerified backend-neutral circuit program.
parameter_namestuple[str, ...]Public runtime-parameter ABI. Quration currently requires this to be empty. Defaults to an empty tuple.

Returns:

MaterializedCircuit[Any] — MaterializedCircuit[Any]: PyQret circuit without runtime parameter metadata.

Raises:


QuantumExecutor [source]

class QuantumExecutor(ABC, Generic[T])

Abstract base class for quantum backend execution.

To implement a custom executor:

  1. execute() [Required] Execute circuit and return bitstring counts as dict[str, int]. Keys are bitstrings in big-endian format (e.g., “011” means q2=0, q1=1, q0=1).

  2. bind_parameters() [Optional] Bind parameter values to parametric circuits. Override if your executor supports parametric circuits (e.g., QAOA variational circuits). Use ParameterMetadata.to_binding_dict() for easy conversion.

  3. estimate() [Optional] Compute expectation values <psi|H|psi>. Override if your executor supports estimation primitives (e.g., Qiskit Estimator, QURI Parts).

Example (Minimal): class MyExecutor(QuantumExecutor[QuantumCircuit]): def init(self): from qiskit_aer import AerSimulator self.backend = AerSimulator()

    def execute(self, circuit, shots):
        from qiskit import transpile
        if circuit.num_clbits == 0:
            circuit = circuit.copy()
            circuit.measure_all()
        transpiled = transpile(circuit, self.backend)
        return self.backend.run(transpiled, shots=shots).result().get_counts()

Example (With Parameter Binding): def bind_parameters(self, circuit, bindings, metadata): # metadata.to_binding_dict() converts indexed names to backend params return circuit.assign_parameters(metadata.to_binding_dict(bindings))

Methods
bind_parameters
def bind_parameters(
    self,
    circuit: T,
    bindings: dict[str, Any],
    parameter_metadata: ParameterMetadata,
) -> T

Bind parameter values to the circuit.

Default implementation returns the circuit unchanged. Override for backends that support parametric circuits.

Parameters:

NameTypeDescription
circuitTThe parameterized circuit
bindingsdict[str, Any]Dict mapping parameter names (indexed format) to values. e.g., {“gammas[0]”: 0.1, “gammas[1]”: 0.2}
parameter_metadataParameterMetadataMetadata about circuit parameters

Returns:

T — New circuit with parameters bound

estimate
def estimate(
    self,
    circuit: T,
    hamiltonian: 'qm_o.Hamiltonian',
    params: Sequence[float] | None = None,
) -> float

Estimate the expectation value of a Hamiltonian.

This method computes <psi|H|psi> where psi is the quantum state prepared by the circuit and H is the Hamiltonian.

Backends can override this method to provide optimized implementations using their native estimator primitives.

Parameters:

NameTypeDescription
circuitTThe quantum circuit (state preparation ansatz)
hamiltonian'qm_o.Hamiltonian'The qamomile.observable.Hamiltonian to measure
paramsSequence[float] | NoneOptional parameter values for parametric circuits

Returns:

float — The estimated expectation value

Raises:

execute
def execute(self, circuit: T, shots: int) -> dict[str, int]

Execute the circuit and return bitstring counts.

Parameters:

NameTypeDescription
circuitTThe quantum circuit to execute
shotsintNumber of measurement shots

Returns:

dict[str, int] — Dictionary mapping bitstrings to counts. dict[str, int] — {“00”: 512, “11”: 512}


QurationExecutor [source]

class QurationExecutor(QuantumExecutor[Any])

Execute PyQret circuits with its full-quantum simulator.

Parameters:

NameTypeDescription
seedintBase simulator seed. Defaults to zero.
Constructor
def __init__(self, seed: int = 0) -> None

Initialize a deterministic-seed Quration executor.

Parameters:

NameTypeDescription
seedintBase simulator seed. Defaults to zero.
Attributes
Methods
estimate
def estimate(
    self,
    circuit: Any,
    hamiltonian: Any,
    params: Sequence[float] | None = None,
) -> float

Evaluate an observable against PyQret’s full state vector.

Parameters:

NameTypeDescription
circuitAnyState-preparation PyQret circuit.
hamiltonianAnyQamomile Hamiltonian observable.
paramsSequence[float] | NoneUnsupported runtime parameters. Defaults to None.

Returns:

float — Real expectation value.

Raises:

execute
def execute(self, circuit: Any, shots: int) -> dict[str, int]

Sample a PyQret circuit and return big-endian bitstring counts.

Parameters:

NameTypeDescription
circuitAnypyqret.frontend.Circuit to execute.
shotsintPositive number of samples.

Returns:

dict[str, int] — dict[str, int]: Big-endian bitstring counts.

Raises:


QurationResourceResult [source]

class QurationResourceResult

Package Quration FTQC compilation and resource information.

Parameters:

NameTypeDescription
circuitAnyMaterialized and compiled PyQret circuit.
compilerAnyOwning pyqret.backend.Compiler. PyQret compile information borrows native state from this object.
compile_resultAnypyqret.backend.CompileResult containing pass timing and ordering.
compile_infoAnypyqret.backend.ScLsFixedV0CompileInfo resource summary.
Constructor
def __init__(
    self,
    circuit: Any,
    compiler: Any,
    compile_result: Any,
    compile_info: Any,
) -> None
Attributes

QurationTranspiler [source]

class QurationTranspiler(Transpiler[Any])

Transpile Qamomile programs to Quration through PyQret.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision forwarded to PyQret. Defaults to 1e-10.
Constructor
def __init__(self, rotation_precision: float = 1e-10) -> None

Initialize the Quration transpiler.

Parameters:

NameTypeDescription
rotation_precisionfloatPositive rotation synthesis precision. Defaults to 1e-10.

Raises:

Attributes
Methods
compile_resources
def compile_resources(
    self,
    kernel: Any,
    option: Any,
    bindings: dict[str, Any] | None = None,
) -> QurationResourceResult

Compile a qkernel to a configured Quration FTQC target.

Parameters:

NameTypeDescription
kernelAnyQKernel or qkernel-like entrypoint.
optionAnypyqret.backend.CompileOption including the desired FTQC target configuration.
bindingsdict[str, Any] | NoneCompile-time bindings. Defaults to None.

Returns:

QurationResourceResult — Materialized circuit, compile pass result, and resource information.

Raises:

executor
def executor(self, **kwargs: Any = {}) -> QurationExecutor

Create a PyQret full-quantum simulator executor.

Parameters:

NameTypeDescription
**kwargsAnyReserved executor options. Unknown values are rejected except for integer seed.

Returns:

QurationExecutor — Quration simulator executor.

Raises:


SegmentationPass [source]

class SegmentationPass(Pass[Block, ProgramPlan])

Segment a block into a strategy-specific executable program plan.

This pass:

  1. Materializes return operations (syncs output_values from ReturnOperation)

  2. Splits the operation list into quantum and classical segments

  3. Builds a ProgramPlan via the configured segmentation strategy

Input: Block (typically ANALYZED or AFFINE) Output: ProgramPlan

Constructor
def __init__(self, strategy: SegmentationStrategy | None = None) -> None
Attributes
Methods
run
def run(self, input: Block) -> ProgramPlan

Lower and segment a block into a program plan.

Parameters:

NameTypeDescription
inputBlockBlock whose while contract and hybrid operations should be lowered before segmentation.

Returns:

ProgramPlan — Strategy-produced execution plan.

Raises:


Transpiler [source]

class Transpiler(ABC, Generic[T])

Base class for backend-specific transpilers.

Provides the full compilation pipeline from qkernel-like frontend objects to executable programs.

Example:

>>> from qamomile.circuit.transpiler import TranspilerConfig
>>> from qamomile.qiskit import QiskitTranspiler
>>> transpiler = QiskitTranspiler()
>>> executable = transpiler.transpile(kernel, bindings={"theta": 0.5})
>>> circuit = executable.get_first_circuit()
>>> config = TranspilerConfig.with_strategies({"qft": "approximate_k2"})
>>> transpiler.set_config(config)
Attributes
Methods
affine_validate
def affine_validate(self, block: Block) -> Block

Pass 1.5: Validate affine type semantics.

This is a safety net to catch affine type violations that may have bypassed frontend checks. Validates that quantum values are used at most once.

analyze
def analyze(self, block: Block) -> Block

Pass 2: Validate and analyze dependencies.

array_bounds_check
def array_bounds_check(self, block: Block) -> Block

Pass 1.85: Reject reachable accesses outside resolved array bounds.

Runs after :meth:partial_eval so binding-dependent view extents and indices are concrete where possible, and before declarative slice operations are stripped. Statically zero-trip loop bodies are skipped because their element accesses are unreachable.

Parameters:

NameTypeDescription
blockBlockPost-fold affine or hierarchical block to validate.

Returns:

Block — The input block unchanged after successful validation.

Raises:

classical_lowering
def classical_lowering(self, block: Block) -> Block

Pass 2.25: Lower measurement-derived classical ops.

Identifies CompOp / CondOp / NotOp / BinOp instances whose operand dataflow traces back to a measurement and rewrites them to RuntimeClassicalExpr. Compile-time-foldable and emit-time-foldable (loop-bound, parameter-bound) classical ops are left unchanged.

Runs after analyze so the measurement-taint analysis has the full dependency graph available, and before validate_symbolic_shapes / plan / emit so downstream passes can rely on the cleaner IR (in particular: future segmentation work can dispatch on RuntimeClassicalExpr type instead of the BitType-only heuristic).

constant_fold
def constant_fold(self, block: Block, bindings: dict[str, Any] | None = None) -> Block

Pass 1.5: Fold constant expressions.

Evaluates BinOp operations when all operands are constants or bound parameters. This prevents quantum segment splitting from parametric expressions like phase * 2.

emit
def emit(
    self,
    separated: ProgramPlan,
    bindings: dict[str, Any] | None = None,
    parameters: list[str] | None = None,
) -> ExecutableProgram[T]

Pass 4: Generate backend-specific code.

Parameters:

NameTypeDescription
separatedProgramPlanThe separated program to emit
bindingsdict[str, Any] | NoneParameter values to bind at compile time
parameterslist[str] | NoneParameter names to preserve as backend parameters

Raises:

executor
def executor(self, **kwargs: Any = {}) -> QuantumExecutor[T]

Create a quantum executor for this backend.

inline
def inline(self, block: Block) -> Block

Pass 1: Inline all inline-policy callable invocations.

lower_compile_time_ifs
def lower_compile_time_ifs(self, block: Block, bindings: dict[str, Any] | None = None) -> Block

Pass 1.75: Lower compile-time resolvable IfOperations.

Evaluates IfOperation conditions (including expression-derived conditions via CompOp/CondOp/NotOp) and replaces resolved ones with selected-branch operations. Merge outputs are substituted with selected-branch values throughout the block.

This prevents SegmentationPass from seeing classical-only compile-time IfOperations that would otherwise split quantum segments.

partial_eval
def partial_eval(self, block: Block, bindings: dict[str, Any] | None = None) -> Block

Pass 1.75: Fold constants and lower compile-time control flow.

plan
def plan(self, block: Block) -> ProgramPlan

Pass 3: Lower and split into a program plan.

Validates C→Q→C pattern with single quantum segment.

plan_circuit
def plan_circuit(
    self,
    prepared: PreparedModule,
    bindings: dict[str, Any] | None = None,
) -> ProgramPlan

Lower a prepared semantic module into the circuit execution model.

This is the destructive circuit-family path: inline-policy calls are flattened, compile-time structure is evaluated, affine and borrow invariants are checked, measurement-dependent classical expressions are classified, and the result is segmented into C-to-Q-to-C steps. Program-graph targets must compile :class:PreparedModule directly instead of invoking this method.

Parameters:

NameTypeDescription
preparedPreparedModuleHierarchical semantic program returned by :meth:prepare.
bindingsdict[str, Any] | NoneCompile-time bindings used for recursion unrolling and partial evaluation. Defaults to None.

Returns:

ProgramPlan — Circuit-family host-orchestrated execution plan.

Raises:

prepare
def prepare(
    self,
    kernel: QKernelLike,
    bindings: dict[str, Any] | None = None,
    parameters: list[str] | None = None,
) -> PreparedModule

Prepare a qkernel for target-specific planning and lowering.

This phase preserves callable boundaries. It performs tracing, entrypoint validation, configured substitutions, and parameter-shape resolution, then collects the reachable callable graph into a program-level semantic view.

Parameters:

NameTypeDescription
kernelQKernelLikeQKernel or qkernel-like frontend object to prepare as a top-level entrypoint.
bindingsdict[str, Any] | NoneCompile-time values used while tracing and resolving parameter shapes. Defaults to None.
parameterslist[str] | NoneArgument names preserved as runtime parameters. Defaults to None.

Returns:

PreparedModule — Hierarchical entrypoint, reachable callables, call graph, and public ABI.

Raises:

resolve_parameter_shapes
def resolve_parameter_shapes(self, block: Block, bindings: dict[str, Any] | None = None) -> Block

Pass 0.75: Resolve symbolic Vector parameter shape dims.

Qamomile circuits are compile-time fixed-structure. Parameter Vector[Float] / Vector[UInt] inputs carry symbolic {name}_dim{i} shape Values so frontend code like arr.shape[0] returns a usable handle. This pass looks at bindings and, for every parameter array that has a concrete binding, substitutes those symbolic dims with constants so that downstream loop-bound resolution sees fixed lengths.

Parameters without a concrete binding are left as-is; their symbolic dims are harmless as long as no compile-time structure decision depends on them (the library QAOA pattern).

set_config
def set_config(self, config: TranspilerConfig) -> None

Set the transpiler configuration.

Parameters:

NameTypeDescription
configTranspilerConfigTranspiler configuration to use
slice_borrow_check
def slice_borrow_check(self, block: Block) -> Block

Pass 1.9: Post-fold slice-view linearity checker.

Runs after :meth:partial_eval has resolved slice bounds to concrete values. Catches the slice-view linearity violations that the trace-time frontend check cannot detect on its own — specifically, slices whose bounds were symbolic at trace time (so the frontend bulk-borrow tracker had to skip them) and aliasing scenarios that only become visible once those bounds are folded to constants:

  1. A view whose newly-concrete coverage overlaps another live view of the same root parent.

  2. A view whose newly-concrete coverage hits a slot that was consumed by a destructive operation earlier in the block.

  3. Slice ownership changes that cannot be represented safely across control-flow boundaries.

Creating a direct element borrow (q[i]) emits no IR operation, so this pass cannot observe the borrow site itself. Later uses of that element do appear as operation operands and are checked for conflicts with live slice views. Trace-time validation in :func:qamomile.circuit.frontend.func_to_block._validate_returned_arrays covers unreturned direct-element borrows that have no observable operand use.

The pass is a pass-through for the IR — it only raises on violations and leaves the block unchanged on success.

Parameters:

NameTypeDescription
blockBlockPost-fold affine or hierarchical block to validate.

Returns:

Block — The input block unchanged after successful validation.

Raises:

strip_slice_ops
def strip_slice_ops(self, block: Block) -> Block

Pass 1.95: Remove SliceArrayOperation nodes from the block.

PartialEvaluationPass keeps these declarative ops through constant folding so :meth:slice_borrow_check can use them as view-declaration markers. Once the linearity check has run, segmentation and downstream passes expect a classical-op-free quantum stream — this pass performs that cleanup.

substitute
def substitute(self, block: Block) -> Block

Pass 0.5: Apply substitutions (optional).

This pass rewrites inline callable targets and sets strategy names on boxed InvokeOperations based on config.

Parameters:

NameTypeDescription
blockBlockBlock to transform

Returns:

Block — Block with substitutions applied

to_block
def to_block(
    self,
    kernel: QKernelLike,
    bindings: dict[str, Any] | None = None,
    parameters: list[str] | None = None,
) -> Block

Convert a qkernel-like frontend object to a Block.

Parameters:

NameTypeDescription
kernelQKernelLikeQKernel or qkernel-like frontend object to convert.
bindingsdict[str, Any] | NoneConcrete values to bind at trace time, including values used to resolve array shapes.
parameterslist[str] | NoneNames to keep as unbound runtime parameters.

Returns:

Block — Hierarchical block for the frontend object.

Raises:

Always uses kernel.build() so Python defaults, required arguments, runtime parameters, and array shapes follow one validated entry path.

to_circuit
def to_circuit(self, kernel: QKernelLike, bindings: dict[str, Any] | None = None) -> T

Compile and extract just the quantum circuit.

This is a convenience method for when you just want the backend circuit without the full executable.

Parameters:

NameTypeDescription
kernelQKernelLikeQKernel or qkernel-like frontend object to compile.
bindingsdict[str, Any] | NoneParameter values to bind.

Returns:

T — Backend-specific quantum circuit.

transpile
def transpile(
    self,
    kernel: QKernelLike,
    bindings: dict[str, Any] | None = None,
    parameters: list[str] | None = None,
) -> ExecutableProgram[T]

Full compilation pipeline from a qkernel-like object to executable.

Parameters:

NameTypeDescription
kernelQKernelLikeQKernel or qkernel-like frontend object to compile.
bindingsdict[str, Any] | NoneParameter values to bind (also resolves array shapes). Names in bindings and parameters must be disjoint — a name is either compile-time bound or runtime symbolic, never both.
parameterslist[str] | NoneParameter names to preserve as backend parameters. Scalars/arrays of float/int/UInt are supported, plus Dict[K, Float]: each constant-key subscript lookup (d[key]) becomes one backend parameter named "d[<key>]", and the execution-time binding bindings={"d": {...}} is decomposed per key onto those parameters. A Dict runtime parameter is recorded in Block.param_slots as a slot whose type is a DictType (compile-time-bound Dicts and Tuple arguments stay out of the slot manifest); its emitted per-key parameters are visible via ExecutableProgram.parameter_names.

Returns:

ExecutableProgram[T] — ExecutableProgram[T]: Executable wrapping the backend circuit and the parameter metadata needed to re-bind runtime parameters, ready for execution.

Raises:

Pipeline:

  1. prepare: Trace and validate the entrypoint, apply configured substitutions, resolve parameter shapes, and preserve the reachable callable graph.

  2. plan_circuit: Inline inline-policy calls, unroll recursion, validate affine and borrow rules, partially evaluate compile-time structure, analyze dependencies, and segment the program into the host-orchestrated C-to-Q-to-C model.

  3. lower: Convert each quantum segment to immutable, backend-neutral CircuitProgram IR.

  4. legalize: Select native intrinsics and Pauli-evolution realizations from target capabilities and compilation policy.

  5. verify: Prove circuit structure and target legality before constructing backend objects.

  6. materialize: Convert the legalized circuit IR to backend-native artifacts and preserve the executable ABI.

unroll_recursion
def unroll_recursion(self, block: Block, bindings: dict[str, Any] | None = None) -> Block

Fixed-point loop of inline ↔ partial_eval for self-recursive kernels.

Each iteration unrolls one layer of self-referential inline callable invocation and then folds the base-case IfOperation via partial_eval. Terminates when no inline callable invocation remains (success), when every residual call is trapped inside an operation-owned block whose recursive callable contract is unsupported (control / inverse / select over a recursive kernel — raises a targeted error, see below), or when MAX_UNROLL_DEPTH is reached (genuinely non-terminating top-level recursion — raises).

Parameters:

NameTypeDescription
blockBlockThe block to unroll. May be HIERARCHICAL (still containing self-referential callable invocations) or already AFFINE (returned unchanged).
bindingsdict[str, Any] | NoneCompile-time bindings used by partial_eval to fold the base-case condition. Defaults to None, meaning no bindings are applied.

Returns:

Block — The fully unrolled, AFFINE block once no inline callable invocation remains. Returned unchanged when the input already has no calls.

Raises:

validate_symbolic_shapes
def validate_symbolic_shapes(self, block: Block) -> Block

Pass 2.5: Reject unresolvable ForOperation loop bounds.

Runs after analyze so dependency info is complete. Raises QamomileCompileError with an actionable message when a gamma_dim0-style symbolic Value reaches a ForOperation bound without being folded to a constant by ParameterShapeResolutionPass, or when a loop bound depends (directly or through classical arithmetic) on a runtime parameter — loop bounds are compile-time structure and must be provided via bindings, not parameters.

Parameters:

NameTypeDescription
blockBlockThe analyzed block to validate.

Returns:

Blockblock, unchanged, when validation succeeds.

Raises: