PipelineEnv¶
- class PipelineEnv(backend, param_sets=(), feature_batch=None, labels=None, artifacts=<factory>, reporter=None, cancellation_event=None, rng=None, evaluation_counter=0, base_seed=None, shots_override=None, collect_variance=False, axes_to_preserve=())[source]¶
Bases:
objectPer-run context for the circuit pipeline.
The client passes the backend and any stage-specific data when constructing the env for a pipeline run.
Attributes Summary
Mutable output dict populated during execution (e.g.
circuit_count).Stage axes that should not be reduced away.
Backend used to run circuits (e.g. simulator or cloud service).
Fixed per-program entropy for unseeded stochastic stages.
Threading event signalling cancellation (set by ProgramEnsemble).
When
True, measurement stages also estimate the shot-noise variance of each cost value from raw counts and write it toartifacts['cost_variance']({param_set_idx: variance}).The shot budget to use for this run.
Index of the current optimizer evaluation, bumped once per cost call.
Classical feature batch for the data axis, shape
(n_samples, n_data).Optional per-sample supervised targets, shape
(n_samples,), aligned withfeature_batch.Parameter sets for binding — strictly 2D (list-of-lists or 2D ndarray).
Progress reporter for async polling feedback.
Random generator for stochastic stage decisions (e.g.
weighted_randomshot allocation).Per-evaluation shot budget overriding
backend.shotswithout mutating the immutable backend.Attributes Documentation
- artifacts: dict = <dataclasses._MISSING_TYPE object>¶
Mutable output dict populated during execution (e.g.
circuit_count).
- axes_to_preserve: tuple[str, ...] = ()¶
Stage axes that should not be reduced away. Advanced callers use this when they need branch-level results after normal downstream reductions.
- backend: CircuitRunner = <dataclasses._MISSING_TYPE object>¶
Backend used to run circuits (e.g. simulator or cloud service).
- base_seed: int | None = None¶
Fixed per-program entropy for unseeded stochastic stages. Combined with
evaluation_counterit gives a stable-within-evaluation seed even when no explicit strategy seed is set, so the cost and metric pipelines still agree.
- cancellation_event: Event | None = None¶
Threading event signalling cancellation (set by ProgramEnsemble).
- collect_variance: bool = False¶
When
True, measurement stages also estimate the shot-noise variance of each cost value from raw counts and write it toartifacts['cost_variance']({param_set_idx: variance}). Off by default — the estimate costs nothing extra in circuits but adds a small classical post-processing pass.
- effective_shots¶
The shot budget to use for this run.
Returns
shots_overridewhen set, otherwise the backend’s configuredshots.
- evaluation_counter: int = 0¶
Index of the current optimizer evaluation, bumped once per cost call. Stochastic spec stages (e.g. QDrift) seed deterministically from it so the cost and metric pipelines sample the same batch within one evaluation.
- feature_batch: ndarray[tuple[Any, ...], dtype[floating]] | None = None¶
Classical feature batch for the data axis, shape
(n_samples, n_data). Read byDataBindingStage;Noneotherwise.
- labels: ndarray[tuple[Any, ...], dtype[floating]] | None = None¶
Optional per-sample supervised targets, shape
(n_samples,), aligned withfeature_batch. Read byDataBindingStage.
- param_sets: Sequence[Sequence[float]] | ndarray[tuple[Any, ...], dtype[floating]] = ()¶
Parameter sets for binding — strictly 2D (list-of-lists or 2D ndarray).
- reporter: ProgressReporter | None = None¶
Progress reporter for async polling feedback.
- rng: Generator | None = None¶
Random generator for stochastic stage decisions (e.g.
weighted_randomshot allocation). WhenNone, stages that need randomness construct a fresh, unseeded generator, which means they are not reproducible.
- shots_override: int | None = None¶
Per-evaluation shot budget overriding
backend.shotswithout mutating the immutable backend. Read viaeffective_shots; set by callers that drive an adaptive shot count (e.g. QUIVER’sM-adaptivity).Nonefalls back to the backend’s configured shots.