Adding GARI#269
Open
arshpreetmaan wants to merge 1 commit into
Open
Conversation
…esseract/simplex cli
noajshu
reviewed
Jul 14, 2026
| # "modeI", "modeJ", "modeK", "modeL", "modeM", "modeN", | ||
| # "modeO", "modeP", "modeQ", "modeR", "modeS", "modeU", | ||
| # "modeV", "modeS2", "modeSO", "modeSO2" | ||
| # ] |
Contributor
There was a problem hiding this comment.
any reason to leave this comment here?
noajshu
reviewed
Jul 14, 2026
Comment on lines
+169
to
+172
|
|
||
| I_nx = eye(nx, format='csc', dtype=np.uint8) | ||
| I_nz = eye(nz, format='csc', dtype=np.uint8) | ||
|
|
Contributor
There was a problem hiding this comment.
This seems to be the central idea from the gari paper? Maybe good to add a comment with some reference to that paper and the specific eq / figure?
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.
Key Changes
det_ordersare introduced as an efficiency feature. These allow Tesseract to process the new GARI-DEM detectors in an optimal chronological manner (for example, real then virtual detectors) to improve speed and efficiency. New and improved orderings can be added based on the circuit under consideration.1. Core Python Utility (
src/py/)This PR introduces a Python interface for GARI (
gari_dem_utils.py), which does the following:gari_transform(H, L, det_types): Transforms physical matrices defining the dem (gari_structuredictionary (GARI matrices, virtual maps, and other data).assign_prior_weights(gari_structure, method, original_priors): Implements various modes to assign weights. Optimizations are solved on-demand for the requestedmethod, preventing redundant execution of all LP algorithms.get_detector_orderings(gari_structure, det_types, ordering_name): Computes custom stabilizer order sequences to prioritize A* search expansion.2. Core C++ Changes & CLI Configuration
Both
tesseract_main.ccandsimplex_main.ccaccept the--demand--det-mapping-fileCLI arguments:--dem: Path to the Stim detector error model (DEM) file (accepts GARI dem as well).--det-mapping-file: Path to a JSON file containing the mapping between the original physical detector indices and detector indices in GARI dem.Tesseract-Only Configuration:
--custom-orderIn
tesseract_main.cc,--custom-orderspecifies a custom detector ordering key to load fromdet_ordersin the JSON mapping file (e.g.--custom-order order10). The orderings guide A* search branching priorities. Simplex does not support stabilizer orderings.3. Simulation Loop & Shot Data Mapping
Incoming physical detector shot data ($N$ original detectors) is translated to the GARI detector space ($M$ GARI detectors) on-the-fly during decoding.
Mapping C++ Loop
det_mapping[d].Virtual Stabilizers and Parity Bounds
Since GARI adds virtual check stabilizers ($M > N$ ), any unmapped virtual checks are initialized with
0(even parity).What Happens if the Mapping File is Omitted?
--det-mapping-fileis omitted, the reader expects01 data ended in middle of record...and throws.[Real X, Real Z, ...]), this layout mismatch causes invalid logical error rates. A possible workaround would be to reorder the real detectors in GARI dem to be same as in original circuit/dem.Safety & Bounds Warnings
det_mapping[hit]using[]performs no bounds checking. If a physical shot contains a stabilizer index higher than the mapping size, it leads to undefined behavior/segmentation fault.[0, count_detectors - 1]. If an invalid index is included in JSON, it causes an out-of-bounds vector access insidetesseract.ccand crashes.4. Sparsification Compatibility
Tesseract's
--sparsify-errorsfeatures are fully compatible with GARI. The sparsifier operates directly on the symptom error degree extracted from the loadedstim::DetectorErrorModel. Because the incoming shots are remapped to GARI space prior to decoding, the GARI indices in both the DEM and the mapped hits align perfectly.5. Testing & Verification
bazel test //src/py/...bazel run //src/py/_tesseract_py_util:gari_dem_utils -- "testdata/surfacecodes/"bazel run //src/py:gari_simulation_test6. Simulation results
Initial benchmarking shows that running Tesseract on the GARI dem can yield up to a 35x speedup. Additional tuning of prior weights, det_orders, and beam parameters suited for the GARI dem's structure is expected to increase performance further.