Fix reset-window and final-round data-qubit priors in precompute_dem#87
Conversation
Two circuit-vs-sampler mismatches in build_single_p_marginal, both in the explicit 25-parameter noise model path: 1. Data qubits idling during the ancilla prep/reset window (tt == 0, intermediate rounds) were assigned p_idle_cnot_*, but the circuit emits no noise there: that idle is folded into the measurement-window SPAM idle. Assign 0 instead. 2. The final-round data injection was assigned p_prep_*, but the circuit represents noisy data readout as a fake data-measurement flip at p_meas_* (Z_ERROR(p_meas_X) for X-basis readout, X_ERROR(p_meas_Z) for Z-basis). Use the measurement rates. Adds unit tests for both locations plus a seeded end-to-end guard that compares per-round syndrome densities from Bernoulli(p) errors pushed through H against direct Stim sampling of the same MemoryCircuit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@jolle-ag one focused question for review, since this pins down the intended noise-model semantics: is the Stim circuit the reference on both counts — (1) the data-qubit reset-window idle carries no separate noise location because it is folded into the measurement-window SPAM idle (consistent with the |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bmhowe23
left a comment
There was a problem hiding this comment.
LGTM. It would be good to get Jan's answer to your question before merging.
|
Thanks for catching this. What you spotted and how you fixed it is the intended behavior. |
Summary
Follow-up to #85 (see the review discussion there). Auditing
build_single_p_marginalwith the same isolated-channel Stim methodology used to validate #85 surfaced two more circuit-vs-sampler mismatches in the explicit 25-parameter noise-model path. Both predate #85 and were invisible to its validation only because the affected channels were zeroed in that isolation.1. Reset-window data idles were overcounted with
p_idle_cnot_*In NoiseModel mode the circuit applies no idle noise to data qubits during the ancilla prep/reset window — that idle is deliberately folded into the measurement-window SPAM idle (
MemoryCircuit: "IGNORE data-idle during ancilla prep/reset"; the config calibrationp_idle_spam = 2p/3 − 4p²/9reflects the combined window). But the marginal builder let intermediate-round data locations attt == 0fall through to the bulk-idle branch and assignedp_idle_cnot_*.Isolating
p_idle_cnot_X/Y/Z = 0.002(d=3, r=4, X basis, 400k shots), per-round mean syndrome densities:With the full public 25-parameter values (r13 config), intermediate-round syndrome densities were ~10% hotter than Stim (0.1020 vs 0.0924).
Fix: intermediate-round data locations at
tt == 0get probability 0. Boundary rounds are unaffected (theirtt == 0data locations are consumed byis_data_prep).2. Final-round data injection used the preparation rates
The circuit represents noisy data readout as a fake data-measurement flip injected at the start of the final perfect round, at the measurement rates:
Z_ERROR(p_meas_X)for X-basis readout,X_ERROR(p_meas_Z)for Z-basis. The sampler'sis_data_prepbranch assignedp_prep_X/Zinstead (itsis_final_roundsplit had identical arms — this change makes the split carry the intended distinction).All shipped configs use
p_prep == p_meas, so this cancels numerically today, but it breaks as soon as the two families are calibrated separately. Isolating the channels makes the mirror image visible in the final round (d=3, r=4, 400k shots): with onlyp_meas_* = 0.004, Stim shows 0.0099 vs the sampler's 0.0040; with onlyp_prep_* = 0.004, the sampler showed 0.0099 vs Stim's 0.0040. After the fix both isolations agree with Stim.Tests
Extends
test_precompute_dem_probabilities.py(added in #85):p_meas_*with the basis-correct Pauli), plus a guard that round-0 data preparation keepsp_prep_*. The two new location tests fail onmainwith the expected signatures.TestSamplerMatchesStimSyndromeDensities): per-round syndrome densities from Bernoulli(p) errors pushed through the precomputedHmust match direct Stim sampling of the sameMemoryCircuitwithin 5 standard errors, for cnot-idle-only, measurement-only, and full-25-parameter noise. Runs in ~1 s at d=3/r=4 (CPU, no cuStabilizer needed), so it sits in the short tier and will catch any future circuit-vs-sampler prior drift.Impact
Only the explicit-NoiseModel path of
build_single_p_marginalis touched; the legacy scalar path is untouched (its circuit emits a genuine reset-window idle, which it already accounts for). Training data generated after this change has intermediate-round syndrome densities ~10% lower than before, now matching the Stim reference; models trained on previously generated bundles are unaffected functionally but were trained against slightly hotter priors.