Repository navigation
SWF(bug): keep top-n-sigma working with masked logits - #75
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
4 of 6 tasks
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.
Summary
One masked
-inflogit (grammar/tool-call masks, banned tokens) made top-n-sigma's mean and σ NaN, so thesigma > 0.0guard silently switched the filter off and low logits got sampled again. The filter now computes mean/σ over finite logits only (f64 accumulation, Atlas's existingmean − nσcutoff kept), and the split verification path keeps matching the full-row result.Root cause —
crates/spark-runtime/src/sampler/sample_impl.rs:sumover the row included-inf, somean = -inf,var = NaN,sigma = NaN, andNaN > 0.0is false → no filtering.crates/spark-runtime/src/sampler/absent.rsmirrored that by skipping its survivor check whenever a present token was masked, so it could accept a pick the (fixed) full row would reject.Fix
sample_impl.rs: statistics over finite logits only; no filtering with ≤1 finite logit.absent.rs: always applies the Cantelli survivor bound when top-n-sigma is on, using the known finite candidates (a conservative lower bound on the full row's finite count; the max always survives). When parity can't be proven it returnsNone, triggering the existing full-row fallback. Dropped the now-unusedvocabparameter ofsample_with_absentand updated callers.Test plan
Failing before the fix (regression tests on unfixed code):
Passing after, on current
main(includes #69's tiny-temperature fix),ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime:spark-model / spark-server split-verification tests also pass.
Try it:
ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime top_n_sigma_with_masked_logitscargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --testsbash scripts/check-license-headers.sh(4268 valid, 0 invalid)typosNotes for reviewers
mean − nσcutoff (the paper usesmax − nσ); unchanged here.sample_impl.rsis 499 lines (cap 500).CLA
Implemented in session Keep top-n-sigma sampling working with masked tokens
Review with Devin · Open in Devin Desktop