Repository navigation
[AMD] Reuse KV gather indices across ASM context prefill layers - #39901
Merged
HaiShaw merged 5 commits intoSep 22, 2026
Merged
Conversation
zijiecode
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
September 17, 2026 04:53
yichiche
approved these changes
Sep 18, 2026
yichiche
left a comment
Collaborator
There was a problem hiding this comment.
Only affect AMD path. LGTM.
4 of 5 tasks
HaiShaw
reviewed
Sep 21, 2026
HaiShaw
reviewed
Sep 22, 2026
HaiShaw
approved these changes
Sep 22, 2026
This was referenced Sep 24, 2026
This was referenced Sep 26, 2026
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
The gfx950 ASM context-prefill path gathers paged K/V into contiguous buffers. It rebuilds the same gather indices at every full-attention layer, including four GPU synchronizations per call. In a TP2 trace, this takes about 35 ms of a 490 ms prefill chunk with 16k new tokens and 15 full-attention layers. This PR computes the indices once per batch and reuses them across layers.
Modifications
ForwardMetadata. Speculative batches and unsupported metadata use the existing helper and bounds checks.SGLANG_GFX_ASM_CTX_GATHER_CHECK=1to compare the reused indices with the original helper during validation.Each layer still gathers its own K/V data. The attention kernel is unchanged.
Accuracy Tests
amd/Qwen3.5-397B-A17B-MXFP4-AttnFP8-V2, TP2/C8, 5-shot GSM8K, chat-completions, 16384-token output budget, temperature 0, real MTP.Benchmarking and Profiling
amd/Qwen3.5-397B-A17B-MXFP4, MI355X, TP2/C32, HiCache, and MTP. Two 1200-second AgentX runs per configuration on the same GPU pair; the table shows arithmetic means of the per-run metrics.Checklist
CI States
Latest PR Test (Base): ⏳ Run #35750753383
Latest PR Test (Extra): ❌ Run #35750753270
Latest PR Test (AMD ROCm 10): ⏳ Run #35750753475