Repository navigation
[AMD] Use the preallocated EAGLE topk=1 draft chain on HIP - #43640
Merged
BBuf merged 4 commits intoOct 14, 2026
Merged
Conversation
xiaofei-zheng
requested review from
Qiaolin-Yu,
Ying1123,
hnyls2002 and
merrymercy
as code owners
October 11, 2026 03:51
Contributor
Author
|
@hnyls2002 @Qiaolin-Yu @merrymercy could you add |
BBuf
reviewed
Oct 13, 2026
| self.assertTrue(fast_parent.is_contiguous()) | ||
| self.assertTrue(fast_index.is_contiguous()) | ||
|
|
||
| @unittest.skipUnless( |
Collaborator
There was a problem hiding this comment.
The pr's change is small and safe, we don't need to add this test. Can you delete it?
Contributor
Author
There was a problem hiding this comment.
Thanks for removing it in 5021a17. The PR is now just the gate change, and I updated the description to match. That push needs one more approval under the repo rules. Could you re-approve and merge once CI is green? Thanks!
BBuf
approved these changes
Oct 13, 2026
This was referenced Oct 14, 2026
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
tanguofu
pushed a commit
to tanguofu/sglang
that referenced
this pull request
Oct 15, 2026
…gl-project#43640)" This reverts commit bc05e8b.
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
EagleDraftWorker.draft_forwardwrites the topk=1 draft chain straight into the preallocated parents/indices buffers only when_is_cuda. HIP already runs the Tritondraft_topk1_postprocesskernel that fills those columns (#35872), but the gate still sends it through the token-list path: the eager_select_top_k_tokens_first(withrepeat_interleave) on step 0, the compiled_select_top_k_tokens_lateron each later step, and a finalcat.Modifications
_is_cuda or _is_hip. The other conditions (topk 1, batch fits the buffers, nohot_token_id, no draft probs) are unchanged, so EAGLE3 token maps and non-greedy batches under rejection sampling keep the token-list path.Accuracy Tests
Bit-exact: the same Triton argmax runs per step and the chain buffers hold what the
catpath builds. On MI355X,test_eagle_worker_v2_topk1_fastpath.pypasses 11 tests and 7 subtests, andtest_spec_topk1.pypasses 6 tests and 12 subtests. A draft-forward probe at GLM-5.3 shapes (vocab 154880, hidden 6144, 5 steps) givestorch.equaloutputs at bs 1-64.Speed Tests and Profiling
Same probe with the draft model stubbed out, so only the draft glue is measured. Kernels per draft cycle drop from 27 to 9 at every batch size. HIP-graph replay per cycle (min of 5 x 200 replays):
That is about 0.25-0.3% of a GLM-5.3 TP4 decode cycle (~12 ms), too small to resolve end to end.
Checklist
CI States
Latest PR Test (Base): ⏳ Run #38503216059
Latest PR Test (Extra): ❌ Run #38503216047
Latest PR Test (AMD ROCm 10): ⏳ Run #38503216074