[ROCm][Perf] Fuse SWA q/kv RMSNorm and q FP8 group quant for DeepSeek-V4 - #53540
Conversation
|
@shen-shanshan can you attach some perf figures ? Thank you. |
| @@ -945,3 +982,22 @@ def wq_b_and_q_quant(): | |||
| else: | |||
| q, q_scale = q_quant, None | |||
| return q, q_scale, weights | |||
|
|
|||
| def _wq_b_proj( | |||
There was a problem hiding this comment.
This function seems to be duplicated.
There was a problem hiding this comment.
This function seems to be duplicated.
There are two _wq_b_proj methods (wq_b in SWA and wq_b in indexer). We should skip the quant process in the both linear layers when using this fused kernel.
There was a problem hiding this comment.
@tjtanaa I have also attached the profile traces before and after this PR, which could make it easier to understand. 😊
Yeah, I have updated the benchmark results just now. |
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com>
479de2f to
ec9d705
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #85760 for commit |
|
/ci run |
|
✅ Triggered Buildkite CI #85791 for commit |
Rebased onto main after vllm-project#53540 landed the fused_mla_dual_rms_norm_group_quant custom op. The op registration this PR previously carried is dropped; only the accessor the pattern matcher needs is added here. Adds MLADualRMSGroupQuantPattern, the group-quant sibling of the existing MLADualRMSPerTokenQuantPattern, so the MLA FP8 path picks up the fused AITER kernel through the compile pass rather than a hand-wired call site -- covering DeepSeek-R1 / MLA, which vllm-project#53540 does not touch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Andy Friedrich <afriedri@amd.com>
…-V4 (vllm-project#53540) Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com>
…-V4 (vllm-project#53540) Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com> Signed-off-by: mikeshawcode <michaelwshaw2@gmail.com>
…-V4 (vllm-project#53540) Signed-off-by: Shanshan Shen <87969357+shen-shanshan@users.noreply.github.com>
Purpose
On the ROCm path of DeepSeek-V4, every decode step's SWA token-insertion pipeline runs:
fused_q_kv_rmsnorm(norms the q-lora and kv latents to bf16).wq_bGEMM).wq_b, which shares the q-lora with the attention layer.This PR replaces 1+2 with a single aiter HIP kernel (
fused_qk_rmsnorm_group_quant): it RMSNorms both latents (fp32 accumulate) and quantizes the q latent (per-1x128, fp32 scales) in one pass, so:wq_band the indexerwq_bboth consume the pre-quantized(qr_fp8, qr_scale)pair and skip their own input quant (removes a third quant launch on the long-context path).fused_deepseek_v4_qnorm_rope_kv_rope_quant_insert) unchanged.Note
The change is scoped to the ROCm/AITER path and does not change the CUDA or XPU implementations.
Before fusing (4µs 839ns + 4µs 719ns + 4µs 719ns = 14 µs 277 ns):
After fusing (4µs 919ns, 2.90x faster):
Test Plan
8k1kworkload.gsm8kdataset.Test Result
Note
The tests below are executed on AMD MI350X GPU, so the performance could be slightly lower than the MI355X baseline, so I verified this PR with an A/B test compared with vLLM
mainon the same machine.Benchmark
Accuracy Test
Full GSM8K evaluation on this change (1,319 examples):
Both results exceed the required 94% threshold.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.