MetaCircuit¶
- class MetaCircuit(circuit_bodies, parameters=(), observable=None, measured_wires=None, measurement_qasms=(), qasm_bodies=(), measurement_groups=(), result_format=None, group_shots=None, backend_ham_ops=None, precision=8, _was_multi_obs=False)[source]¶
Bases:
objectLogical circuit IR.
Stores one or more tagged
DAGCircuitbodies together with the parameters that appear in them, optional observable / measured-wire metadata, and the (already-serialised) measurement QASM strings produced byMeasurementStage.The DAGCircuit bodies are the long-lived working IR for all stages that mutate circuits at the gate level (QEM folding, Pauli twirling, QuEPP path enumeration). QASM2 text is produced only once per parametric body — inside
ParameterBindingStagewhen it builds aQASMTemplate— and once at compilation time when bound bodies are concatenated with the pre-serialised measurement QASMs.Attributes Summary
Observable string handed to the backend for analytic expectation values (
_backend_expvalgrouping);Nonefor counts-based paths.Tagged parametric DAGs.
Per-observable-group shot allocation (
group_index -> shots) when ashot_distributionis active;Noneotherwise.Qubit indices to measure for probs/counts measurements.
Cached grouped observables set by
MeasurementStage.Pre-serialised, non-parametric OpenQASM 2.0 measurement strings (diagonalising gates +
measureinstructions), one per commuting observable group.Number of qubits in the circuit (from the first body DAG).
Observable(s) for expectation-value measurements.
Ordered Qiskit Parameter objects referenced by the DAGs.
Number of decimal places for numeric parameter values in QASM conversion.
OpenQASM 2.0 body strings at the current binding level.
Canonical format the raw backend results should be converted into.
Methods Summary
set_backend_ham_ops(ham_ops)Return a new MetaCircuit with the backend observable string set.
set_circuit_bodies(bodies)Return a new MetaCircuit with updated circuit-body DAGs.
set_group_shots(group_shots)Return a new MetaCircuit with per-group shot allocation set.
set_measurement_bodies(bodies)Return a new MetaCircuit with updated measurement QASMs.
set_measurement_groups(measurement_groups)Return a new MetaCircuit with updated measurement groups.
set_qasm_bodies(bodies)Return a new MetaCircuit with updated QASM body strings.
set_result_format(result_format)Return a new MetaCircuit with the result format set.
Attributes Documentation
- backend_ham_ops: str | None = None¶
Observable string handed to the backend for analytic expectation values (
_backend_expvalgrouping);Nonefor counts-based paths.
- circuit_bodies: tuple[tuple[tuple[tuple[str, Hashable], ...], DAGCircuit], ...] = <dataclasses._MISSING_TYPE object>¶
Tagged parametric DAGs. Every body shares the same logical qubit layout.
- group_shots: Mapping[int, int] | None = None¶
Per-observable-group shot allocation (
group_index -> shots) when ashot_distributionis active;Noneotherwise.
- measured_wires: tuple[int, ...] | None = None¶
Qubit indices to measure for probs/counts measurements.
Nonefor expval.
- measurement_groups: tuple[tuple[object, ...], ...] = ()¶
Cached grouped observables set by
MeasurementStage.
- measurement_qasms: tuple[tuple[tuple[tuple[str, Hashable], ...], str], ...] = ()¶
Pre-serialised, non-parametric OpenQASM 2.0 measurement strings (diagonalising gates +
measureinstructions), one per commuting observable group. Populated byMeasurementStage.set_measurement_bodies.
- n_qubits¶
Number of qubits in the circuit (from the first body DAG).
- observable: SparsePauliOp | tuple[SparsePauliOp, ...] | None = None¶
Observable(s) for expectation-value measurements.
None— probs/counts measurement (usesmeasured_wiresinstead).SparsePauliOp— accepted as input;__post_init__wraps it in a length-1 tuple.tuple[SparsePauliOp, ...]— canonical stored form; one mitigated expectation value per entry.
- parameters: tuple[Parameter, ...] = ()¶
Ordered Qiskit Parameter objects referenced by the DAGs. Order matches the flat parameter-values array fed by
ParameterBindingStage.
- qasm_bodies: tuple[tuple[tuple[tuple[str, Hashable], ...], str], ...] = ()¶
OpenQASM 2.0 body strings at the current binding level.
One slot carries a body through progressive binding by the parameter-binding stages:
DataBindingStageparks per-sample partial bodies (data substituted, weight placeholders kept), whichParameterBindingStageconsults bybody_tagprefix before falling back to serialisingcircuit_bodiesviadag_to_qasm_body(); that stage then renders either fully bound bodies (no placeholders) or template bodies (placeholders preserved for backend substitution). The compilation pass reads this slot when non-empty, else serialisescircuit_bodieson the fly.
- result_format: ResultFormat | None = None¶
Canonical format the raw backend results should be converted into. Set by a measurement stage; read by
pipeline.run().
Methods Documentation
- set_backend_ham_ops(ham_ops)[source]¶
Return a new MetaCircuit with the backend observable string set.
- Return type:
- set_circuit_bodies(bodies)[source]¶
Return a new MetaCircuit with updated circuit-body DAGs.
- Return type:
- set_group_shots(group_shots)[source]¶
Return a new MetaCircuit with per-group shot allocation set.
- Return type:
- set_measurement_bodies(bodies)[source]¶
Return a new MetaCircuit with updated measurement QASMs.
- Return type:
- set_measurement_groups(measurement_groups)[source]¶
Return a new MetaCircuit with updated measurement groups.
- Return type:
- set_qasm_bodies(bodies)[source]¶
Return a new MetaCircuit with updated QASM body strings.
- Return type: