-
Notifications
You must be signed in to change notification settings - Fork 26
Expose error model sparsification to python module, update sinter decoders dict #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
noajshu
wants to merge
13
commits into
main
Choose a base branch
from
sparsify-errors-python
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
53c530b
feat(python): expose error model sparsification and add sinter decoders
noajshu 1831f23
format
noajshu 59f9f53
Address sparsify Python review feedback
noajshu 1e726ba
Use free sparsify limit suggestion helper
noajshu 2404262
Update README with K settings for error handling
noajshu 5b0d0b2
Default CLI detector ordering to index
noajshu 90f3b4f
Report resolved sparsify reactivation limit in stats
noajshu 845da96
Avoid reserving max pqlimit arena
noajshu 308e2ec
Format stats JSON initializer
noajshu 1a0a3f8
Show resolved sparsify limit in docs
noajshu 0d01be7
Document sparsified decoder selection guidance
noajshu 13f9c00
Default Python detector ordering to index
noajshu 18e9b14
Fix sparsify stats error count clamp build
noajshu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ The `tesseract_decoder.tesseract` module provides the Tesseract decoder, which e | |
|
|
||
| #### Class `tesseract.TesseractConfig` | ||
| This class holds the configuration parameters that control the behavior of the Tesseract decoder. | ||
| * `TesseractConfig(dem: stim.DetectorErrorModel, det_beam: int = 5, beam_climbing: bool = False, no_revisit_dets: bool = True, verbose: bool = False, merge_errors: bool = True, pqlimit: int = 200000, det_orders: list[list[int]] = [], det_penalty: float = 0.0, create_visualization: bool = False)` | ||
| * `TesseractConfig(dem: stim.DetectorErrorModel, det_beam: int = 5, beam_climbing: bool = False, no_revisit_dets: bool = True, verbose: bool = False, merge_errors: bool = True, pqlimit: int = 200000, det_orders: list[list[int]] = [], det_penalty: float = 0.0, create_visualization: bool = False, sparsify_errors: bool = False, sparsify_base_degree: int = -1, sparsify_max_degree: int = -1, sparsify_reactivate_limit: int = -1)` | ||
| * `__str__()` | ||
|
|
||
| Explanation of configuration arguments: | ||
|
|
@@ -20,6 +20,13 @@ Explanation of configuration arguments: | |
| * `det_orders` - A list of lists of integers, where each inner list represents an ordering of the detectors. This is used for "ensemble reordering," an optimization that tries different detector orderings to improve the search's convergence. The default is an empty list, meaning a single, fixed ordering is used. | ||
| * `det_penalty` - A floating-point value that adds a cost for each residual detection event. This encourages the decoder to prioritize paths that resolve more detection events, steering the search towards more complete solutions. The default value is `0.0`, meaning no penalty is applied. | ||
| * `create_visualization` - A boolean flag that enables decoder visualization output when set to `True`. The default value is `False`. | ||
| * `sparsify_errors` - Enables per-shot sparse error activation. When enabled, all errors up to `sparsify_base_degree` are always active, and selected higher-degree errors are reactivated per shot. | ||
| * `sparsify_base_degree` - Required when `sparsify_errors=True`. Errors with detector degree less than or equal to this value are always active. | ||
| * `sparsify_max_degree` - Optional maximum degree for reactivated errors. Use `-1` for no maximum degree cap. | ||
| * `sparsify_reactivate_limit` - Maximum number of optional high-degree errors to reactivate per shot. Use `-1` to apply the built-in heuristic, clamped to the number of errors in the compiled error model. | ||
|
|
||
| Module-level helper: | ||
| * `suggest_sparsify_reactivate_limit(num_detectors, sparsify_base_degree)` - Returns the suggested reactivation limit for a detector count and base degree. The decoder applies this suggestion, clamped to the compiled error count, when `sparsify_reactivate_limit == -1`. | ||
|
|
||
| **Example Usage**: | ||
|
|
||
|
|
@@ -59,6 +66,21 @@ print(f"Custom configuration no-revisit detection events: {config2.det_beam}") | |
| print(f"Custom configuration pqlimit: {config2.det_beam}") | ||
| print(f"Custom configuration verbose: {config2.det_beam}") | ||
| print(f"Custom configuration detection penalty: {config2.det_beam}") | ||
|
|
||
| # Configuration with error sparsification | ||
| config3 = tesseract.TesseractConfig( | ||
| dem=dem, | ||
| det_beam=20, | ||
| beam_climbing=True, | ||
| sparsify_errors=True, | ||
| sparsify_base_degree=3, | ||
| sparsify_reactivate_limit=-1, | ||
| ) | ||
| decoder = config3.compile_decoder() | ||
| print( | ||
| "Resolved sparsify reactivation limit:", | ||
| decoder.config.sparsify_reactivate_limit, | ||
| ) | ||
| ``` | ||
|
|
||
| #### Class `tesseract.TesseractDecoder` | ||
|
|
@@ -488,6 +510,17 @@ The Tesseract Python interface is compatible with the Sinter framework, which is | |
|
|
||
| #### The TesseractSinterDecoder Object | ||
| All Sinter examples rely on this utility function to provide the Sinter-compatible Tesseract decoder. | ||
| The default decoder dictionary also includes sparsified variants: | ||
| `tesseract-long-beam-sparsify3`, `tesseract-long-beam-sparsify2`, | ||
| `tesseract-short-beam-sparsify3`, and `tesseract-short-beam-sparsify2`. | ||
|
|
||
| As a quick rule of thumb, use the non-sparsified decoders as the safest baseline. Use `sparsify2` | ||
| for surface-code-like or mostly graphlike DEMs, and use `sparsify3` for color-code, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit: wdyt about using a name like |
||
| bivariate-bicycle-code, or other DEMs where a typical bulk data error activates about three | ||
| detectors. Within either family, prefer the long-beam variants when accuracy matters more and the | ||
| short-beam variants when runtime matters more. See the root README's | ||
| [Performance Optimization](../../README.md#performance-optimization) section for the full | ||
| sparsification details. | ||
|
|
||
| ```python | ||
| import sinter | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.