Repository navigation
Conversation
This was referenced Oct 28, 2026
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.
Result
A finite fair-bit cap cannot implement exactly unbiased stochastic rounding of a non-dyadic rational value. For a reduced odd-denominator probability$a/b$ , with $N=2^R$ available fair-bit strings and $r$ the remainder of $aN$ divided by $b$ , the sharp bias and exact-accepted-law abort bounds are
An exact standalone sampler attains the optimal expected draw count two, but its worst-case draw count is unbounded. Truncating that binary-comparison sampler and retrying unfinished paths preserves the desired law only when$b$ divides $2^R-1$ . At four bits the desired probability 1/13 becomes 1/15. Correct exact conditional sampling instead needs abort probability at least 3/16.
Significance for researchers
The proposed stochastic extension of the denominator-13 inverse in PR #5069 and its retained PR #5037 kernel must choose and pay for bias, explicit failure or unbounded stopping. The finite dyadic sampler from Nick Petalas's PR #6026 and the coupled inverse ABI in PR #6066 cannot simply be transferred to that coefficient domain. Expected two draws cannot serve as a deterministic worst-case tariff.
The deterministic predecessor does not claim this stochastic substitution; no source defect is alleged. The calibration is a rational sampling law, not a proof that every actual service operand reaches every residue. This provides no new inverse implementation, native caller, precision saving or κ.
Validation
CPython 3.12.8 normal and optimized registered replays pass 2,332 exhaustive finite-bit cases, 37,584 accepted/failure/abort count triples, 82 exact comparison trees and 20,992 literal tapes, plus the cap/retry congruence, denominator-13 table and semantic rejection controls. All arithmetic is exact; no Monte Carlo or floating point is used. The written counting and stopping-time arguments supply the uniform theorem. Committed bytes pass.
The optional full-history preflight is unavailable in this shallow checkout; pins use the reachable base. The navigation-only repair from PR #6050 is included. Frozen sources and the selected record stay unchanged; no selected or native cold replay or independent human/formal-kernel review is claimed.
Fresh read-only Git-free export replay also passes at head
689e28282fd5259dec7f75b83904617dab2d7b3a, under optimized isolated CPython with empty PATH/PYTHONPATH; exported file hashes remain unchanged. The package’s hosted scientific replay and planning job pass at this head. Three other replay jobs report archived-source pin drift after the included navigation repair; those frozen packages are unchanged. The canonical investigation and remaining obligations are in Discussion #6073.Open next questions
Determine whether the sharp bounded bias fits one actual caller's reached residues and full suffix error budget. Alternatively, host the exact variable-time comparison loop with a retained tape, stopping record, reversible cleanup and complete runtime/stock ledger. A persistent entropy reservoir is a changed contract; no batch-amortized randomness lower bound is claimed.
Prepared by zxv with substantial OpenAI Codex assistance. JoyboyBrian's inverse lineage, Nick Petalas's dyadic stochastic context and their attribution remain intact. Probability counting and binary comparison are classical; the contribution is the source-relative sharp resource decision and failed capped-retry substitution.