Skip to content

Read prep/meas noise keys by failing basis in the color-code circuits - #104

Merged
ivanbasov merged 1 commit into
mainfrom
fix/color-code-prep-meas-key-convention
Nov 19, 2026
Merged

ivanbasov merged 1 commit into
mainfrom
fix/color-code-prep-meas-key-convention

Conversation

@ivanbasov

@ivanbasov ivanbasov commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What

The four prep/meas keys of data.noise_model are named by the basis that fails: p_prep_Z / p_meas_Z belong to Z-basis reset/measurement (applied as X_ERROR), p_prep_X / p_meas_X to X-basis (applied as Z_ERROR). The surface-code builder, conf/config_public.yaml and the README follow this.

The color-code path paired them the other way (Z-basis reset/measurement took p_prep_X / p_meas_X), so a non-uniform noise model had its X-basis and Z-basis rates exchanged. This PR gives the color-code path the same pairing as the surface code. The Pauli applied for each basis is unchanged; only the key that supplies the probability changes.

Changes

  • qec/color_code/memory_circuit.py: add_reset, add_single_error, add_measure_reset, add_measure, and the data-readout flip of the final round.
  • qec/precompute_dem.py: build_single_p_marginal_color_code, so the Torch probability vector keeps matching the Stim circuit.
  • qec/noise_model.py: docstring only.

Impact

Behaviour changes only for the color code with p_prep_X != p_prep_Z or p_meas_X != p_meas_Z; exchange the values within each pair to reproduce earlier results.

All configs under conf/, NoiseModel.from_single_p, NoiseModel.from_si1000 and the pretrained models use equal values within each pair. For these the color-code circuit and probability vector are byte-identical before and after (checked at d=5, both bases).

Tests

  • New test_color_code_prep_meas_key_convention.py: a single non-zero key produces the expected instruction on the expected qubits; the color builder agrees with the surface builder; the DEM precompute agrees with the Stim circuit. Fails on main, passes here.
  • Changed expectations in test_color_augmented_dem_precompute.py, which pinned the old pairing with four distinct values: test_color_single_qubit_noise_probabilities_follow_pauli_labels (renamed ..._follow_basis_labels) and test_color_stim_and_dem_data_noise_locations_match.
  • Local: unittest discover 528 tests, 57 skipped, 1 failure (test_required_model_files_present, pretrained weights not present locally); pytest on the color tests 315 passed, 11 skipped; yapf clean.

🤖 Generated with Claude Code

The color-code Stim builder and the color-code DEM precompute read
p_prep_X, p_prep_Z, p_meas_X and p_meas_Z by the applied Pauli
(Z-basis reset/measure used the *_X keys), while the surface-code
builder, the config comments and the README name a key by the basis
that fails (Z-basis reset/measure uses the *_Z keys and is applied as
X_ERROR). With a non-uniform noise model the color-code path applied
the X-basis rates to the Z basis and vice versa.

Move the color-code readers to the surface-code convention:
- qec/color_code/memory_circuit.py: add_reset, add_single_error,
  add_measure_reset, add_measure and the data-readout flip injected in
  the final round.
- qec/precompute_dem.py: build_single_p_marginal_color_code (ancilla
  prep/meas, data prep and final data-readout entries).

Models with p_prep_X == p_prep_Z and p_meas_X == p_meas_Z, which
includes every shipped config, produce the same circuits and
probability vectors as before.

Tests: add test_color_code_prep_meas_key_convention.py and update the
two expectations in test_color_augmented_dem_precompute.py that pinned
the previous convention.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Ivan Basov <ibasov@nvidia.com>
@ivanbasov
ivanbasov merged commit bf639ab into main Nov 19, 2026
17 checks passed
ivanbasov added a commit that referenced this pull request Nov 19, 2026
With #104 merged, the color-code circuits read the prep/meas keys by the
failing basis, as the surface-code circuits do. Drop the sentence that
said they read them the other way and the surface-code scoping of the
parameter-name note. The example itself still covers the surface code only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Ivan Basov <ibasov@nvidia.com>
ivanbasov added a commit that referenced this pull request Nov 19, 2026
* Document noise learning with CUDA-Q QEC for pre-decoder training

Add NOISE_LEARNING.md: how to estimate the 25-parameter noise model from
detector data with cudaq-qec 0.9.0 (nv_qldpc.learn_noise, parametric mode)
and write it as a data.noise_model block for training. Link it from the
"Noise model" section of the README.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Ivan Basov <ibasov@nvidia.com>

* Fit one noise model to both bases in the noise learning guide

Address review comments on the noise learning guide.

The example combined the two single-basis results parameter by
parameter. One memory basis fixes the preparation and measurement
parameters only together with two CNOT parameters, so values taken from
different runs do not form a consistent set. The example now fits the
one set of 25 parameters that reproduces the mechanism rates learned in
both bases; the two experiments together fix all 25.

Also state that the device must run the MemoryCircuit schedule, scope
the parameter-name note and the swap step to the surface-code circuits,
say what a single-basis result can be used for, and correct the
description of the learn_physical_params command-line tool.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Ivan Basov <ibasov@nvidia.com>

* Update the noise learning guide for the color-code key convention

With #104 merged, the color-code circuits read the prep/meas keys by the
failing basis, as the surface-code circuits do. Drop the sentence that
said they read them the other way and the surface-code scoping of the
parameter-name note. The example itself still covers the surface code only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Ivan Basov <ibasov@nvidia.com>

---------

Signed-off-by: Ivan Basov <ibasov@nvidia.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants