Repository navigation
Conversation
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>
…ders The surface-code and color-code Circuit classes repeated the same "emit X_ERROR for a Z-basis failure, Z_ERROR for an X-basis failure" block 14 times each, once per noise mode and basis, and the mapping from (operation, basis) to a noise-model key was written out at every site. The DEM precompute repeated the same mapping as ternaries. - NoiseModel.spam_probability(kind, basis) is now the single place that maps a prep/meas operation in a basis to its key. - Circuit._spam_probability and Circuit._flip_error (both builders) replace the duplicated blocks in add_reset, add_single_error, add_measure_reset, add_measure and the final-round data-readout flip. - build_single_p_marginal and build_single_p_marginal_color_code index the prep/meas probabilities by basis code instead of branching. No behaviour change: circuit text and DEM probability vectors are byte-identical before and after for 15680 builder/precompute configurations (both codes, scalar and NoiseModel noise, both bases). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Ivan Basov <ibasov@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #104: this branch contains its commit. Only the last commit, 4e3d14d (+145/−315), belongs to this PR. Draft until #104 merges; the branch is then rebased onto
main.What
Refactoring only, no behaviour change. The surface-code and color-code
Circuitclasses repeated the block "emitX_ERRORfor a Z-basis failure,Z_ERRORfor an X-basis failure" 14 times each, and every site spelled out whichdata.noise_modelkey belongs to which basis. The DEM precompute repeated the same mapping as ternaries.Changes
qec/noise_model.py:NoiseModel.spam_probability(kind, basis)is now the single place that maps a prep/meas operation in a basis to its key.qec/surface_code/memory_circuit.py,qec/color_code/memory_circuit.py:Circuit._spam_probabilityandCircuit._flip_errorreplace the duplicated blocks inadd_reset,add_single_error,add_measure_reset,add_measureand the final-round data-readout flip.qec/precompute_dem.py:build_single_p_marginalandbuild_single_p_marginal_color_codeindex the prep/meas probabilities by basis code instead of branching.For a basis or error type other than X/Z, which no caller passes, the result differs: previously an unparsable circuit line or a silent skip, now a
ValueErrorfromspam_probabilityor an empty string.Verification
NoiseModelnoise (including distinct and zero prep/meas values), d=3 and 5, 1/2/4 rounds, both bases,noisy_init/noisy_meas/add_detectors/add_boundary_detectors, four surface-code rotations, color-codegidney_style_noise/flip_triangle.NoiseModel.spam_probabilityintest_noise_model.py, including rejected arguments.unittest discover528 tests, 57 skipped, 1 failure (test_required_model_files_present, pretrained weights not present locally);pyteston the color, precompute, noise-model and torch-setup tests 325 passed, 13 skipped;yapfclean.The builders run once per configuration, so there is no runtime effect.
🤖 Generated with Claude Code