[AMD] Fix deepseek-v4 mtp accept length issue - #28520
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the DeepSeek-V4 attention backend (deepseek_v4_backend_hip_radix.py) to bypass cached swa_loc and recompute it from live per-step positions during multi-step draft decoding, preventing ring slot reuse issues. It also introduces a new integration test suite (test_deepseek_v4_pro_fp4_mtp.py) for validating DeepSeek-V4-Pro FP4 with MTP on AMD MI35x GPUs. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/tag-and-rerun-ci |
Co-authored-by: Bingxu Chen <bingxche@amd.com>
Co-authored-by: Bingxu Chen <bingxche@amd.com>
Co-authored-by: @bingxche
Waiting CI checking by Bingxche help: https://github.com/sgl-project/sglang/actions/runs/27679583497/job/81863337423
Motivation
On DeepSeek-V4 with MTP enabled, the
unified_kv_tritonattention backend reaches an average accept length of only ~2.17, while thetritonbackend reaches ~3.04. Accuracy is unaffected, but the lower accept length significantly hurts decode throughput.Per-position acceptance rate shows the draft chain collapsing from token 2 onward on
unified_kv_triton.Modifications
python/sglang/srt/layers/attention/deepseek_v4_backend_hip_radix.pyswa_loc) is precomputed once per forward. This path never accounted for multi-step draft decode: across draft steps the positions advance, but the cachedswa_locdoes not, so every draft step writes its KV to the same ring slot. Later steps overwrite the KV that earlier draft tokens produced, breaking the draft chain at depth >= 2 and collapsing accept length.get_unified_swa_loc, detect multi-step draft decode and recompute the ring slot from the live per-step positions. It only triggers on draft layers, so the overhead is negligible.test/registered/amd/test_deepseek_v4_pro_fp4_mtp.pyAccuracy Tests
Local run new CI task command:
Both accept length and accuracy check passed.
Speed Tests and Profiling
conc16, 8k1k:
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #27682217928
Latest PR Test (Extra): ❌ Run #27682217663