Repository navigation
[AMD] [Fix] Fix --attention-backend triton work for DeepSeek MLA on MI355 (null-K + decode dispatch + RoPE) - #30355
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
…ll-k GPU fault DeepSeek MLA models segfault with --attention-backend triton on gfx95 when SGLANG_USE_AITER=1. In forward_absorb_core, triton is not in FORWARD_ABSORB_CORE_ATTENTION_BACKENDS so it falls into the else branch, which was gated only on _use_aiter_gfx95 (env + gfx95, not the attention backend). That takes the aiter-fused fused_qk_rope_cat_and_cache_mla path, which writes K into the KV cache and returns an empty k (numel=0, null ptr) for the aiter kernel to read from the buffer. Triton's extend kernel instead reads k directly and dereferences the null pointer -> Memory access fault on address (nil). Gate the fused path on the attention backend not being triton so triton builds a real k via torch.cat with save_kv_cache=True. Also allow triton through the rope-in-prepare condition, otherwise gfx95+aiter defers rope to the fused op and triton's cat path would receive an unrotated k.
…on MLA is correct on gfx95
415807c to
16fc178
Compare
|
@amd-bot ci-status |
CI Status for PR #30355Merge verdict: Caution This PR's changed code is not exercised by any PR-CI test that ran. The diff is gated entirely on Changed files: Executed CI failure attribution: AMD: 0 executed test failures (stage-a ✅; stage-b/c skipped — see caution) · Others: 7 failures (0 related). Remaining red X's are fast-fail/finish/gate cascade jobs, not independent failures. Other Executed Failures
Details / what to do before merge
Generated by amd-bot using Claude Code CLI |
All pass. |
…MLA (not aiter fused-RoPE)
cc0876d to
625cca2
Compare
|
@HaiShaw CI completed, ready to merge. |
…I355 (null-K + decode dispatch + RoPE) (sgl-project#30355)
Motivation
DeepSeek MLA models could not run with
--attention-backend tritonon gfx95 (MI300/MI355) whenSGLANG_USE_AITER=1(the ROCm image default). Triton is the common NVIDIA/AMD path and should not GPU-fault or produce wrong output on a valid backend selection.Root cause is a recurring anti-pattern: several gfx95/aiter fused MLA paths are gated on env vars (
SGLANG_USE_AITER,SGLANG_ROCM_FUSED_DECODE_MLA) or on "not in the absorb-core backend list", not on the actually selected attention backend. As a result the triton backend inherits aiter-only fused paths that it cannot consume:forward_absorb_core, triton fell into the aiter-fusedfused_qk_rope_cat_and_cache_mlapath, which writes K into the KV cache and returns an emptyk(numel=0, null ptr) for the aiter kernel to read from the buffer. Triton's extend kernel readskdirectly →Memory access fault on address (nil)._dispatch_mla_subtypehonoredSGLANG_ROCM_FUSED_DECODE_MLA=1for any backend, routing triton decode toMLA_FUSED_ROPE_ROCM(forward_absorb_fused_mla_rope_prepare), which is neither MXFP4-aware (bmmsees packedw_kc, 64 vs 128) nor triton-metadata-compatible (ForwardMetadataunpack)._skip_rope_for_aiter_fused_mlareturned True for triton (backend not in the absorb-core list), so RoPE was silently skipped in prepare while triton took the standard cat path → garbage output.Modifications
forward_mla.py:forward_absorb_core: gate the aiter-fused path toself.current_attention_backend == "aiter"so triton builds a realk = torch.cat([k_nope, k_pe])withsave_kv_cache=True.or self.current_attention_backend == "triton")._skip_rope_for_aiter_fused_mla: restrict to== "aiter"so triton applies RoPE in prepare (the 0.03 → 0.945 fix).attention_backend_handler.py:_dispatch_mla_subtype: gateMLA_FUSED_ROPE_ROCMoncurrent_attention_backend == "aiter"so triton (and other backends) decode via the standardMLApath.All changes are backend-scoped; aiter/fa3/flashinfer/CUDA paths are unchanged.
Accuracy Tests
DeepSeek-R1-MXFP4 (Quark MXFP4), MI355X gfx950, tp4,
--kv-cache-dtype fp8_e4m3, gsm8k (200q):--attention-backend tritonnow runs DeepSeek-R1-MXFP4 end-to-end with correct output.Scope / Known Limitation
This PR makes triton MLA correct for non-speculative decode.
--attention-backend triton+ EAGLE speculative decoding is still broken (GPU fault in the NextN draft/verify path, independent of cuda graph) and is out of scope here — that is a separate draft-path bug. For DeepSeek MLA with speculative decoding, continue using--attention-backend aiter(fully working, 0.955).Checklist
[Tag] Descriptioncommit/PR convention.CI States
Latest PR Test (Base): ❌ Run #29228875042
Latest PR Test (Extra): ❌ Run #29228874957