Repository navigation
[ROCm][Perf] Optimize sparse attention prefill kernel for DeepSeek-V4 - #48519
Merged
simon-mo merged 3 commits intoJul 16, 2026
Merged
Conversation
Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com>
tjtanaa
approved these changes
Jul 13, 2026
tjtanaa
left a comment
Member
There was a problem hiding this comment.
LGTM. Thanks for optimizing it.
michael-gpu
pushed a commit
to practical-inference/vllm-ampere-extended
that referenced
this pull request
Oct 20, 2026
…vllm-project#48519) Signed-off-by: kliuae <kuanfu.liu@embeddedllm.com> Co-authored-by: TJian <tunjian.tan@embeddedllm.com>
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.
Purpose
This PR optimizes DeepSeek-V4's dedicated sparse attention ragged prefill kernel in ROCm. The optimization speeds up the kernel by ~2x, and in E2E benchmark reduces TTFT by ~10%.
In the current upstream ROCm path, this kernel has some slight inefficiencies that can be optimized. Specifically, this PR addresses three points of optimization.
num_warpssetting. In DSv4-Pro's architecture, the per-workgroup tile under TP8 is[BLOCK_H=16, 512]and reduces to[16, 16]. Settingnum_warpssplits the K dimension, however, splitting it as high as 8 gives larger cross-wave reduction and more barriers for LDS reads/writes. Therefore, this PR setsnum_warps=4instead to lower this overhead.kvis loaded with valid regions masked, and immediately after masked with the same predicate. The later mask should be redundant as thekvelements are already0.0where masks areFalseat loading. This redundant masking also inserts a mask op right between the load-MFMA ordering, preventing the kernel from benefiting from software pipelining.All these optimization combined, for DeepSeek-V4-Pro's running shapes, the kernel achieves ~2x speed up compared with the current upstream baseline.
Kernel latency under
num_heads=16,head_dim=512(DSv4-Pro TP8)Test Plan
lm_evalwith gsm8k and performance benchmark on MI355Server command
Performance benchmark
lm_eval
Test Result
deepseek-ai/DeepSeek-V4-Pro gsm8k PR
deepseek-ai/DeepSeek-V4-Pro E2E performance benchmark
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.