Skip to content

Expose error model sparsification to python module, update sinter decoders dict#257

Merged
noajshu merged 14 commits into
mainfrom
sparsify-errors-python
Jun 15, 2026
Merged

Expose error model sparsification to python module, update sinter decoders dict#257
noajshu merged 14 commits into
mainfrom
sparsify-errors-python

Conversation

@noajshu

@noajshu noajshu commented May 27, 2026

Copy link
Copy Markdown
Contributor

Exposes per-shot error model sparsification to the Python module, CLI, and Sinter compatibility layer.

Changes:

  • Added Python sparsification config fields: sparsify_errors, sparsify_base_degree, sparsify_max_degree, and sparsify_reactivate_limit.
  • Added module-level tesseract.suggest_sparsify_reactivate_limit(num_detectors, sparsify_base_degree) for documenting and testing the built-in heuristic.
  • Resolves sparsify_reactivate_limit == -1 only when preparing the decoder, and reports the effective resolved value in CLI stats output.
  • Caps the auto reactivation limit to the compiled error count and avoids overflow in the heuristic computation.
  • Added validation for sparsification parameters: base degree must be positive when sparsification is enabled, max degree must not contradict base degree, and reactivation limit must be >= -1.
  • Kept CLI sparsification semantics explicit: user-provided nonnegative --sparsify-reactivate-limit is preserved, while -1 or an omitted value uses auto resolution at decoder initialization.
  • Changed the C++ CLI, Python config, and Sinter decoder defaults to DetIndex ordering. --det-order-bfs remains available for the old BFS behavior.
  • Extended TesseractSinterDecoder to support sparsification config while preserving pickle/serialization compatibility for existing distributed Sinter runs.
  • Registered readable sparsified decoders in the Sinter decoders dictionary: tesseract-long-beam-sparsify-color-code-like, tesseract-long-beam-sparsify-surface-code-like, tesseract-short-beam-sparsify-color-code-like, and tesseract-short-beam-sparsify-surface-code-like.
  • Added README guidance for choosing non-sparsified, surface-code-like sparsified, color-code-like sparsified, long-beam, and short-beam variants.
  • Added Python and C++ unit tests for sparsify config, validation, heuristic suggestion, Sinter propagation, auto-limit capping, and end-to-end decoding.

@noajshu noajshu changed the title feat(python): expose error model sparsification and add sinter decoders Expose error model sparsification to python module, update sinter decoders dict May 27, 2026
@noajshu noajshu marked this pull request as ready for review June 10, 2026 16:38
@noajshu noajshu requested a review from a team as a code owner June 10, 2026 16:38
@noajshu noajshu requested review from LalehB, aria-googler and mhucka and removed request for a team June 10, 2026 16:38

@mhucka mhucka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not qualified to evaluate the algorithmic or theoretical correctness, but I tried to look at this from the a basic code perspective. I had a couple of minor items, noted in-line.

In addition, one thing that I don't see (and this may just be due to ignorance of Tesseract Decoder) is an update to the .pyi files. This PR does seem to introduce new properties on some objects, which suggests the .pyi files may become out of date. Not 100% sure – just flagging it for your attention.

Comment thread src/py/README.md
Comment thread src/py/tesseract_test.py Outdated
Comment thread src/tesseract.cc Outdated
Comment thread src/tesseract_main.cc

@LalehB LalehB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

Comment thread src/py/README.md Outdated
noajshu and others added 14 commits June 14, 2026 22:59
Exposes the per-shot error model sparsification functionality (added in PR 254)
to the Python module and Sinter compatibility layer.

Changes:
- Moved the sparsify reactivate limit (M) heuristic calculation from the CLI
  to `TesseractConfig::get_sparsify_reactivate_limit()` in C++ core.
- Added validation for sparsification parameters in decoder initialization.
- Simplified CLI sparsification parameter resolution.
- Bound sparsification parameters (`sparsify_errors`, `sparsify_base_degree`,
  `sparsify_max_degree`, `sparsify_reactivate_limit`) and the heuristic
  resolution method in `TesseractConfig` Python bindings.
- Extended `TesseractSinterDecoder` to support sparsification config,
  maintaining pickling/serialization compatibility for distributed Sinter runs.
- Registered new sparsified decoders in Sinter decoders dictionary:
  `tesseract-long-beam-sparsify3`, `tesseract-long-beam-sparsify2`,
  `tesseract-short-beam-sparsify3`, and `tesseract-short-beam-sparsify2`.
- Added comprehensive Python unit tests for core sparsify config, validation,
  and Sinter end-to-end decoding.
- Fixed pre-existing CMake build failure under strict compilers by upgrading
  external HiGHS dependency to v1.14.0.

TAG=agy
CONV=365755ec-6af0-4d9c-a7e2-4a363289b763
Added recommendations for setting K in various code types.
@noajshu noajshu force-pushed the sparsify-errors-python branch from 18e9b14 to 726ad20 Compare June 15, 2026 06:13
@noajshu

noajshu commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks Mike and Laleh for the reviews!

@noajshu noajshu merged commit feb094c into main Jun 15, 2026
14 checks passed
@noajshu noajshu deleted the sparsify-errors-python branch June 15, 2026 06:24
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.

3 participants