Repository navigation
Conversation
On gfx950 with SGLANG_ROCM_QSA_FLYDSL_PREFILL=1, both extend branches of QwenSparseAttnBackend.forward_extend (no prefix, and over a prefix on the packed K/V) run the sparse attention on aiter.ops.qsa.qsa_sparse_prefill (ROCm/aiter#7556) instead of the Triton kernels. Calls the op refuses (qsa_sparse_prefill_problem), prefill graph runs and an aiter without the API keep Triton. The backend compiles the op's kernels at start-up through qsa_sparse_prefill_warmup. Adds a real-kernel test of both branches against a float32 reference, a manual microbenchmark of the two paths and the variable's docs entry. Co-authored-by: Claude <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
Contributor
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
1 of 5 tasks
This was referenced Nov 18, 2026
5 of 11 tasks
4 of 11 tasks
…kens aiter#7556's qsa_sparse_prefill_warmup now also runs a layout whose request has a 4-token prefix (it keeps the request on the base union tile with batch_invariant=True) and returns the (query_lens, prefix_lens) that ran. run() sized K/V by the query rows alone, so the op refused that layout: its kernels stayed uncompiled and start-up logged "QSA extend attention stays on Triton". K/V now hold each request's prefix and query tokens. Checked on MI355X against aiter#7556's head: the warm-up's source runs every layout at 24/2, 12/1 and 48/4 query/KV heads (selection width 2051); with the previous run() the op refused the prefix layout. Signed-off-by: Rony Leppänen <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
This was referenced Nov 28, 2026
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
On gfx950,
QwenSparseAttnBackend.forward_extendruns QSA extend attention on Triton:sparse_gqa_fwd_interface_tritonfor an extend without a prefix,sparse_gqa_fwd_interface_triton_ckon the packed K/V over a prefix.ROCm/aiter#7556 adds
aiter.ops.qsa.qsa_sparse_prefill, FlyDSL kernels for the same operands (BF16 Q, K/V[N, HK, 256], the int32 selectionexpand_qsa_block_indiceswrites) that share K/V tiles among the rows of a request. WithSGLANG_ROCM_QSA_FLYDSL_PREFILL=1this PR runs both branches on it. On one MI355X:Limits:
Scope:
indexer_n_heads), served byQwenSparseAttnBackend(qwen4_exp.py, e.g. Qwen3.8-Flash-Next): every extend of the target model and, with NEXTN, the draft model's extend after a prefill (13 QSA layers per chunk)._forward_paged_attention); context-parallel extends (_forward_extend_cp).amd/Qwen3.8-Flash-Next-Quark-MXFP4-AttnFP8-PLEFP8.Related work:
kv_slots; this PR passes the packed K/V the Triton kernel already gets.Modifications
qwen_sparse_attn_backend.py:_resolve_flydsl_sparse_prefill()returnsaiter.ops.qsawhen the flag is set, on gfx950, if aiter hasqsa_sparse_prefill_problemandqsa_sparse_prefill_warmup(TODO(aiter#7556), as_flydsl_v4_decode()guards an unmerged aiter API)._flydsl_sparse_prefill(...)takes the Triton kernels' operands plus the host query and prefix lengths. It returnsNone(keep Triton) in a prefill graph scope or whenqsa_sparse_prefill_problemnames a broken rule (logged once). Bothforward_extendbranches call it first.__init__compiles the op's kernels for each attention geometry of the model throughqsa_sparse_prefill_warmup, once per process, so no served extend compiles them.environ.pyand the environment variable docs:SGLANG_ROCM_QSA_FLYDSL_PREFILL(default off).test_qsa_rocm.py; manual benchmarktest/registered/kernels/benchmark/attention/bench_qsa_flydsl_prefill.py.Accuracy Tests
Served with the cookbook's MI355X concurrency 12–16 command, one server lifetime per row, in this order (details). GSM8K: lm_eval, 5-shot, chat template, all 1,319 questions (stderr 0.0053). NIAH: 100 prompts of 32,039 to 32,140 tokens, each asking for a 7-digit number placed in the context.
_sparse_gqa_prefill13 and_sparse_gqa_chunk_prefill13 times and no FlyDSL kernel; on ran 52 FlyDSLsparse_prefill_*kernels (26 calls) and neither Triton kernel. Both on lifetimes logQSA FlyDSL sparse prefill warmed for 24 query heads, 2 KV heads, head dim 256, selection width 2051at start-up and neverQSA extend attention stays on Triton.forward_extendon the same operands (10 layouts): at most 0.0156, mean 7.8e-5 to 1.6e-4, 45% of the elements equal. Max error against float32 attention on 64 sampled rows: FlyDSL 0.00057 to 0.0038, Triton 0.00066 to 0.0044.test_qsa_extend_flydsl_sparse_prefill_matches_reference(one request without a prefix; two requests, one over a prefix) runsforward_extendwith the real op against a float32 reference and Triton; it fails without this PR and under each of 11 mutations (details).Speed Tests and Profiling
Served on one MI355X, one server lifetime per column; the kernel benchmark (all layouts) is in the details.
max_new_tokens1. Load: 48 prompts of 32,768 random token ids, 256 output tokens, at most 12 at a time.Setup, commands, full sweep, tests and mutations
Setup. One MI355X (gfx950), TP1,
lmsysorg/sglang-rocm:v0.5.23-rocm10-mi35x-20261117(SGLangc67db7c762, aiter581579ab5, FlyDSL 0.4.2, torch 2.11.0+rocm10.0.0). In a new container of the image for each run:python/changes applied withgit applyto the image's/sgl-workspace/sglang, plus this PR's two test files copied in;98c9335b8a): its diff to its 8 non-test files against its merge base (git diff 8e96f31c6f 98c9335b8a -- aiter/) applied withgit apply -3to the image's aiter checkout at/sgl-workspace/aiter; the one conflict, the__all__list ofaiter/ops/qsa.py, keeps both sets of names.Flag off and on run in the same container, one server lifetime each, with
SGLANG_ROCM_QSA_FLYDSL_PREFILL=0or1.Server. The cookbook's MI355X concurrency 12–16 command (
docs/cookbook/autoregressive/Qwen/Qwen3.8-Flash-Next.mdx:SGLANG_AITER_HONOR_EXPLICIT_MEM_FRACTION=1 AITER_GDR_FLYDSL=1, NEXTN 3/1/4,--chunked-prefill-size 16384,--mem-fraction-static 0.9, BF16 KV) with--host 127.0.0.1and--admin-api-key(needed by/start_profile).GSM8K (lm_eval 0.4.13,
openai/gsm8kmain, revision740312a):NIAH. 100 prompts built once with a fixed seed: GSM8K train questions as the haystack and one sentence "The special magic number for is <7 digits>." at a random depth (5 to 95%), then the question; greedy,
max_tokens16, 8 at a time; correct when the reply contains the number.Path.
/start_profile(activitiesGPU), one request of 32,768 token ids withmax_new_tokens1 and nothing else running,/stop_profile; kernel names counted in the trace.Single requests.
/generate, one request at a time,max_new_tokens1, temperature 0; token ids drawn from [1000, 150000) by a seeded generator, the same in every lifetime. Prefill: one warm-up request, then 6 timed. Over a prefix: 98,304 ids sent once, then 6 requests of those ids plus 64 (or 512) new ids; every reply reports 98,304 cached tokens. Steps of each lifetime, in order: path, GSM8K, NIAH, single requests, load.Load.
Server start to ready: 216, 521, 226 and 151 s, of which loading the target weights took 41, 328, 160 and 84 s. The warm-up line follows
Using QSA for sparse full-attention layers.by 26 s in lifetime 2 (empty FlyDSL kernel cache) and 1 s in lifetime 3.Kernels.
python test/registered/kernels/benchmark/attention/bench_qsa_flydsl_prefill.py --sweep, three runs, each on a different GPU. Per case: median over the runs of the time of 12 layers on one layout (new for each chunk over a prefix) and of the ratio [min-max]; first-call extra = median first call minus median later call of one layer.Device memory the op keeps after its calls (planner cache and work buffers, outside the KV-pool sizing; one process, layouts in this order): 6.8 MiB after 1,536 rows, 148.6 after 16,384 rows, 201.5 after 16,384 over 16,384, 334.1 after 16,384 over 83,968 (unchanged by 2,048 over 98,304), 650.9 after 16,384 over 245,760. Served,
available_gpu_memafter graph capture is 24.79 and 24.94 GB with the flag against 25.44 and 25.49 GB without; the KV pool is the same (3,595,456 tokens).Tests (
test_qsa_rocm.pyin the container): with this PR, 7 passed (38 s with an empty FlyDSL cache, 13 s warm); on the image's sources without it, the three new cases fail. Each mutation of the PR below makes at least one new case fail:qsa_sparse_prefill_problemignoredNumerical difference (
forward_extend, flag on against off, same operands; max error against float32 on 64 sampled rows):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 #46306930568
/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: