MetaCircuit¶
- class MetaCircuit(circuit_bodies, parameters=(), observable=None, measured_wires=None, measurement_qasms=(), qasm_bodies=(), measurement_groups=(), 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
Tagged parametric DAGs.
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.
Methods Summary
set_circuit_bodies(bodies)Return a new MetaCircuit with updated circuit-body DAGs.
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.
Attributes Documentation
- circuit_bodies: tuple[tuple[tuple[tuple[str, Hashable], ...], DAGCircuit], ...] = <dataclasses._MISSING_TYPE object>¶
Tagged parametric DAGs. Every body shares the same logical qubit layout.
- 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.
Methods Documentation
- set_circuit_bodies(bodies)[source]¶
Return a new MetaCircuit with updated circuit-body DAGs.
- 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: