Repository navigation
[AMD] [GLM-5.3-Flash Day 0] Enable the k-pool DSA indexer on gfx950 - #39341
Conversation
…ayout
The k-pool indexer is CUDA-only end to end. forward_cuda raises
NotImplementedError off CUDA, the paged (decode) path picks between a
tilelang kernel whose selector returns False off CUDA and DeepGEMM, and
the ragged (prefill) path calls deep_gemm.fp8_mqa_logits directly.
DeepGEMM has no ROCm build, so GLM-5.3-Flash cannot start.
Open the forward gate to HIP and route both logits paths to AITER:
- paged: aiter_paged_mqa_logits(..., preshuffle=True), resolved through
DSAPagedMQALogitsBackend so --dsa-paged-mqa-logits-backend reaches
this path rather than branching on is_hip() at the call site.
resolve() already pins ROCm to AITER.
- ragged: _fp8_mqa_logits() picks aiter.ops.triton.fp8_mqa_logits on
HIP. It takes the fp8 values and scales as separate arguments where
DeepGEMM takes a tuple.
AITER's paged kernel reads the index-K cache in a 16x16 tile order, so
kpool_fp8_index has to write it that way. The four write kernels and the
one read kernel now share _kpool_cache_k_offsets, which follows
_set_k_and_s_triton_kernel in index_buf_accessor.py -- the non-pooled
indexer already lays its cache out this way for the same AITER kernel,
and the two must agree.
aiter_paged_mqa_logits inserts the next_n dim itself, so q_fp8 stays
[tokens, heads, dim] through the dispatch and the tilelang and DeepGEMM
branches unsqueeze at their own call sites.
AITER's fp8_mqa_logits only compiles while the fp32 [num_q x num_k]
logits fit a 32-bit buffer_store offset; above 2 GiB it takes a gl.store
fallback that fails to compile and abort()s every TP rank. The query rows
are split so each call stays under the cap. That bound is Yikai Zhang's
work, contributed to the sgl-project#38544 replacement.
Add layout coverage. A write/read disagreement here does not raise, it
silently returns the wrong top-k, so the offsets are pinned against an
independent reference, checked for collisions, and round-tripped through
the reader. The round trip follows the runtime tile rather than pinning
16, so it also holds on a build without AITER's preshuffle kernel.
Recovers sgl-project#37685, which GitHub closed when its base branch
xinyuan/glm-5.3-flash-support was merged into main, and supersedes the
sgl-project#38544 replacement.
Co-Authored-By: Yikai Zhang <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Raiden-Makoto <[email protected]>
Squashed from #39341, which carries the same change against main and remains open there for review. Co-Authored-By: Jacob Chang <[email protected]> Co-Authored-By: Yikai Zhang <[email protected]>
Two textual conflicts, plus one the merge could not see. dsa_indexer_kpool.py imports: main added dsa_use_prefill_cp from dsa/utils while this branch added aiter_can_use_preshuffle_paged_mqa beside it and a DSAPagedMQALogitsBackend import. Independent additions, both kept. test_dsa_mqa_logits_chunking.py: main moved the chunk decision into mqa_logits_utils and rewrote the first three tests around mqa_logits_should_chunk; this branch added the k-pool split tests, which need sys/types/mock and dsa_indexer_kpool. Both import sets kept. The branch also imported dsa_indexer, which main's rewrite left unused, so it is dropped rather than tripping ruff F401. The silent one: main's mqa_logits_utils now defines MQA_LOGITS_MAX_BYTES_ROCM and MQA_LOGITS_BYTES_PER_ELEM with the same values, and for the same aiter buffer_store reason, as the private copies this branch added to dsa_indexer_kpool. Two definitions of one 2 GiB bound would have to be updated together when ROCm/aiter#5114 ships, so the private pair is removed and the shared constants are used, as dsa_indexer.py already does. The test patches the imported name accordingly.
|
/rerun-test test/registered/unit/model_executor/runner_utils/test_graph_pool_borrow.py::TestGraphPoolBorrow.test_input_logprobs_survive_replay_with_growing_chunks |
|
Results for 🚀 |
|
/rerun-failed-ci |
|
base-b: 16/20 jobs green on 2f57e29, no failures. Remaining shards ( The earlier |
…take The three layout cases compared `_kpool_cache_k_offsets` against a retyped copy of its own formula, so they stayed green if the non-pooled writer in `index_buf_accessor` ever changed its tile order -- the one drift the module docstring says it fears. Replace them with a round trip that writes through `SetKAndS.triton` and reads back through `gather_index_k_scale_prefix_into`, so both writers and the reader are pinned to each other by execution, not by a second copy of the arithmetic. The file launches no server, so it moves from `e2e/attention/` to `unit/layers/attention/` beside the chunking test, and `est_time` follows the ~8 s measured on mi35x. `_fp8_mqa_logits` hand-rolled the row split that `mqa_logits_rows_per_chunk` already implements and the DSV4 indexers already use; reuse it. With the helper's own tests covering the "everything fits" branch, the `below_the_cap_is_one_call` case is a duplicate and goes. The split case stays: it checks the wrapper's slicing and reassembly, which nothing else covers. Comments and docstrings the PR added are trimmed to the one constraint that makes each line look right. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Pushed Layout tests: three cases → one. The three cases in Chunking: reuse the existing helper, drop the duplicate case. Comments and docstrings added by the PR are trimmed to the one constraint that makes each line look right. CUDA coverage gap (not this PR's fault). The PR rewrites all five kpool cache write kernels, and on CUDA the new mi35x |
|
CUDA kpool kernel tests dispatched by hand on the
These two register on |
Adopt upstream sgl-project#39341 (k-pool DSA indexer on gfx950) and sgl-project#39779 (MXFP4 MTP draft mapper) in the conflicted files. Keep on top of them the int64 page index in the index-K prefix gather, and count aiter's 256-column row padding when splitting ragged MQA logits under the 2 GiB cap.
Reset quark.py to upstream sgl-project#39779's per-expert fused config resolution and keep only the block-FP8 activation-grouping check. Fused shared experts are CUDA-only, so the removed shared-expert precision matching loses nothing on ROCm. Drop tests whose targets are now upstream code or duplicate upstream coverage: k-pool cache layout and backend dispatch (sgl-project#39341), TileLang zero-RoPE (sgl-project#38547), transform_index widths (sgl-project#39340), mHC HIP dispatch (sgl-project#38545), the NextN name mapper, write-plan multi-pool, negative-slot scatter, and the comment-only AITER runner. Keep one focused test per production change this branch owns.
… next Adopting sgl-project#39341 reassembled the chunked ragged MQA logits into one [rows, keys] fp32 matrix before top-k. At AgentX long context that matrix reaches several GiB per rank and exhausted HBM at c32 (HSA out of resources). Restore the pre-overhaul structure: top-k consumes each capped block of rows before the next block's logits are computed.
Summary
GLM-5.3-Flash does not start on ROCm. The server dies on the first forward with
The k-pool indexer computes the scores that decide which tokens sparse attention looks at. It needs two pieces that exist only on NVIDIA — a tilelang kernel whose own selector returns
Falseoff CUDA, and DeepGEMM, which has no ROCm build. With neither available there is nothing left to call, so it raises instead of falling back.This gives ROCm those two pieces by calling AITER, and fixes the one thing that has to move with them: the memory layout of the cache AITER reads.
Scope
Two files in the ROCm k-pool indexer path, plus tests. Nothing outside that path moves.
--dsa-paged-mqa-logits-backendand AITER's capability probe decideRead and write must land together: convert one side only and the cache is misread rather than rejected, which is why this is one PR.
This does not wait on AITER. ROCm/aiter#5114 is the upstream bug report, not a fix. The row split here is the SGLang-side workaround, and it is the same one already merged for the non-pooled indexer in #36960 —
dsa_indexer.pyonmaincarries the identical bound today.Test plan
Recovery of #37685 and its #38544 replacement; rebuilt on
main@6388b6cfb, files byte-identical to #38544's head, so these numbers are carried over rather than re-run.A wrong layout never raises, it silently returns a wrong top-k — so the test runs against two deliberately broken ones as well. Image
rocm/sgl-dev:v0.5.18-rocm720-mi35x-20260901, gfx950, layout the only variable:The 2-GiB bound (@Arist12's commit, authorship intact): on 8x MI355X a 150K-token prompt is unchanged, and 300K and 600K now finish — 300K previously took all eight ranks down.
End to end, since no single PR here can serve the model on its own:
mainplus the eight open Day-0 PRs — #39338, #39339, #39340, #39341, #38545, #38546, #38547 and #39317 — which all merge cleanly onto it.rocm/sgl-dev:v0.5.19-rocm720-mi35x-20260909, MI355X TP4, decode CUDA graphs on, 1,319 GSM8K examples, one scoring pass each. Only the checkpoint differs between the two rows:zai-org/GLM-5.3-Flash, block FP8amd/GLM-5.3-Flash-Quark-MXFP4Accuracy: not attributable to this PR in isolation, and there is no standalone baseline — GLM-5.3-Flash does not start on ROCm without the rest of the stack.
CI States
Latest PR Test (Base): ⏳ Run #35778831874
Latest PR Test (Extra): ❌ Run #35778831876
Latest PR Test (AMD ROCm 10): ⏳ Run #35778831779