qscript_to_meta¶
- qscript_to_meta(qscript, precision=8, parameter_order=None, was_multi_obs=None)[source]¶
Shared helper: convert a PennyLane
QuantumScriptto aMetaCircuit.Used by
PennyLaneSpecStageand by the program-layer factories indivi.qprog.algorithms. Builds the circuit body from the qscript and derives the measurement observable (SparsePauliOp) or measured-wire tuple from the qscript’s single measurement.- Parameters:
qscript (
QuantumScript) –PennyLane
QuantumScript. Accepts:a single
probs/countsmeasurement;one or more
expvalmeasurements — setsobservableto atuple[SparsePauliOp, ...], one entry per measurement. Mixingexpvalwithprobs/countsin oneQuantumScriptis not supported.
precision (
int) –MetaCircuit.precisionfor numeric gate parameters.parameter_order (
tuple[Parameter,...] |None) – Explicit parameter ordering for the resultingMetaCircuit. Use when the qscript’s first-appearance order doesn’t matchenv.param_setscolumns (e.g. ansatz builds gates in a different order than the flat weight array). WhenNone, ordering is inferred from the qscript (first appearance).was_multi_obs (
bool|None) – Optional override for the resulting MetaCircuit’s_was_multi_obsflag. WhenNone(default), inferred from the script: more than oneexpvalmeasurement →True, otherwiseFalse. PassTruewhen the higher-level caller knows the user opted into the multi-observable API (e.g.observable=[O]inTimeEvolution) even when only one expval ends up in the script.