QEMStage¶
- class QEMStage(protocol=None)[source]¶
Bases:
BundleStageBundleStage that applies a QEM protocol to each circuit body.
Threads
QEMContextobjects through theStageTokenso thatreducecan pass them back to the protocol together with the quantum results.Attributes Summary
Axis name introduced by this stage.
Whether this stage invalidates forward-pass reuse from this point.
Methods Summary
dry_expand(batch, env)Analytic path: delegates each body to
protocol.dry_expand.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)Check this stage's position in the pipeline.
Attributes Documentation
- axis_name¶
- stateful¶
Methods Documentation
- dry_expand(batch, env)[source]¶
Analytic path: delegates each body to
protocol.dry_expand.The default
dry_expand()falls back toexpandso simple / cheap protocols (e.g._NoMitigation,ZNE) stay correct unchanged. Expensive protocols such asQuEPPoverridedry_expandto skip Clifford simulation + per-path DAG cloning while preserving the emitted DAG count.- Return type:
- expand(batch, env)[source]¶
Transform keyed MetaCircuit batch and return expansion lineage plus token.
- Return type:
- 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
expandwith the post-expand batch, the pipeline env, and the stage’s token.
- validate(before, after)[source]¶
Check this stage’s position in the pipeline.
Called by
CircuitPipelineat construction time after structural validation. Override to inspect neighboring stages and either:raise
ContractViolationif preconditions are not met, oremit
DiviPerformanceWarningfor legal-but-slow configurations (e.g. expensive internal options, known-bad neighboring stages). Suppressed at the pipeline level viaCircuitPipeline(..., suppress_performance_warnings=True).