Repository navigation
Conversation
On gfx950, for a BF16 checkpoint with low-part rings at K = V = 128 and a ring of 16: - When the verify launch (4 draft tokens) has more than 1024 programs, the most main's launches run at once on MI355X (one wave per SIMD), gdn_replayssm_qk_prep_kernel normalizes q and k and forms k @ k^T and k @ q^T once per (request, key head). The verify kernel reads them under QK_PREP, through its q and k arguments, instead of recomputing them in every (V tile, value head) program, and runs three waves per SIMD. - With track rows and at least 1536 (request, value head) programs, the compact commit folds every layer of a (V tile, request, value head) in one program (LAYER_LOOP). Both are bitwise equal to the launches they replace. Other cases launch as before; on gfx950 those launches compile to the same instructions. Co-authored-by: Claude <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
4 of 5 tasks
1 of 5 tasks
eppaneamd
added a commit
to eppaneamd/InferenceX
that referenced
this pull request
Nov 18, 2026
Patches 16, 21 and 24 add opt-in kernels, each off unless the recipe sets its SGLANG_AMD_* variable; c12, c24, c48 and c80 set all eight: - 16 QSA indexer prefill blocks selected by the exact topk_v2, one pipeline stage on gfx95 (sgl-project/sglang#50871, #51263) - 21 QSA decode, verify and draft-extend blocks selected by the exact topk_v2, draft-extend rows scored grouped as in verify (sgl-project/sglang#50871, #51242) - 24 GDN ReplaySSM verify and commit kernels (sgl-project/sglang#51180) Co-authored-by: Claude <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
4 of 11 tasks
select_verify_intermediate_state_indices reads its row mask only with PP spec stable rows (SGLANG_ENABLE_PP_SPEC) and otherwise returns its default. Since sgl-project#48414 the GDN and KDA verify layers pass the mask as a callable. The PLE N-gram verify commit now passes batch.lengths.ne(0) the same way, so a verify step without stable rows launches no compare for it. The new test checks the rows the commit writes with and without stable rows, and that the mask is computed only with them. Co-authored-by: Claude <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
The fused verify conv handles the PLE short conv in verify when PLE fusion is on (the default) and it takes the inputs (BF16 on the GPU, not NPU). Otherwise each PLE layer's _short_conv passes batch.lengths.ne(0) to select_verify_intermediate_state_indices. It now passes the mask as a callable, as the N-gram verify commit does, so a verify step without PP spec stable rows launches no compare for it. The test now covers both PLE verify sites: the rows each writes with and without stable rows, and that each computes its mask only with them. The test file imports the PLE pools and the layer router once, at module level. Co-authored-by: Claude <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
5 of 11 tasks
4 of 11 tasks
This was referenced Nov 21, 2026
maeehart
pushed a commit
to SemiAnalysisAI/InferenceX
that referenced
this pull request
Nov 24, 2026
…draft head at its shipped precision Patches 11-16, 21 and 24 add opt-in kernels, each off unless the recipe sets its SGLANG_AMD_* variable; c12, c24, c48 and c80 set all eight: - 11 grouped QSA verify scoring (sgl-project/sglang#48625, carries #46631) - 12-13 FlyDSL QSA sparse prefill (ROCm/aiter#7556 kernels in the image's AITER checkout, sgl-project/sglang#51179 wiring) - 14 MXFP4 MoE intermediate kept 128-aligned at TP 1 (sgl-project/sglang#49852) - 15 Triton HC prefill path (sgl-project/sglang#50863) - 16 QSA indexer prefill blocks selected by the exact topk_v2, one pipeline stage on gfx95 (sgl-project/sglang#50871, #51263) - 21 QSA decode, verify and draft-extend blocks selected by the exact topk_v2, draft-extend rows scored grouped as in verify (sgl-project/sglang#50871, #51242) - 24 GDN ReplaySSM verify and commit kernels (sgl-project/sglang#51180) c1 and c2 set SGLANG_AMD_MONO_QWEN38_DRAFT_HEAD_FP8=0, and the recipe drops default-chat-template-kwargs so the server serves the chat template's default thinking mode. The setup script uses set -eo pipefail (AGENTS.md Bash: no nounset). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
Signed-off-by: Rony Leppänen <[email protected]>
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
With
--enable-linear-replayssm-spec --mamba-ssm-dtype bfloat16and MTP (4 draft tokens, the default ring of 16), every verify step runsgdn_replayssm_spec_decodeonce per GDN layer andcommit_gdn_replayssm_circularonce for all of them. On gfx950 two parts of that work repeat:k @ k^Tandk @ q^T, which depend only on the request and the key head. The kernel takes 262 VGPRs (64-wide V tile) or 334 (128-wide), one wave per SIMD, so MI355X runs 1,024 of its programs at a time; at 16 key and 48 value heads a step of 11 requests needs a second round.This PR computes the q/k part once per (request, key head) in a new kernel, which brings the verify kernel to 144 VGPRs (3 waves per SIMD), and folds all layers of a (V tile, request, value head) in one program. The arithmetic and its order are unchanged, so outputs, rings and checkpoints are bitwise those of
main. On one MI355X at 16 key and 48 value heads and 36 GDN layers (Qwen3.8-Flash-Next at TP1), the GDN verify and commit of a step take 8.8 to 25.4 % less from 11 to 128 requests; at six other head and layer counts, 8.3 to 26.9 % less where the new launches run.Limits:
mainwould use has more than 1,024 programs, the layer loop from 1,536 (request, value head) programs with track rows. Other gfx950 parts were not measured.--disable-radix-cache) the commit keepsmain's launch, whose kernel then fits twice the waves.main's verify launch (one stage; the 128-wide tile from 768 request x value-head programs). The prep counts the programs of the launch that is routed, so with [Perf] [AMD] gdn: ReplaySSM verify uses one pipeline stage at every batch size on gfx950 #47433 at 48 value heads it runs at 11 to 15 and from 22 requests. Against [Perf] [AMD] gdn: ReplaySSM verify uses one pipeline stage at every batch size on gfx950 #47433's launch it measured faster at 11 to 15, 22 and 24 requests and slower at 10, 16 and 21, where it does not run.Scope:
gdn_replayssm_spec_decoderuns in the GDN backend's ReplaySSM spec verify (--enable-linear-replayssm-spec), for models with GatedDeltaNet layers (qwen3_next.py,qwen3_5.py,qwen4_exp.py,gigachat35.py,interns2_mobius.py,jet_nemotron.py). The prep needs 4 draft tokens (MTP, top-k 1).commit_gdn_replayssm_circularfollows every such verify: the MTP commit inspec_utils.pyand the DFLASH / DSPARK commit inhybrid_linear_attn_backend.py. Its change does not depend on the draft count.--enable-linear-replayssm-spec), other shapes, launches under the thresholds, other GPUs (apart from the PLE row masks inqwen4_exp.py, below). On gfx950 the launches that do not change compile to the same instructions as onmain.Related work:
mul.rn.f32) and requirestorch.version.hip is None. It edits the same launch lines ofcommit_gdn_replayssm_circular; [Perf] spec: one launch each for the verify commit's conv-window and PLE rollbacks #51066 (draft) is stacked on it.mainnow does.gdn_replayssm_spec_decode.pyand conflicts with this PR there; whichever merges second rebases.Modifications
gdn_replayssm_qk_prep_kernel, grid (requests, key heads): the L2 norms, the normalized q, k and k low-part tiles, andk @ k^Tandk @ q^Twith the low-part terms, into a [B, H, 3, 4, K] BF16 and a [B, H, 2, 4, 4] FP32 buffer.gdn_replayssm_spec_circular_kernel: under the newQK_PREPconstexpr it reads those buffers through itsqandkarguments instead of computing them (atl.static_assertchecks the preconditions). The q/k arithmetic moved into_qk_rnorm,_qk_tilesand_qk_products, used by both kernels. No new pointer or stride argument, so the launches that do not prep keepmain's kernel arguments and instructions.gdn_replayssm_compact_commit_kernel: the per-layer body runs in atl.rangeloop overNUM_LAYERSthat advances the layer pointers; withLAYER_LOOPthe grid is (1, requests, value heads), a 128-wide V tile and 8 warps.main's launch has more than_VERIFY_RESIDENT_PROGRAMS = 1024programs;_LAYER_LOOP_MIN_PROGRAMS = 1536(requests x value heads).qwen4_exp.py, on any device: both PLE verify call sites, the N-gram commit and the short conv, pass their row mask (batch.lengths.ne(0)) toselect_verify_intermediate_state_indicesas a callable, as the GDN and KDA verify layers do since [Feat] kimi_k3: Merge the rest of the Kimi-K3.1 Day-0 branch #48414. The selector reads the mask only with PP spec stable rows (SGLANG_ENABLE_PP_SPEC), so a verify step without them skips the compare: once a step in the N-gram commit, and once per PLE layer in the short conv when the fused verify conv does not run (PLE fusion off, NPU, or inputs it does not take). The rows the selector returns are unchanged.test_ple_state_coordinates.py(CPU) checks, for both sites, the rows written with and without stable rows and that the mask is computed only with them; it fails without either change.test_gdn_replayssm_batched_launch.py(gfx950, MI35x suite) and the benchmarktest/manual/kernels/benchmark/attention/bench_gdn_replayssm_spec_decode.py.Accuracy Tests
main's at 2 to 64 requests; at the six other head and layer counts of the forced-launch runs (details) the verify outputs and ring writes do at 4 to 128 requests. The new test checks the verify at 10 and 32 requests and the commit at 32, each plus a padding row; it fails onmainand under each of 5 mutations.amd/Qwen3.8-Flash-Next-Quark-MXFP4at TP1 with MTP on one MI355X,lmsysorg/sglang-rocm:v0.5.23-rocm10-mi35x-20261117, the same server flags for both:The difference is 5 of 1,319 questions: 17 right only on
main, 12 right only with this PR (paired standard error 0.41 points). With this PR the server compiledgdn_replayssm_qk_prep_kerneland the 8-warp commit kernel (the layer loop, so the radix cache passed track rows);main's compiled neither. 21 of the 26 logged decode batches of each run had 61 to 64 running requests.GSM8K setup and path evidence
Server (both runs,
SGLANG_USE_AITER=1,main=372b35034d'spython/or this PR's first onPYTHONPATH, each with an empty Triton cache):--max-mamba-cache-size 400lets 80 requests run (5 state slots each); with the default the server capped them at 30, below the layer loop's 32. Client: lm-eval 0.4.13,local-chat-completions,gsm8k, 5-shot as multi-turn chat, temperature 0,max_gen_toks1024, thinking off, 64 concurrent requests, seed 42.Kernels compiled into each server's empty Triton cache (
gdn_replayssm*, name, warps, stages):Speed Tests and Profiling
One MI355X,
lmsysorg/sglang-rocm:v0.5.23-rocm10-mi35x-20261117, the benchmark added here: the verify of 36 GDN layers plus the commit with track rows, 16 key and 48 value heads, µs a step, mean of two runs:At six other head and layer counts every step that takes a new launch is 8.3 to 26.9 % shorter, and every other step within 0.5 % (details).
Setup, method, other head counts, tests and mutations
Image
lmsysorg/sglang-rocm:v0.5.23-rocm10-mi35x-20261117(sha256:09b8237296024285e6286ffb54d75c3af6d59342bbbb3558dea56bed86798814, Triton 3.8.0, PyTorch 2.11.0+rocm10.0.0), one MI355X.mainis372b35034d; its GDN files equal the image's. This PR's script runs with each side'spython/first onPYTHONPATH, over the image's sglang:PYTHONPATH=$CHECKOUT/python python3 test/manual/kernels/benchmark/attention/bench_gdn_replayssm_spec_decode.py \ --h 16 --hv 48 --num-layers 36 --batch-sizes 1 2 4 8 11 16 24 32 48 64 96 128The benchmark sizes its pools as a server with 128 running requests does (640 state slots, 129 ring rows), so the checkpoint pool exceeds 2 GiB and Triton does not compile its pointer with 32-bit offsets, as in serving. q, k and v are views of one conv output. Each part runs in a CUDA graph (
triton.testing.do_bench_cudagraph, median), replayed back to back. The commit without track rows takesmain's kernel on both sides; its difference between the runs (up to 3.8 %) is the run-to-run noise.Step change by head count (key/value heads/GDN layers), from the same command:
Where the thresholds come from: from the kernels' ISA (
; Occupancy, waves per SIMD; MI355X has 1,024 SIMDs),main's verify takes 262 or 334 VGPRs (1 wave), the prep launch's verify 144 (3);main's commit takes 168 with track rows (3) and 74 without (6), the layer loop 240 (2, so one 8-warp program per CU). With forced launches at 16/48/36, 8/24/36, 4/12/36, 16/32/36, 8/16/36, 16/64/45 and 4/16/45 and 4 to 128 requests (cold L2,main'sMambaPool, verify µs a layer, commit with track rows), the prep was 4 to 38 % faster thanmain's launch at every point above 1,024mainprograms; from 448 to 1,024 it was 0.3 % faster to 14 % slower, and at 384 and fewer 8 % faster to 7 % slower, wheremain's kernel with one stage and a 128-wide tile (#47433) was faster than both. The layer loop was faster at every point from 1,536 programs and slower at some below (8, 24, 36 and 40 requests at 16 value heads: 0.5, 1.5, 2.25 and 2.5 rounds of one program per CU). All of these verify launches were bitwise equal tomain's.Tests:
test_gdn_replayssm_batched_launch.pypasses; onmainit errors (no_VERIFY_RESIDENT_PROGRAMS); it fails under each of: the prep kernel without the low-part terms,_VERIFY_RESIDENT_PROGRAMS = 1 << 40, the layer loop without thek_cacheor thed_residual_cachelayer step,_LAYER_LOOP_MIN_PROGRAMS = 1 << 40.test_gdn_replayssm_direct_commit.py(8 tests) andtest_gdn_replayssm_dflash_commit.py(10) pass with and without this PR. The launches this PR leaves tomain's code (BF16 and FP32 checkpoints, 64- and 128-wide verify tiles, commits with and without track rows) compile to the same instructions as onmain, compared from empty Triton caches.Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ⊘ Skipped -- the PR is a draft; marking it ready starts a new run (AMD: then⚠️ Run #46306933681
/rerun-failed-ci).Latest PR Test (Extra): ⊘ Skipped -- the PR is a draft; marking it ready starts a new run (AMD: then
/rerun-failed-ci).Latest PR Test (AMD ROCm 10):
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: