Skip to content

Add confidence_ratio option to LookupDecoder - #552

Merged
perlinm merged 7 commits into
mainfrom
lut
Jul 30, 2026
Merged

Add confidence_ratio option to LookupDecoder#552
perlinm merged 7 commits into
mainfrom
lut

Conversation

@perlinm

@perlinm perlinm commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

AI-assisted summary

This PR lets LookupDecoder decline to commit to a logical prediction when a syndrome is ambiguous, rather than always guessing the single most likely observable flip.

Behavior. When a syndrome is consistent with more than one observable flip, the decoder groups the candidate errors (of weight ≤ max_weight) by the observable flip they induce and gives each group a net probability. With a positive confidence_ratio, the decoder assigns an ambiguous syndrome the most likely flip iff that flip is at least confidence_ratio times as likely as all the other flips combined — i.e. prob_top >= confidence_ratio * prob_rest. Otherwise, the syndrome is omitted from the lookup table, so it decodes to erasure.

A positive confidence_ratio therefore auto-enables the erasure bit, setting add_erasure_bit=True. At the extreme, confidence_ratio=np.inf keeps only syndromes with a single consistent observable flip, erasing every syndrome that has any competing flip.

Implementation notes.

  • Group probabilities are now accumulated in log-space (logaddexp) to avoid underflow when summing the tiny probabilities of individual errors.
  • Lookup-table construction was factored into two helper methods (_build_syndrome_map_from_errors / _build_syndrome_map_from_observable_flips).
  • Fixes a latent KeyError for syndromes whose only consistent errors have zero probability, and rejects negative/NaN ratios.

perlinm and others added 7 commits July 29, 2026 16:53
Let the LookupDecoder declare erasure when no observable flip is
sufficiently more likely than the alternatives, via a new
confidence_ratio parameter.  Accumulate group probabilities in log-space
to avoid underflow, and factor lookup-table construction into two helper
methods.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Instead of storing a best-guess flip and flipping the erasure bit, omit
ambiguous syndromes from the lookup table so they decode to erasure via
default_correction, exactly like a syndrome that was never enumerated.
A positive confidence_ratio now auto-enables the erasure bit (and
conflicts with add_erasure_bit=False) rather than requiring the caller
to set it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@perlinm
perlinm merged commit 7da5683 into main Jul 30, 2026
3 checks passed
@perlinm
perlinm deleted the lut branch July 30, 2026 02:05
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.

1 participant