Repository navigation
[AMD] Skip full-vocab softmax in EAGLE topk==1 draft on ROCm - #35872
Merged
Merged
Conversation
yichiche
requested review from
Qiaolin-Yu,
Ying1123,
hnyls2002 and
merrymercy
as code owners
August 21, 2026 14:32
yichiche
force-pushed
the
amd/spec-topk1-argmax-rocm
branch
4 times, most recently
from
August 21, 2026 16:21
aefd4de to
814df22
Compare
yichiche
force-pushed
the
amd/spec-topk1-argmax-rocm
branch
2 times, most recently
from
August 24, 2026 07:08
1f8c707 to
443fb7f
Compare
yichiche
commented
Aug 24, 2026
yichiche
force-pushed
the
amd/spec-topk1-argmax-rocm
branch
from
August 25, 2026 03:20
443fb7f to
abfb11a
Compare
Avoid AITER's unmasked vector tail while keeping ROCm draft selection softmax-free and fusing position and token updates. Co-authored-by: Cursor <[email protected]>
chuyeh
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
August 28, 2026 13:43
chuyeh
added a commit
to chuyeh/sglang
that referenced
this pull request
Aug 28, 2026
Move the independent ROCm top-k1 selector work to sgl-project#35872 so this PR only projects selected draft-extend rows through the LM head. Co-authored-by: Cursor <[email protected]>
4 tasks done
Co-authored-by: Cursor <[email protected]>
Share the draft-forward Triton branch across CUDA and HIP while documenting why draft-extend requires optional position advancement and separate platform routing. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Use a draft-extend-only wrapper with discarded scratch positions instead of making the upstream position parameter optional. Co-authored-by: Cursor <[email protected]>
Resolve the EAGLE worker import conflict while retaining both the new pipeline-parallel helper and the draft-extend top-k1 wrapper. Co-authored-by: Cursor <[email protected]>
…ax-rocm Keep both the ROCm top-k1 argmax import and the GLM-5.3 DSA topk-width helper. Co-authored-by: Cursor <[email protected]>
Contributor
|
/rerun-failed-ci |
The test is a CUDA wall-clock check, not a kernel unit test. kernel-unit's fork-worker batch leaves CUDA initialized across forks, so StageProfiler sync flakes and fails required pr-test-finish on unrelated PRs. Co-authored-by: Cursor <[email protected]>
…nit" This reverts commit 0701988.
1am9trash
approved these changes
Sep 11, 2026
1am9trash
left a comment
Collaborator
There was a problem hiding this comment.
A clean softmax skip on amd side.
Impact on all topk==1 mtp cases.
sogalin
approved these changes
Sep 11, 2026
4 of 5 tasks
2 tasks done
tanguofu
pushed a commit
to tanguofu/sglang
that referenced
this pull request
Oct 12, 2026
…fusion Two upstream fixes that our decode path provably hits: 1. sgl-project#35872 (790551c) - skip the full-vocab softmax in the EAGLE topk==1 draft on ROCm. Live decode runs speculative_algorithm=EAGLE with eagle_topk=1 and steps=2 on EAGLEWorkerV2, so every draft step went through renorm_draft_probs + fast_topk over the whole vocabulary. The decode profile measures that softmax at 3.4% and the argmax reduce at 2.9% of decode kernel time. ROCm previously fell through to the generic topk path because of sgl-project#26358 (torch.argmax tie-break on FP8 logits). This uses the triton draft_topk1_postprocess kernel instead of torch.argmax, so the tie-break concern does not apply. A scratch positions buffer absorbs the position advance that draft-extend has already consumed. 2. sgl-project#41258 (db32673) - let the GLM DSA NextN draft declare its own shared-expert fusion architecture. ModelConfig rewrites a GLM draft's architecture to GlmMoeDsaForCausalLMNextN, so the inherited DeepSeek name never matched the gate and the draft's shared expert was never fused into fMoE, costing an extra GEMM per draft step. Measured at 1.1% of decode kernel time (_fused_append_shared_experts_kernel). Only the architecture declaration is ported. The upstream commit's second hunk depends on should_apply_glm_nextn_moe_ptpc, which this tree does not have. Deliberately not included: sgl-project#42982 (FP8 KV saturation). It has no throughput benefit, it changes the values written into the KV cache, and therefore forces the whole rollout into the "changes KV encoding" risk class. It should ship on its own with its own correctness run. Assisted-by: Hy4 preview via CodeBuddy Code
tanguofu
pushed a commit
to tanguofu/sglang
that referenced
this pull request
Oct 15, 2026
…ect#43640) Follow-up to sgl-project#35872, which we already ported. Once the HIP draft path uses the triton topk-1 kernel, the preallocated parent chain can be materialised directly by that kernel instead of assembling the draft tokens with a final cat per step. Two lines: widen the `_is_cuda` gate to `_is_cuda or _is_hip`. Upstream spells the last condition `needs_draft_probs`; this tree uses `get_spec().speculative_use_rejection_sampling`, which is the same check under a different name, so only the platform gate is changed. Not yet built or rolled out. Assisted-by: Hy4 preview via CodeBuddy Code
5 tasks
5 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.
Motivation
EAGLE
topk=1only needs the largest-logit token. For finite logits, a full-vocabulary softmax cannot change the argmax and is redundant. AITERgreedy_samplehas an unmasked vector-tail correctness issue; on MI355X it returned an out-of-vocabulary index for vocabulary size 151,666. SGLang’s existing Triton split-argmax masks offsets>= vocab_sizeand safely handles NaNs.Changes
topk=1in both draft-decode and draft-extend.-inf, and all-negative logits.topk > 1, and all non-ROCm paths unchanged.Correctness
test_spec_topk1.py: 6 passed, 12 subtests passedtest_eagle_worker_v2_topk1_fastpath.py: 9 passed, 7 subtests passed[0, vocab_size)for vocabulary sizes 151,666 and 248,320.Performance
All deltas compare Triton against the same baseline, the existing full-softmax selector.
Qwen3.5-397B-A17B-MXFP4
2× MI355X per arm, TP2,
rocm/sgl-dev:v0.5.18-rocm724-mi35x-20260825, ISL 8192 / OSL 1024, random-range ratio 0.8, EAGLE 3/1/4, AITER unified attention, FP8 E4M3 KV.Six-point medians: throughput +1.08%, TPOT −1.03%. Qwen provides measurable end-to-end evidence, with lower median E2E at five of six points.
TP4 Follow-up: C4/C8/C16
Hardware: 4× MI355X, TP4. Image:
rocm/sgl-dev:v0.5.18-rocm724-mi35x-20260825.Qwen3.5-397B-A17B-MXFP4
ISL 8192 / OSL 1024, EAGLE 3/1/4, AITER unified attention, and FP8 E4M3 KV.
Three-point medians: throughput −0.16%, TPOT −1.74%, median E2E −1.01%. Throughput is neutral while decode latency improves consistently.
MiniMax-M3 428B MXFP8
ISL 8192 / OSL 1024, EAGLE3 3/1/4, Triton target/draft attention, and FP8 E4M3 KV.
Both arms include compatibility commit
2e3ee8aa8from draft #35889; only the full-softmax versus current #35872 scratch-wrapper selector differs.Three-point medians: throughput +0.57%, TPOT −0.69%, median E2E +0.46%. Throughput improves at every point; C16 retains a localized latency regression.
MiniMax-M3 428B MXFP8
2× MI355X, TP2,
rocm/sgl-dev:v0.5.18-rocm724-mi35x-20260825, ISL 8192 / OSL 1024, random-range ratio 0.8, EAGLE3 3/1/4, Triton target/draft attention, and FP8 E4M3 KV.Both arms used compatibility commit
2e3ee8aa8from draft #35889, because current upstream is blocked by #33383. Only the full-softmax versus Triton selector differed.Six-point medians: throughput +0.40%, TPOT −0.57%, median E2E −0.64%. Overall performance is neutral to slightly positive, although C16 retains a localized regression.
Conclusion
This removes a redundant full-vocabulary softmax from ROCm EAGLE
topk=1while using a vocabulary-masked selector with generic correctness and safety benefits. Qwen shows a measurable improvement, while MiniMax confirms no regression within variance. The optimization applies to supported ROCm EAGLE/MTP models without introducing model-specific behavior.Checklist
-inf, and all-negative logits covered.topk > 1, and non-ROCm behavior unchanged.CI States
Latest PR Test (Base): ✅ Run #35552861209
Latest PR Test (Extra): ❌ Run #35552861101
Latest PR Test (AMD ROCm 10): ❌ Run #35552861347