[ROCm] Add Triton sparse-MLA prefill and decode for gfx950 - #38601
Open
fanxingran wants to merge 1 commit into
Open
fanxingran wants to merge 1 commit into
fanxingran wants to merge 1 commit into
Conversation
Wire --dsa-prefill-backend triton and --dsa-decode-backend triton on gfx950 with fp8 KV. Prefill uses a fused Triton kernel with XCD swizzle and 64-bit KV offsets; decode adds a separate Triton path for MTP-shaped forwards. Shape-gate misses fall back to TileLang.
fanxingran
requested review from
BBuf,
DarkSharpness,
Fridge003,
HaiShaw,
HydraQYH,
Qiaolin-Yu,
Ying1123,
alphabetc1,
celve,
ch-wan,
fzyzcjy,
hanming-lu,
hebiao064,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
xiezhq-hermann,
yizhang2077 and
yuan-luo
as code owners
September 9, 2026 02:24
This was referenced Sep 11, 2026
This branch has not been deployed
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.
Wire
--dsa-prefill-backend tritonand--dsa-decode-backend tritonon gfx950 with fp8 KV. Prefill uses a fused Triton kernel with XCD swizzle and 64-bit KV offsets; decode adds a separate Triton path for MTP-shaped forwards. Shape-gate misses fall back to TileLang.Motivation
Sparse MLA is a major GPU cost on gfx950 DSA serving (prefill chunks and every MTP draft/verify decode step). This PR adds
tritonas an explicit DSA backend for both prefill and decode on gfx950 + fp8 KV:Default remains TileLang until those flags are set. Prefill and decode each have a shape gate; misses log
triton_shape_gateand fall back to TileLang so short warmup / out-of-spec batches stay safe.Replaces the earlier single-file
triton_sparse_mla.pystub with split prefill/decode modules registered in the kernel inventory.Modifications
python/sglang/kernels/ops/attention/dsa/triton_sparse_mla_prefill.py— fused per-query sparse-MLA prefill. XCD-swizzledpid → tokenbijection, softmax in log2 space, reciprocal-once denominator, unmasked KV loads after page clamp, next-block index prefetch, 64-bit KV offsets past the int32 wrap. Fixed serving config:BLOCK_N=64,num_warps = clamp(H_PAD // 16, 1, 4),num_stages=1(autotune hits a Triton 3.7.0 LLVM abort on part of the grid).python/sglang/kernels/ops/attention/dsa/triton_sparse_mla_decode.py— split-K sparse-MLA decode for gfx950 fp8 KV. Tiling (pick_n_groups/pick_block_n_warps/pick_num_stages) targets MTP token counts;qis two strided halves of the fused[T, H, 576]tensor (no extra.contiguous()).dsa_backend.py—--dsa-prefill-backend triton/--dsa-decode-backend tritoninDSA_CHOICES. Construction requires gfx950 + fp8 KV. Prefill shape gate: 8 or 16 heads,d_v=512, rope tail 64, topk 2048, 512–32768 tokens. HIP KV layout selector liststritonnext totilelang/aiter.exec_.py,hisparse_hook.py,kv_cache_configurator.py,forward_mla_rocm.pywire the new backend name.triton.Accuracy Tests
Kernel SNR floors (registered tests):
Bit-exact match is not expected: fp8 accumulation order differs.
Serving (upstream tree, MI355X, TP4/EP4, GLM-5.2-MXFP4, EAGLE MTP, fp8 KV,
--dsa-topk-backend sgl-kernel):Decode used Triton in production-shaped batches; prefill fell back to TileLang on small token counts (
reason=triton_shape_gate), which matches the prefill seq gate design.Speed Tests and Profiling
Kernel — prefill
MI355X, seq=32768, H=16 (TP4), fp8 KV, topk=2048, production index distribution. Alternating in-process A/B after a 1.5 s clock ramp.
Four 32k chunks of a 100k prompt: 36.2 ms → 20.2 ms, 1.79x.
Kernel — decode
Idle MI355X, ctx=100k, auto tiling, µs/call from 16-call
timed_graph. 24-point sum: TileLang 510, Triton 293 (1.74x).Serving — AgentX 900 s (GLM-5.2-MXFP4, same node)
TP4/EP4, MTP (EAGLE n=5), HiCache,
simulate_acc=3.61. Baseline = tilelang/tilelang; Triton = triton/triton. Error rate 0 on every cell.Official 3600 s TP4/EP4 sweep (tilelang vs both_triton, conc 8/10) shows similar trends (+0.9% to +1.6% out tok/s, TTFT −3.8% to −7.5%); full 3600 s table to be attached after the node sweep completes.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #34303074580
Latest PR Test (Extra): ❌ Run #34303074357
Latest PR Test (AMD ROCm 7.2): ❌ Run #34303074600