Skip to content

Fix float64 underflow in sinter.shot_error_rate_to_piece_error_rate - #1154

Open
madcpf wants to merge 1 commit into
quantumlib:mainfrom
madcpf:track-d/2026-12-04-sinter-piece-error-rate-underflow
Open

madcpf wants to merge 1 commit into
quantumlib:mainfrom
madcpf:track-d/2026-12-04-sinter-piece-error-rate-underflow

Conversation

@madcpf

@madcpf madcpf commented Dec 4, 2026

Copy link
Copy Markdown

Summary

Replace naive 1 - (1 - x)**a expressions in sinter.shot_error_rate_to_piece_error_rate with -math.expm1(math.log1p(-x) * a) and guard 0, 1, and shot_error_rate == 0.5 boundaries so small multi-observable error rates (e.g., shot_error_rate=1e-12, pieces=100000, values=2) no longer cancel or underflow to 0.0.

Fixes #1150

Verification

  • /usr/local/google/home/pengfeichen/quantum_oss/checks/check_stim.sh: pytest (--ignore plot/optional-decoder files, -k "not pymatching and not fusion_blossom and not mwpf") passed 166 passed, 51 deselected (Python 3.13.18 / Linux).
  • PYTHONPATH=glue/sample/src /usr/local/google/home/pengfeichen/quantum_oss/venvs/stim/bin/python dev/doctest_proper.py --module sinter passed (0 failures; updated the 3 docstring example literals that previously reflected float64 cancellation).

Use math.log1p and math.expm1 instead of naive 1 - (1 - x)**a so small multi-observable shot error rates do not cancel or underflow to zero.
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.

sinter rounds positive per-round error rates to zero for multiple observables

1 participant