Repository navigation
[Fix] Keep speculative chain samples on positive support - #35
Open
rchalamala wants to merge 1 commit into
Open
rchalamala wants to merge 1 commit into
rchalamala wants to merge 1 commit into
Conversation
Mask zero-mass and padded CDF lanes. If endpoint rounding leaves a finite positive distribution without a match, select its last positive token. Keep malformed inputs outside the supported sampling contract. Add analytic synthetic regressions for endpoint gaps, zero tails, partial blocks, uniform boundaries, tiny mass, malformed no-match inputs, and graph replay.
rchalamala
marked this pull request as ready for review
September 25, 2026 07:28
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Motivation
The chain sampler's reduction and prefix scan can round differently near the upper CDF endpoint. A valid draw can then select a zero-mass tail or fall through to the final vocabulary token.
Modifications
Require CDF candidates to have positive mass and lie within the vocabulary, and find the first candidate with one minimum-index reduction. If no candidate matches, use the last positive token only when the target probabilities are finite and nonnegative, the sampling mass is finite and positive, and the final uniform is in
[0, 1). The extra validation scan runs only on this fallback path.Malformed distributions, zero residual mass, and invalid uniforms remain unsupported inputs; this change does not introduce an error signal for callers.
Accuracy Tests
Speed Tests and Profiling
Matched synthetic float32 B300 CUDA-graph timings use batches of 1 and 8, target/all-correct/rejection paths, dense/sparse finite probabilities, alternating baseline/treatment order, repeated samples, and baseline/baseline null controls. Across 72 ordinary cases covering both source comparisons, none exceeds the 5% regression threshold. Per-case median CUDA latency changes are:
Deliberately forced endpoint fallback costs 13.33–18.93 microseconds for this change across six cases. The release takes 6.48–10.32 microseconds while returning zero-mass tokens in those cases, so that comparison is not between correct samplers. These are operator measurements, not serving latency or throughput; no model or serving benchmark is claimed.
Checklist
CI States
Latest PR Test (Base): ❌ Run #36106412981
Latest PR Test (Extra): ❌ Run #36106412632
Latest PR Test (AMD ROCm 10): ❌ Run #36106412883