CircuitPreprocessor

class CircuitPreprocessor(name, preprocess=<function _identity>, result_format=ResultFormat.EXPVALS, terminal_stage=None, consumes_dag_bodies=False, cache_key=None)[source]

Bases: object

A named seed transform and the readout it targets.

Variables:
  • name – Identifier for the routine ("cost", "sample", …).

  • preprocess – Transform applied to each post-spec MetaCircuit before mitigation and the terminal measurement. Defaults to identity.

  • result_format – Format the raw backend results convert into; also drives error-mitigation applicability when the pipeline is assembled. Defaults to expectation values.

  • terminal_stage – Optional custom handles_measurement terminal. None means the program supplies its default MeasurementStage (configured with the program’s grouping / shot strategy); PCE supplies its own PCECostStage.

  • consumes_dag_bodies – Whether preprocess reads or replaces circuit DAG bodies. Metadata-only transforms leave this False so dry runs can keep analytic shortcuts.

  • cache_key – Identity under which _build_preprocessor_pipeline() memoizes the assembled pipeline (so its forward-pass cache survives across optimizer iterations). None (the default) means do not cache — the pipeline is rebuilt per call and discarded. Every built-in routine (cost/sample/evolution/overlap and the metric estimators) passes a constant key, because each one’s preprocess is a pure transform; per-iteration freshness where it is needed (the QDrift stochastic resampling) comes from the spec stage’s cache_key_extras invalidating the forward-pass cache, not from leaving this None.

Attributes Summary

Methods Summary

Attributes Documentation

cache_key: Hashable | None = None
consumes_dag_bodies: bool = False
name: str = <dataclasses._MISSING_TYPE object>
result_format: ResultFormat = 'expvals'
terminal_stage: Stage | None = None

Methods Documentation

preprocess()
Return type:

MetaCircuit