Repository navigation
[AMD] [GLM-5.3-Flash Day 0] Support non-2048 top-k widths in the DSA page-table transform - #39340
Merged
hnyls2002 merged 10 commits intoSep 22, 2026
Conversation
transform_index_page_table_{decode,prefill}_fast both assert the top-k
width is exactly 2048. k-pool appends up to index_kpool - 1 open-tail
tokens to index_topk, so GLM-5.3-Flash hands over 2051 and both entry
points reject it.
Only the decode kernel actually needs the width. It bakes TOPK in as a
literal constexpr, reuses it as the row stride, and covers a row with one
unmasked tl.arange(0, TOPK) -- which requires a power of two. Add a tiled
variant that carries the strides explicitly and masks the trailing
partial tile, and keep the 2048 single-program path for the unpooled
width so nothing regresses there.
The prefill kernel is already width-generic: it takes TOPK as a kernel
argument, masks on topk_offsets < TOPK, and its wrapper already sizes the
grid with cdiv(topk_indices.shape[1], block_topk). Its assert only
rejected widths the kernel handles, so drop it.
Parametrize the existing test on the top-k width and add 2051 (the
GLM-5.3-Flash k-pool width), 515 (a partial trailing tile) and 257 (below
one tile) for both entry points. Register it on the AMD mi35x per-PR
suite alongside the existing CUDA registration -- the kernel is shared
and the widths are not ROCm-specific.
Recovers sgl-project#37573, which GitHub closed when its base branch
xinyuan/glm-5.3-flash-support was merged into main, and supersedes the
sgl-project#38543 replacement.
This was referenced Sep 14, 2026
Closed
2 tasks done
Jacob0226
marked this pull request as ready for review
September 14, 2026 07:56
Jacob0226
requested review from
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
September 14, 2026 07:56
This was referenced Sep 16, 2026
Raiden-Makoto
approved these changes
Sep 16, 2026
1am9trash
pushed a commit
that referenced
this pull request
Sep 17, 2026
…page-table transform Squashed from #39340, which carries the same change against main and remains open there for review. Co-Authored-By: Jacob Chang <[email protected]>
Conflict in test_dsa_transform_index.py: main renamed this test's CUDA stage to base-b-kernel-unit while this branch added the AMD mi35x registration beside it. Keep both.
Collaborator
|
MI35X stage-b run for Passed. |
hnyls2002
approved these changes
Sep 21, 2026
Conflict in transform_index.py: this branch dropped the `topk_indices.shape[1] == 2048` assert in transform_index_page_table_prefill_fast outright, while main replaced it with the width-generic `ndim == 2` / `shape[1] > 0` pair. Keep main's asserts -- they accept the k-pool widths this branch is enabling. Co-authored-by: Cursor <[email protected]>
check_registered_tests.py requires kernel tests to live under
test/registered/kernels/{ops,benchmark}/<group>/. sgl-project#32673 added this one at
test/registered/kernel/spec/, which fails the taxonomy check and turns the
lint job red on every open PR, this one included.
Move it beside the other draft/spec kernel tests in kernels/ops/speculative/.
Nothing references the old path, and register_cuda_ci(stage="base-b-kernel-unit")
is declared in the file rather than derived from it, so CI dispatch is unchanged.
Co-authored-by: Cursor <[email protected]>
hnyls2002
approved these changes
Sep 22, 2026
hdt98
added a commit
to hdt98/sglang
that referenced
this pull request
Sep 25, 2026
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.
3 of 4 tasks
4 of 5 tasks
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.
Summary
GLM-5.3-Flash's sparse attention picks 512 pools, expands them to 2048 tokens, then adds up to 3 leftover tokens from the end of the sequence. So the width it hands downstream is 2051, not 2048 — and the code that receives it asserts the width is exactly 2048, and rejects it.
Nobody has hit this yet: the default setup uses a single combined kernel that does the whole job itself, so the rejecting code never runs. Three supported setups split that job in two, and the second half is the part that rejects. None of them is AMD-specific — the assert fires on CUDA the same way.
--dsa-topk-backend torchScope
transform_index.pyonly. No environment variable, no architecture gate. The 2048 path keeps its own kernel, so every current caller keeps its performance:Only the decode kernel needed work. It bakes 2048 in as a literal
constexpr, reuses it as the row stride, and covers a row with one unmaskedtl.arange, which requires a power of two. The prefill kernel already takes the width as an argument and masks on it, so its assert only rejected widths the kernel handles.The tiled kernel produces identical output to the 2048 one at that width. The branch is there to leave the existing path alone, not because the tiled kernel is wrong.
Test plan
Unit base
rocm/sgl-dev:v0.5.18-rocm720-mi35x-20260901. The two 2048 asserts and the tiled kerneltransform_index_page_table_decode_tiled_kernelare the only variables.cd test && python3 registered/kernels/ops/attention/test_dsa_transform_index.py.AssertionErrorWidths are compared against
torch.gatherover the page table with-1for unselected slots, the reference the file already used.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.
register_amd_ci(suite="stage-b-test-1-gpu-small-amd-mi35x")added beside the file's existingregister_cuda_ci. The kernel is shared and the widths come from the model config, so both platforms want the coveragepre-commitvalidate registered test CI registriesreports the same 582 pre-existing taxonomy violations as pristinemain, i.e. none addedCI States
Latest PR Test (Base): ⏳ Run #35674235203
Latest PR Test (Extra): ❌ Run #35674235007
Latest PR Test (AMD ROCm 10): ⏳ Run #35674235129