Skip to content

Comments

Add python scripts for DEM manipulation: generalize_dem.py and decomposer.py#187

Merged
noajshu merged 25 commits intoquantumlib:mainfrom
noajshu:main
Feb 18, 2026
Merged

Add python scripts for DEM manipulation: generalize_dem.py and decomposer.py#187
noajshu merged 25 commits intoquantumlib:mainfrom
noajshu:main

Conversation

@noajshu
Copy link
Contributor

@noajshu noajshu commented Feb 17, 2026

Here we open source python versions of two DEM processing utilities.

  • DEM Generalization: When decoding the color code experiments, we found a large improvement in logical error rate (about 0.87x reduction factor) from calibrating a DEM on the rate that a most-likely-error decoder predicts that each error mechanism across a calibration dataset taken with the same set of qubits. To aggregate stats and generalize a DEM from, say, 10 rounds to 100 rounds, we use the detector coordinates of the DEM to identify a unique spatial key.

  • DEM Error Decomposition: Another DEM processing task important for matching decoders is decomposition. Stim's decomposition tactics are robust and general, at the cost of being suboptimal for the surface code.

As a next step, we could expose the functionality in Tesseract as follows:

import tesseract_decoder

# Take one or more DEMs **with detector coordinates**, aggregate the error probabilities
nice_calibrated_dem = tesseract_decoder.demutil.regeneralize_spatial_dem(
    templates: List[stim.DetectorErrorModel],
    scaffold: stim.DetectorErrorModel,
    verbose: bool=False
)

# Re-decompose the errors assuming Stim surface code coordinate convention
nice_matchable_dem = tesseract_decoder.demutil.decompose_errors(dem method='stim-surfacecode-coords')

# Re-decompose the errors assuming the last-coordinate index indicates the component:
nice_matchable_dem2 = tesseract_decoder.demutil.decompose_errors(dem, method='last-coordinate-index')

noajshu and others added 23 commits February 14, 2026 13:36
…culation

Fix Simplex cost_from_errors to use provided errors and const-qualify mask/cost helpers
…o fix the test failure caused by the previous fix to the cost from errors function in simplex
…into codex/add-index-translation-vectors-for-dem-errors
…rs-for-dem-errors

Add index translation vectors for DEM errors
@noajshu noajshu requested a review from a team as a code owner February 17, 2026 19:13
@noajshu noajshu requested review from LalehB and oscarhiggott and removed request for a team February 17, 2026 19:13
Copy link
Collaborator

@LalehB LalehB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
p.s. we will move them later for demutil

@noajshu noajshu merged commit b66b782 into quantumlib:main Feb 18, 2026
7 checks passed
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