Repository navigation
Conversation
With index_kpool > 1 (GLM-5.3-Flash) the kpool tail guard rejected the aiter DSA prefill backend, and elsewhere that backend ran mla_decode_fwd once per query token. On gfx950, a rope-free 512-wide bf16 pool now turns the page-size-1 top-k table into CSR (combined_to_csr, no host sync) and calls aiter's OPUS sparse prefill: mla_sparse_prefill without a sink when the installed aiter has it (>= 0.1.28), else pa_sparse_prefill_opus with a -1e30 sink, which adds nothing to the softmax denominator. - The kpool tail guard admits aiter for prefill when this path is taken; decode stays rejected. - The path needs DCP 1, no index-K sharding, no HiSparse and no logit cap; anything else keeps the per-token decode kernel. - Below 4,096 query rows x heads (64 rows at 64 heads per rank, 128 at 32, 256 at 16, 512 at 8) the prefill runs TileLang, with q made token-major for it: there the CSR conversion and the kernel cost a near-fixed 0.15-0.3 ms on MI355X, more than TileLang. - The sink-less call runs unsplit (num_kv_splits=1): aiter's split-key kernel can leave a row with no keys non-finite, and the DSA padding rows have none. Calls with a sink (DeepSeek-V4) are unchanged. - Tests: the guard (CPU), and the backend's prefill call as DSA makes it (gfx950: head-major q, a 2,051-column table with -1 holes and an empty row, 32 and 16 heads, few rows on TileLang and many on OPUS). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
4 of 10 tasks
No conflicts. Co-authored-by: Claude <[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
GLM-5.3-Flash on ROCm prefills only with TileLang. Its DSA layers keep a bf16 KV pool with a 512-wide latent and no
RoPE part, and they append tail tokens to the top-k (
index_kpool > 1). The kpool tail guard rejects--dsa-prefill-backend aiterfor that. Elsewhere theaiterprefill path runs AITER's decode kernel(
mla_decode_fwd) with each query token as its own sequence.AITER has a sparse prefill kernel for this layout (OPUS), which SGLang already calls for DeepSeek-V4
(
opus_sparse_prefill_hip.py). On MI355X this PR's call (CSR conversion and OPUS) takes 0.27–0.39× TileLang's timefor 2 K–16 K prefill rows at 32 and 16 heads per rank (kernel table below). End to end, GLM-5.3-Flash at TP 2 (one
768×1024 image and 6.5 K–8 K text tokens per request, concurrency 16–64) gains 17–18 % output throughput over TileLang
prefill on the same bf16 KV cache, and 6–7 % over the FP8 KV + TileLang recipe.
Modifications
kernels/ops/attention/dsv4/opus_sparse_prefill_hip.py: the sink is optional. Without one, the wrapper callsmla_sparse_prefillwhen AITER has it (≥ 0.1.28), elsepa_sparse_prefill_opuswith a −1e30 sink, which addsnothing to the softmax denominator. Both calls use one KV split: AITER's split-key path can leave a row with no keys
non-finite, and the DSA padding rows have no keys. Calls with a sink (DeepSeek-V4) are unchanged.
layers/attention/dsa_backend.py: with--dsa-prefill-backend aiter, a prefill on gfx950 with a rope-free512-wide bf16 pool turns the page-size-1 top-k table into CSR (
combined_to_csr, no host sync) and calls OPUS.conversion and the kernel cost a near-fixed 0.15–0.3 ms, more than TileLang.
layers/attention/dsa/dsa_backend_kpool.py: the kpool tail guard admitsaiterfor prefill when this path runs.Decode stays rejected.
test/registered/unit/layers/attention/test_dsa_q8kv8_bf16_prefill_routing.py(CPU): the guard admitsaiterfor prefill and rejects it for decode. It fails without this PR.
test/registered/attention/unittests/dsv4/test_dsv41_opus_sparse_prefill_hip.py(gfx950): the call as DSA makesit, against an fp32 reference: a 2,051-column table with −1 holes and an empty row, 32 and 16 heads, few and many
rows.
Scope: every DSA model with a rope-free 512-wide bf16 KV pool, on gfx950, with
--dsa-prefill-backend aiter.Measured: GLM-5.3-Flash. DeepSeek-V3.2-style pools (with a RoPE part), fp8 KV caches, gfx942 and CUDA are not
affected.
Accuracy Tests
python3 -m sglang.test.run_eval --api chatagainst the servers under Speed Tests (max tokens 2,048, temperature 0;MMMU: the 900 validation items; GSM8K: the 1,319 test questions, 5-shot):
tilelangaiter(this PR)tilelangaiter(this PR)One standard error is 1.5 pp on MMMU and 0.5 pp on GSM8K. An earlier session of the same bf16
tilelangserver scored0.697 and 0.971.
Speed Tests and Profiling
lmsysorg/sglang-rocm:v0.5.23-rocm724-mi35x-20261106(SGLang62384de1ae, AITER285579b621) with this PRapplied.
amd/GLM-5.3-Flash-Quark-MXFP4(revisionb5688f25), TP 2 on two MI355X; decode ontilelangthroughout.at each concurrency, then three repetitions of concurrency 16, 32 and 64 with 10 × concurrency requests. Every server
uses the same seed per (concurrency, repetition); the output token counts matched in every cell.
SGLANG_DSA_PREFILL_DENSE_ATTN_KV_LEN_THRESHOLD=0: prefills of at most 2,048 KV tokens (the eval prompts) otherwiserun the dense MHA path; the benchmark's prompts take the sparse prefill either way.
SGLANG_UNIFIED_RADIX_TREE_CORE_BACKEND=python: the containers had no network access, and the default core buildsfrom crates.io at startup.
Session 1, bf16 KV cache in both servers:
tilelangaitertilelangaiterSession 2,
tilelangon an fp8_e4m3 KV cache (the GLM-5.3-Flash cookbook's MI355X recipe) vs this PR on bf16:tilelangfp8aitertilelangfp8aiteraiterserver than on the fp8tilelangone: MMMU 300 s vs 291 s, GSM8K 98 s vs 95 s. Its decode reads the bf16 cache, about twice the bytes.In the session-1
aiterserver, 38,544 of the DSA prefill calls on TP rank 0 ran OPUS and 143 (0.4 %), with fewerthan 4,096 rows × heads, ran TileLang (counted by wrapping the two backend methods).
Kernel: this PR's prefill call vs TileLang (same image, one MI355X; bf16, 512-wide, 2,051-column table)
lmsysorg/sglang-rocm:v0.5.23-rocm724-mi35x-20261106(SGLang62384de1ae, AITER285579b621, which haspa_sparse_prefill_opusonly).reference on sampled rows.
Small calls (PR / TileLang, the larger of no prefix and an 8,192-token prefix): at 32 heads 1.246 at 32 rows, 0.929 at 64, 0.616 at 128; at 16 heads
1.029 at 128 rows, 0.714 at 256. The 4,096 rows × heads bound keeps every measured call at or below TileLang's time.
Notes
pa_sparse_prefill_opus(it needsnum_kv_splits, from [HIP] [OPUS] [FlyDSL] Packed-row FP4 MQA logits / decode top-k, split-K gfx950 sparse prefill ROCm/aiter#6334);AITER ≥ 0.1.28 adds
mla_sparse_prefill, which acceptsattn_sink=None. Before [HIP] [OPUS] [FlyDSL] Packed-row FP4 MQA logits / decode top-k, split-K gfx950 sparse prefill ROCm/aiter#6334 the sink-less call raisesTypeError; the configurations that reach it raisedNotImplementedErrorbefore this PR.aiter_sparse_mlabackend for GLM-5.3 at 8 and 16 heads per rank (TP 8 and4), and edits the same kpool guard clause. This PR adds the OPUS prefill for
--dsa-prefill-backend aiterat everyhead count, including 32 and 64 (TP 2 and 1).
tritonandtilelangbackends only; with--dsa-prefill-backend aiterthe cache stays bf16, which this path needs. Session 2 compares with thatconfiguration.
_forward_aiter_extend's metadata reuse; this PR adds a branch before that path is reached.sparse prefill kernel over a bf16 rope-free pool, and leaves decode as it is.
This change was developed with AI assistance (Claude); I reviewed every line and ran the tests listed.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ⊘ Skipped -- the PR is a draft; marking it ready starts a new run (AMD: then⚠️ Run #46306851898
/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: