Repository navigation
[Perf] [AMD] GLM5: Row-streaming KDA packed decode on gfx950 - #44659
Open
Raiden-Makoto wants to merge 3 commits into
Open
Raiden-Makoto wants to merge 3 commits into
Raiden-Makoto wants to merge 3 commits into
Conversation
Raiden-Makoto
marked this pull request as ready for review
October 16, 2026 04:07
Raiden-Makoto
requested review from
hanming-lu,
hebiao064,
yizhang2077 and
yuan-luo
as code owners
October 16, 2026 04:07
This comment has been minimized.
This comment has been minimized.
Jacob0226
reviewed
Oct 20, 2026
Raiden-Makoto
added a commit
to Raiden-Makoto/squidward
that referenced
this pull request
Oct 20, 2026
Jacob0226
reviewed
Oct 21, 2026
| from sglang.kernels.ops.attention.fla.fused_recurrent import ( | ||
| fused_recurrent_kda_packed_decode, | ||
| ) | ||
| from sglang.kernels.ops.attention.fla.fused_sigmoid_gating_recurrent import ( |
Contributor
| @@ -0,0 +1,187 @@ | |||
| """Row-streaming KDA packed decode for gfx950. | |||
Contributor
There was a problem hiding this comment.
After #45112, fla/ holds the vendored FLA ops and SGLang's own linear-attention kernels live in attention/linear/. This file belongs there too, next to fused_sigmoid_gating_recurrent.py.
Add a gfx950 row-streaming packed KDA decode kernel and route validated safe-gate KDA geometry through it. Unsupported hardware, layouts, dtypes, dimensions, and indices retain the existing decode path.
Raiden-Makoto
force-pushed
the
RM/glm53-kda-rowstream-decode
branch
from
October 27, 2026 15:56
65e59de to
6b1ca08
Compare
Contributor
Raiden-Makoto
added a commit
to Raiden-Makoto/squidward
that referenced
this pull request
Nov 2, 2026
Port sgl-project#44416's HIP gate/top-k onto sgl-project#44994's TopK.routing_inputs(), keep sgl-project#41615's aiter_sparse_mla routing beside the ROCm DCP path, keep sgl-project#44659's HIP guard and sgl-project#38764's conv tuning, and take main's fp32 correction-bias routing that supersedes sgl-project#44415's copy.
5 tasks done
This was referenced Nov 17, 2026
This was referenced Nov 18, 2026
This comment has been minimized.
This comment has been minimized.
4 of 5 tasks
This was referenced Nov 24, 2026
Open
5 tasks done
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.

Motivation
GLM-5.3-Flash's KDA layers use the safe gate (
lower_bound), so on ROCm their decode skips the packed decode path. It runsfused_sigmoid_gating_delta_rule_update, which holds a[BV, K]FP32 state tile per program. The recurrent state update is bandwidth-bound on that FP32 state, and this kernel reaches only about 5 TB/s of in-place state traffic on MI355X at decode batch sizes.This change adds a gfx950 Triton kernel that streams the FP32 state in row chunks per (request, head, row group), and routes GLM-5.3's safe-gate layers to the packed decode path on gfx950. CUDA already uses its own row-streaming kernel in this dispatcher; other HIP targets keep their current path.
Modifications
kda_packed_decode_rowstream, a gfx950 Triton row-streaming KDA decode kernel. It fuses QK L2 norm, the per-K gate with the optional safe-gatelower_bound, the sigmoid beta, the delta-rule state update, and the output. It uses one static launch configuration per decode batch bucket.fused_recurrent_kda_packed_decode, dispatch to the row-streaming kernel whencovered()holds: gfx950,K=V=128, BF16 packed qkv, contiguous FP32[slots, HV, V, K]state, and contiguous output and indices. Everything else keeps the existing CUDA and Triton paths.TritonKDAKernel.supports_packed_decode_safe_gateon gfx950 only, so safe-gate layers reach the packed path there.-1slots write zero output and leave the state pool untouched.fused_sigmoid_gating_delta_rule_update. It covers every batch bucket, TP4 and TP8 head counts, safe gate on and off, padded slots, untouched pool slots, and 16 consecutive decode steps.Accuracy Tests
Focused validation passed 3 gfx950 row-streaming tests (29 subtests) and the KDA Triton unit suite (5 passed, 1 skipped). Coverage includes batch buckets 1-64, 16 and 8 heads, safe gate on and off, padded
-1slots, untouched pool slots, state over 16 decode steps (atol/rtol1e-5), output (atol/rtol2e-2), and finite outputs. CUDA-graph replay is exercised by the CUDA-graph E2E runs below.Full GLM-5.3-Flash MXFP4 TP4 GSM8K on snapshot
b5688f25491202978c19c4d036eef579f61bbe07: 1,319 examples, 64 evaluator threads, 32,768 maximum output tokens, thinking enabled, temperature 1.0, top-p 0.95, sampling seed unset.mainSpeed Tests and Profiling
Environment:
gfx950)rocm/sgl-dev:v0.5.21-rocm724-mi35x-20261014amd/GLM-5.3-Flash-Quark-MXFP4, snapshotb5688f25491202978c19c4d036eef579f61bbe07e7d2453f2)4e85e8ed37ac7a44ecc5Recurrent decode state update
GLM-5.3 shapes (
K=V=128, FP32 state, safe gatelower_bound=-5), timed inside CUDA graphs. The baseline is the path GLM's safe-gate layers take onmain(fused_sigmoid_gating_delta_rule_update); the candidate isfused_recurrent_kda_packed_decodedispatching to the row-streaming kernel. State bandwidth counts one FP32 state read plus one write per request.Every measured cell beats the baseline.
End-to-end serving
GLM-5.3-Flash MXFP4 snapshot
b5688f25491202978c19c4d036eef579f61bbe07, TP4, random 8K input / 1K output. The first concurrency-4 run in each repetition is the warmup; the tables average the two measured runs per concurrency. Arm A is basemain(4e85e8ed37); arm B is that base plus this change (ac7a44ecc5). The arms are otherwise identical.A. Base
main:B. Row-streaming packed decode (delta versus base
main):Row-streaming improves ITL by 0.14-1.21%, E2E latency by 0.10-1.08%, and output throughput by 0.10-1.09% across the complete TP4 matrix. TTFT is unchanged within +0.14%.
TP8 end-to-end serving
GLM-5.3-Flash MXFP4 TP8, 131,072 context, random 8K input / 1K output. The first concurrency-4 run in each repetition is the warmup; the tables average the two measured runs per concurrency. Arm A is base
main(4e85e8ed37); arm B is that base plus this change (ac7a44ecc5). The arms are otherwise identical.A. Base
main:B. Row-streaming packed decode (delta versus base
main):Row-streaming improves TP8 ITL by 0.12-1.12%, E2E latency by 0.04-0.95%, and output throughput by 0.04-0.96% across the complete matrix. TTFT is 0.20-0.41% higher. The change touches only the decode state update; prefill does not call this kernel.
Checklist
Scoped isort, Ruff, Ruff format, codespell, registered-test validation, and trailing-whitespace/end-of-file checks pass on the changed files.
CI States
Latest PR Test (Base): ❌ Run #44600717123
Latest PR Test (Extra): ⊘ Skipped -- add the
run-ci-nv-extralabel to opt in.Latest PR Test (AMD ROCm 10): ❌ Run #44600716961
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: