Repository navigation
Conversation
ormandj
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
Qiaolin-Yu,
Ying1123,
celve,
hnyls2002,
merrymercy and
yuan-luo
as code owners
October 9, 2026 12:35
17 of 56 tasks
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 20, 2026
… correctness) - core batch [10-15]: sgl-project#43376 long-ctx indexer OOM bound, sgl-project#42368 FlashInfer-0.7 decode dispatch, sgl-project#39914 extra-KV 64-token page split + candidate fallback, sgl-project#42714 graph-safe page-split buffers, sgl-project#32464 SM120 sparse-prefill test gate, sgl-project#34027 int32->int64 page-split overflow guard. - Group C [16-23]: sgl-project#42717 TP-rank verify-budget, sgl-project#43225/sgl-project#43374 compact-verify seq_lens + padding renorm, sgl-project#42718 packed-verify token->request map, sgl-project#42713 forced-uniform capture metadata, sgl-project#45301 padded-query graph lifetime, sgl-project#44141 bounded-replay guard, sgl-project#45185 V4.1-Flash-1017 FP8 QDQ (env-gated, default OFF). sgl-project#42710 skipped (superseded upstream: step_logits already fp32).
This was referenced Oct 22, 2026
With compact verify, the strided target logits have zero-logit padding rows past each request's verify length. Without logit adjustments these rows are exactly uniform after softmax, the worst case for FlashInfer's radix top-p, and top-p renorm leaves them unchanged (it keeps every probability >= its threshold). In the dense top-p path, renorm only the verified rows (the kernel gets a copy of the request's last verified row in place of each padding row) and keep the padding rows' softmax. Only used in compact mode with no grammar and no logit adjustments; the strided logits and every other path are unchanged.
ormandj
force-pushed
the
dspark-verify-pad-last-row
branch
from
October 29, 2026 21:54
63db908 to
6e78b53
Compare
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.
Motivation
Compact verify scatters verified logits into a strided tensor and fills each request's unverified rows with zero logits. The resulting
[bs * verify_num_draft_tokens, vocab]logits are passed to acceptance. When a request samples with top-p, the accept path builds the target probabilities with softmax and FlashInfertop_p_renorm_probsover every row, padding included.Without logit adjustments, a padding row is exactly uniform after softmax. In FlashInfer's radix (AIR) top-p, every element of a uniform row falls into the same histogram bucket on every pass, and in the kernel microbenchmark below these rows make the call 3.5x to 12.5x slower than a copy of a verified row. The renorm also has no effect on such a row: FlashInfer keeps every probability >= the threshold it finds, which for a uniform row keeps every token, then divides by the row sum (1 up to rounding).
Modifications
build_speculative_verify_target_probsgets an optionalpadding_verify_lens. In the dense top-p branch (top-p only, no top-k) on CUDA, padding rows are not renormalized. A Triton kernel copies each request's last verified row into its padding rows in place, so the zero-logit padding rows no longer reach the top-p kernel, and a second pass writes the padding rows' saved uniform softmax value back into the output. Rows of requests without padding are not touched, and no extra[rows, vocab]buffer is allocated.verify_lensonly in compact mode, when the batch has no grammar andverify_logits_adjustments_are_noopholds (no logit bias, penalties or custom logit processor). Host-side lengths disable substitution for full-width batches; device-only layouts (built when the verify token count is rounded up to a captured CUDA-graph size) conservatively enable it. For a full-width device-only layout, the two kernels launch but leave every row untouched. In all other cases, and for all other callers, the code path is unchanged.Accuracy Tests
New CUDA test
test/registered/spec/dspark/test_dspark_compact_top_p.py. It uses a compact batch with verify lengths 6/3/1/4, per-request temperatures and top-p values, and verified rows on which top-p keeps two tokens and drops a third:correct_len, bonus,cap_trim_lens) are bit-identical to the full-renorm path over 4 seeds, and match the expected values for a rejection on an inner verified row, a rejection on the last verified row, and acceptance through the last verified row into the padding rows;python -m pytest test/registered/spec/dspark/test_dspark_compact_top_p.pyon one RTX PRO 6000 Blackwell (SM120): 4 passed, 2 subtests passed.test/registered/unit/kernels/test_kernels_namespace.py: 67 passed. On 2026-10-29 this was rebased onto main974831643f; the new head keeps the full renorm for batches whose logits watermarking forced, the CPU-runnabletest/registered/unit/kernels/test_kernels_namespace.pypasses on it (apart from one failure main has too), and the SM120 GPU results above are from the previous head and will be re-run.Speed Tests and Profiling
Kernel microbenchmark (RTX PRO 6000 Blackwell, SM120): FlashInfer
top_p_renorm_probson[rows, 129280]FP32 probabilities, top_p 0.95, half the rows padding, timed in a CUDA graph. "Copy of last row" is the kernel input this change produces.This times the top-p kernel only. The two added padding-row kernels, and end-to-end serving with this version, were not measured.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciDeveloped with AI assistance.
CI States
Latest PR Test (Base): ❌ Run #40961599764
Latest PR Test (Extra): ❌ Run #40961599687
Latest PR Test (AMD ROCm 10): ❌ Run #40961599658