Repository navigation
[Perf] [AMD] dsv41: Skip unneeded layer 20 computation under decoder-bounded-replay - #45339
Merged
Merged
Conversation
1am9trash
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
October 20, 2026 06:40
1am9trash
marked this pull request as draft
October 20, 2026 06:40
1am9trash
marked this pull request as ready for review
October 20, 2026 08:07
At1a8
added a commit
to At1a8/sglang
that referenced
this pull request
Oct 20, 2026
Resolve the conflicts with sgl-project#45339 in deepseek_v4_backend_hip_radix.py: keep main's tail entry (the source layer runs inside the tail after write_tail_source_kv) and add the CP metadata / DP buffer switch on top of it. The HIP CP low-ratio sources take q_lora rows only for the indexer, since write_tail_source_kv runs the compressor alone with q_lora=None.
4 of 5 tasks
This was referenced Oct 21, 2026
4 of 5 tasks
Open
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
With
--enable-decoder-swa-bounded-replay, DeepSeek-V4.1's decoder layers only process the last 128 prompt tokens of each request during prefill. Layer 20 (the first decoder layer) still has to write the KV cache for every token, but it does not need to run the indexer, attention, and MoE on all of them. Currently, The amd code path still runs all of layer 20 on every token.Nv enabled the skip in #42901. Amd was left out because its fused layer path runs the whole layer 20 in one call, so the KV write could not be split from the rest of the layer.
This PR enables it on amd. Layer 20 writes the KV cache for every token first, then runs the rest of the layer on the last 128 tokens only.
Modifications
No change on nv. All changes are in
deepseek_v4_backend_hip_radix.pyor under_is_hip.deepseek_v4.pytail_writes_source_kvtoTrueon amd, so the tail starts at layer 20 instead of layer 21.fused_boundary_attn_input.deepseek_v4_platform_stage.pyfused_boundary_attn_input, which runs that pending mHC post and builds layer 20's attention input for every token.deepseek_v4_backend_hip_radix.pyDeepseekV4AttnBackend.write_tail_source_kvto write layer 20's KV cache for every token.Accuracy Tests
Server cmd:
Speed Tests and Profiling
Follow SA MI355 tp2 setting:
Time spent in layer 20 for one 16K-token prefill chunk:
TTFT:
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #39402793949
Latest PR Test (Extra): ❌ Run #39402793760
Latest PR Test (AMD ROCm 10): ⏳ Run #39402793786