Skip to content

[AMD] Enable Fast Triton Sparse MLA backend - #30575

Merged
HaiShaw merged 41 commits into
sgl-project:mainfrom
clintg6:feat/triton-sparse-mla
Sep 10, 2026
Merged

HaiShaw merged 41 commits into
sgl-project:mainfrom
clintg6:feat/triton-sparse-mla

Conversation

@clintg6

@clintg6 clintg6 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fast Triton Sparse MLA Kernels for DSA (Prefill + Decode)

Summary

This adds triton as an explicit DSA prefill/decode backend:

--dsa-prefill-backend triton
--dsa-decode-backend triton

The new backend provides pure Triton sparse MLA kernels for the fp8 DSA path on ROCm, validated on MI355X (gfx950) and MI300X (gfx942). It replaces the previous Triton prefill env-var gate, SGLANG_DSA_TRITON_PREFILL, with a faster kernel exposed through the normal backend option and adds a fast Triton kernel for the decode path.

What Changed

  • Adds triton to DSA_CHOICES for --dsa-prefill-backend and --dsa-decode-backend.
  • Adds startup validation in both server-args paths so Triton DSA is only used with --kv-cache-dtype fp8_e4m3.
  • Adds standalone Triton prefill and decode dispatch branches in dsa_backend.py.
  • Ensures HIP Triton DSA uses the raw MLA KV layout (512 nope + 64 rope) instead of the scaled fp8 layout used by other non ROCm backends.
  • Extends the gfx950 fused-rope skip path to include Triton, matching the TileLang/AITER raw-layout flow.

Kernel Notes

  • Prefill uses a split-dim 4x128 implementation for the 512-wide nope dimension, plus the 64-wide rope tail.
  • Prefill can split topk work across CTAs and reduce partial online-softmax state in Triton.
  • Decode uses an adaptive split-K path with a fused single-pass fast path when kv_splits == 1.
  • Kernels use exp2 with sm_scale * LOG2E prescaling.

The kernels consume raw fp8 MLA KV cache layout on HIP. They are not intended for NVIDIA's scaled fp8 KV layout.

Validation

  • GSM8K 400-question validated: TileLang and Triton both produced 95.5% accuracy with 0% invalid answers. Accuracy also verified on gfx942
  • Isolated prefill microbench on MI355X/GLM-5.2 shape (H=16, D_V=512, D_TAIL=64, topk=2048) showed about 10% speedup for the split-dim prefill kernel versus the earlier 512-wide-dot Triton env gated kernel, with cosine similarity 1.00000.
  • End-to-end GLM-5.1-MXFP4 serving on TP4 MI355X (ISL=8192, OSL=1024) showed Triton improving throughput by roughly 3-5% versus TileLang in the measured concurrency range.
  • Performance improvement is seen across all concurrencies, TPs, and for short and long context.

Performance

End-to-end GLM-5.1-MXFP4 serving on TP4 MI355X, concurrency 2:

Backend Total tok/s Output tok/s Mean TTFT (ms) Mean TPOT (ms)
TileLang 1,005 112 834 17.1
Triton 1,044 116 701 16.6
Improvement +3.9% +3.6% -16.0% -2.9%

Changed Files

  • python/sglang/srt/layers/attention/dsa/triton_sparse_mla.py: updates the Triton prefill implementation with split-dim and split-K paths.
  • python/sglang/srt/layers/attention/dsa/triton_sparse_mla_decode.py: adds the Triton decode implementation.
  • python/sglang/srt/layers/attention/dsa_backend.py: adds Triton prefill/decode dispatch and removes the old env-var-gated prefill path.
  • python/sglang/srt/server_args.py: exposes triton as a DSA backend choice.
  • python/sglang/srt/arg_groups/overrides.py: validates Triton DSA override combinations against fp8 KV cache requirements.
  • python/sglang/srt/model_executor/model_runner_kv_cache_mixin.py: selects raw HIP MLA KV layout for Triton DSA.
  • python/sglang/srt/models/deepseek_common/attention_forward_methods/forward_mla.py: includes Triton in the gfx950 fused-rope skip check.

CI States

Latest PR Test (Base): ❌ Run #34293813943
Latest PR Test (Extra): ❌ Run #34293813789
Latest PR Test (AMD ROCm 10): ❌ Run #34293813924

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@clintg6 clintg6 changed the title Enable Fast Triton Sparse MLA backend [AMD] Enable Fast Triton Sparse MLA backend Jul 9, 2026
Comment thread python/sglang/srt/layers/attention/dsa_backend.py Outdated
Comment thread python/sglang/srt/layers/attention/dsa_backend.py
@HaiShaw

HaiShaw commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci label Jul 9, 2026
Raiden-Makoto added a commit to Raiden-Makoto/squidward that referenced this pull request Jul 10, 2026
Raiden-Makoto added a commit to Raiden-Makoto/squidward that referenced this pull request Jul 10, 2026
…nce CSV; rules: known-boxes m12-17 + no-SIGKILL-on-GPU-procs

Adds the MI355X (MXFP4) prefill kernel breakdown (tuned MoE, sgl-project#30575/sgl-project#30519/sgl-project#30715
annotations) and the 1k/1k conc64 MI355X-vs-B200 decode reference CSV. Documents the
m12-17 GLM-5.2 box and the rule against pkill -9 on ROCm GPU server processes (triggers
100-200GB gpucore dumps that fill the shared disk).
@Jacob0226

Copy link
Copy Markdown
Contributor

Hi @clintg6
I ran some decode-stage unit tests comparing Tilelang vs Triton across concurrency 4–256. Your Triton kernel performs well at low concurrency, but the advantage fades as concurrency increases.
image

In the perspective of E2E in SGLang, TTFT actually speedup >10% and it also helps TPOT be faster as waiting for prefill is reduced. TPOT on high conc shows regression on i1k but i8k still benefit from TTFT and Triton attention kernel in i8k take small runtime so it didn't add the show the regression in the end.

From an end-to-end perspective in SGLang, TTFT speeds up by >10%, which in turn helps TPOT since requests spend less time waiting on prefill.
On i1k, high concurrency shows a slight TPOT regression — this tracks with the kernel-level regression above, because at short context the decode attention kernel is a meaningful share of each decode step, so the Triton slowdown shows through.
On i8k, there's no TPOT regression. At long context the decode attention kernel plays a small fraction of the per-step runtime, so the Triton kernel's regression is amortized away. 😊
Test were done on rocm/sgl-dev:v0.5.14-rocm720-mi35x-20260708.
image

My only open question: is the regression at high concurrency expected behavior, or is there room to improve it?

@1am9trash 1am9trash left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clintg6

clintg6 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@fanxingran

fanxingran commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Hi @clintg6 @1am9trash — sharing independent MI355X validation on GLM-5.2 AgentX (TP4/EP4, conc=8, 3600s, 064fc7c72), which is important for our upcoming GLM-5.2 AgentX benchmark (9/11).

vs TileLang (c8):

  • P90 Interactivity: 106.6 → 114.4 (+7.3%)
  • Output tok/s: 347.1 → 356.7 (+2.8%)
  • TTFT p90: 1.244s → 1.116s
  • GSM8K: 0.932 → 0.933

Head-to-head vs our parallel PR #38601 (same recipe):

All gaps are ~1–3% (noise). AMD internal has reviewed this; we plan to close #38601 once #30575 lands.
Thanks!

@HaiShaw

HaiShaw commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Error: PR Test Base / base-c-test-8-gpu-b300 - https://github.com/sgl-project/sglang/actions/runs/34293813943/job/102658495822?pr=30575 is addressed in #38588

@HaiShaw HaiShaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HaiShaw

HaiShaw commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

@ispobock @xiezhq-hermann @BBuf @hzh0425 please have a review.

@fanxingran

Copy link
Copy Markdown
Contributor

Error: PR Test Base / base-c-test-8-gpu-b300 - https://github.com/sgl-project/sglang/actions/runs/34293813943/job/102658495822?pr=30575 is addressed in #38588

Hi, we noticed #38588 has been merged. Happy to leave next steps!Thanks!

@HaiShaw
HaiShaw merged commit 8a6ab89 into sgl-project:main Sep 10, 2026
562 of 643 checks passed
jiejingzhangamd added a commit to SemiAnalysisAI/InferenceX that referenced this pull request Sep 11, 2026
sgl-project/sglang#30575 exposes the Fast Triton Sparse MLA path as an
explicit backend; the 20260910 image already contains it.

Co-authored-by: Cursor <cursoragent@cursor.com>
edwingao28 pushed a commit to SemiAnalysisAI/InferenceX that referenced this pull request Sep 13, 2026
* update config for glm5.2-mxfp4 on mi355x gpu

* update pr link

* Update changelog link for replacement PR

Co-authored-by: Cursor <cursoragent@cursor.com>

* Update changelog link for upstream PR

Co-authored-by: Cursor <cursoragent@cursor.com>

* Raise SGLang /health timeout so eval-only GSM8K survives AITER JIT.

Cold mha_varlen compile after ready is ~40s; the default 20s generate health check marked the server UnHealthy and lm_eval hit a dead port.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Bump the GLM-5.2 MI355X SGLang daily image to 20260910.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Lower the TP HiCache host-pool ratio from 1.5 to 1.0.

Eval and sweep keep the same ratio-based sizing so a green evals-only run at
ratio 1.0 remains comparable for this sweep PR. TP4 pinned host DRAM drops
from ~679 GB to ~453 GB.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Keep HiCache write_through_selective instead of restoring write_through.

Matches main and the ratio-1.0 eval PR so a green evals-only run is the same
host-tier write path as this sweep.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Rename --cuda-graph-max-bs for the v0.5.19 image.

The 20260910 tag splits that flag into prefill and decode names, so the
unsuffixed form is rejected as ambiguous and the server never starts.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Restore HiCache write-through policy

Co-authored-by: Cursor <cursoragent@cursor.com>

* Use canonical decode CUDA graph limit

Co-authored-by: Cursor <cursoragent@cursor.com>

* Switch GLM-5.2 DSA prefill/decode to Triton.

sgl-project/sglang#30575 exposes the Fast Triton Sparse MLA path as an
explicit backend; the 20260910 image already contains it.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix changelog

---------

Co-authored-by: LI MOU <lxglbk@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Chun Fang <chun.fang@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.