pub fn emit_plan_stim(
plan: &NodeEmissionPlan,
options: &PlanStimOptions<'_>,
) -> Result<PlanStim, StimEmissionError>Expand description
Lower one node’s emission plan to standalone Stim text.
Every Op variant is handled, so a plan is never rejected for containing
an operation this does not know about. Two conventions are worth naming
because they are not the only defensible choices:
REPEATis unrolled.Self::measurement_columnsare absolute positions, and a measurement inside a loop occupies a different one every iteration. Unrolling is what makes the map well defined; the cost is that a plan with a large repetition count produces proportionally large text.- A feedback
Yis written asCXthenCZ, notCY. The control is a classical record, so the phase difference betweenYandXZis constant across the whole branch and cannot be observed. This matches the convention the artifacts already in the field were built with, and deliberately differs fromemit_bloq_stim, whose text is pinned by its own consumers.
§Errors
StimEmissionError::Circuitif a plan qubit is missing from the qubit map, a body reference dangles or recurses, or a record lookback leaves Stim’s range.StimEmissionError::QubitIndexOutOfRangeif a caller-supplied qubit index exceeds16_777_215.StimEmissionError::UnsupportedGatefor a non-Clifford gate other thanT/T_DAGin theStimDialect::Stimdialect, which Stim could not parse.StimEmissionError::MalformedGraphif a feedback control is read before its measurement is emitted, or the plan names a measurement its own circuit never emits.
§Panics
In debug builds, panics if plan emission disagrees with the circuit column walk.