Repository navigation
Conversation
Co-authored-by: Zihan Zhang <tiancaizhangdaxian@sjtu.edu.cn>
jianc99
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
Qiaolin-Yu,
Ying1123,
celve,
hnyls2002,
merrymercy and
yuan-luo
as code owners
October 24, 2026 00:14
This was referenced Oct 24, 2026
This branch has not been deployed
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.
This is component 3 of the DFlash adaptive-verification series. Original implementation and component-only review: jianc99#3. Integration and full-system results: #46182.
Updated onto upstream
main(6a319e7). All applicable pre-commit checks passed on this branch. The GPU tests and benchmark results below were run previously on the original source branch; they have not been rerun after this upstream update. Submission preparation used AI assistance.Problem
DFLASH (selector and plain drafts), DSPARK, UNO dense verification and sampling-mask capture build their sampled-verify target distribution in
build_speculative_verify_target_probs(srt/speculative/dflash_utils.py). EAGLE-family, standalone and n-gram verify build their own and are unchanged.The function divided the whole
[rows, vocab]logits matrix by the temperature, then rantorch.topkover the result. With Qwen3.8's 248,320-token vocabulary on GB300 this costs:[rows, vocab]fp32 temporary.Fix
sglang.kernels.ops.sampling.topk.radix_topk. It is resolved once per platform, like the renorm ops:torch.topk.build_speculative_verify_target_probsselects the top-k on the raw logits and divides only the k selected values by the temperature. Dividing by a positive temperature keeps the order of the logits, so the probabilities stay the same.srt/models/dflash.pyhad a private copy of the same FlashInfer call. It now uses the shared op.Ties: when several logits tie at a row's top-k boundary, which of them keep the probability is deterministic for a given batch, but it may differ from
torch.topk's choice, and it can change with the number of rows, because the row count selects FlashInfer's kernel path. The number of kept tokens and the probability values are the same. As withtorch.topk, ranks that see the same logits select the same ids.Effect
Microbenchmark, GB300: vocab 248,320, top_k 20, top_p 0.95, temperature 1.
Below 128 rows the build is launch-bound, at about 0.5 ms both before and after.
End-to-end setup: Qwen3.8-27B with a DFlash2 draft (block 8), static DFLASH, TP1, GB300,
--max-running-requests 128, SPEED-Bench first turns, T=1 / top_p 0.95 / top_k 20, up to 4096 output tokens. The before and after runs were interleaved across two GPUs. Decode tok/s = per-request decode rate (output tokens after the first / time after the first token), times concurrency.Acceptance length is unchanged: 3.58-3.61 on both sides at c128. At c128 the running cap equals the concurrency, so about one request waits in the queue; #46182 shows that this setup reads 7-15% higher at that level than a larger cap, on both sides, so compare c128 only within this table. At 512 requests (TP4) the per-rank saving is about 11 ms per verify step, from the microbenchmark above.
Tests
test/registered/kernels/ops/sampling/test_verify_target_probs.py, which checks:torch.topkfallback.radix_topkagainsttorch.topkfor fp32 and bf16, contiguous and strided input, k up to 4096.Related upstream work
scaled_logits, the full[rows, vocab]temperature-scaled matrix that this PR removes: its CUDA helper sums overscaled_logits, and its seeded/non-CUDA path takes alogsumexpover it. Beyond the overlapping lines, whichever lands second should compute that sum from the raw logits with the temperature applied inside the reduction (its helper already takes atemperaturesargument for this) rather than bring the scaled copy back. With top-p set, that reduction is one more full-vocabulary pass per verify step.padding_verify_lensargument, one hunk away from this change; whichever lands second rebases.Notes
CI States
Latest PR Test (Base): ❌ Run #40044008844
Latest PR Test (Extra): ❌ Run #40044008811
Latest PR Test (AMD ROCm 10): ❌ Run #40044008869