DataBindingStage

class DataBindingStage(data_params, loss_reduction, loss_constant=0.0, sample_loss=None)[source]

Bases: BundleStage

Bind a classical feature batch into a parametric circuit.

expand() creates one variant per row of env.feature_batch, binding data_params while leaving weight parameters symbolic. It uses QASM templates unless a downstream stage requires concrete DAG bodies. reduce() collapses the resulting data-sample axis with loss_reduction, optionally applying a supervised sample_loss first.

Parameters:

Attributes Summary

axis_name

Axis name introduced by this stage.

handles_measurement

Whether this stage sets up measurement circuits and result format.

Methods Summary

dry_expand(batch, env)

Dry path: share the incoming parametric DAG across all sample variants.

expand(batch, env)

Transform keyed MetaCircuit batch and return expansion lineage plus token.

introspect(batch, env, token)

Return stage-specific metadata for dry-run reporting.

reduce(results, env, token)

Identity by default; override if this stage reduces results.

validate(before, after)

Use the template path unless a downstream stage consumes DAG bodies.

Attributes Documentation

axis_name
handles_measurement

Methods Documentation

dry_expand(batch, env)[source]

Dry path: share the incoming parametric DAG across all sample variants. Per-sample data substitution is skipped — dry-run only needs correct circuit counts and depth/width stats, both of which are invariant under data binding.

Return type:

StageOutput[dict[tuple[tuple[str, Hashable], ...], MetaCircuit]]

expand(batch, env)[source]

Transform keyed MetaCircuit batch and return expansion lineage plus token.

Return type:

StageOutput[dict[tuple[tuple[str, Hashable], ...], MetaCircuit]]

introspect(batch, env, token)[source]

Return stage-specific metadata for dry-run reporting.

Override in subclasses to provide richer introspection data. Called by the dry-run tool after expand with the post-expand batch, the pipeline env, and the stage’s token.

Return type:

dict[str, Any]

reduce(results, env, token)[source]

Identity by default; override if this stage reduces results.

Return type:

dict[Any, Any]

validate(before, after)[source]

Use the template path unless a downstream stage consumes DAG bodies.

Return type:

None