Skip to content

[HIP] [FlyDSL] [JIT] Reland topk per row gfx950 (#5686) without building topk_plain on gfx1250 - #7014

Merged
junhaha666 merged 2 commits into
ROCm:mainfrom
AFDEAPAC:feat/topk-per-row-gfx950-reland
Oct 28, 2026
Merged

junhaha666 merged 2 commits into
ROCm:mainfrom
AFDEAPAC:feat/topk-per-row-gfx950-reland

Conversation

@MHYangAMD

Copy link
Copy Markdown
Contributor

Motivation

#5686 was reverted in #6991 because the first topk_select call on gfx1250 failed to compile. This PR relands #5686 with a fix for that failure. The first commit reapplies #5686 unchanged, and its description, review history and measurements are in #5686. The second commit fixes the gfx1250 build.

Technical Details

Cause:

Fix (aiter/ops/topk_select.py):

  • topk_select offers plain, and calls into its module, only on gfx942 and gfx950 (_PLAIN_ARCHES).
  • The other shape rules call that module only when plain is available or the arch is gfx942/gfx950. On gfx1250, routing therefore picks among argmax, small_k, decode and stream without touching module_topk_plain.
  • Routing on gfx942 and gfx950 is unchanged.

Test (op_tests/test_topk_select.py):

  • test_plain_off_its_arches routes as gfx1250, with every module_topk_plain binding replaced by one that raises. It needs no gfx1250 GPU, so it runs in the existing CI. test_plain_pitch_in_place returns early where plain is not offered.

Test Plan

  • test_plain_off_its_arches, run once on the reapplied [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686 alone and once with the fix.
  • gfx1250 build without gfx1250 hardware: the aiter JIT with GPU_ARCHS=gfx1250 and the pinned CK submodule builds module_topk_plain, module_top_k_per_row and module_top_k_per_row_sampled. Each topk source was also compiled for gfx1250 with the ROCm 10.0 and 7.14 compilers, before and after [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686.
  • The FlyDSL backends topk_select uses on gfx1250 (argmax, stream, decode) were compiled with FLYDSL_GPU_ARCH=gfx1250, before and after [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686.
  • On gfx950 and gfx942:
    • op_tests/test_topk_select.py
    • op_tests/test_topk_per_row.py
    • op_tests/test_topk_plain.py
  • On gfx950 only:
    • op_tests/test_topk_per_row_stable.py
    • op_tests/test_topk_row_prefill.py
  • black and ruff.

Test Result

Submission Checklist

topk_plain_batches_ragged_rows now asks plain's module (topk_plain_uses_radix)
rather than a Python mirror of it, and _available asks it for every fp32 call
with k <= 2048 on any GPU. On gfx1250 the first topk_select call therefore
builds module_topk_plain, and that build fails: topk_plain_kernels.cu's
`>= 2 * opus::get_warp_size()` static_asserts do not hold at wave32. It fails
the same way without this branch; every other topk translation unit builds
for gfx1250.

plain is now offered, and its module asked, on gfx942 and gfx950 only. The
other shape rules ask it only where plain is in the set or the arch is one of
those two, so a gfx1250 call routes among argmax, small_k, decode and stream
without touching the module. test_plain_off_its_arches routes as gfx1250 with
every module_topk_plain binding refusing: all 450 of its calls asked one
before this change, none after.
@MHYangAMD
MHYangAMD requested a review from a team October 27, 2026 11:10
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7014 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@junhaha666
junhaha666 merged commit 92d7a1d into ROCm:main Oct 28, 2026
59 checks passed
@MHYangAMD
MHYangAMD deleted the feat/topk-per-row-gfx950-reland branch October 28, 2026 08:35
vpietila-amd pushed a commit that referenced this pull request Oct 28, 2026
…ing topk_plain on gfx1250 (#7014)

* Reapply "[HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 (#5686)" (#6991)

This reverts commit 93d4679.

* topk_select: keep plain's module off the arches it does not build for

topk_plain_batches_ragged_rows now asks plain's module (topk_plain_uses_radix)
rather than a Python mirror of it, and _available asks it for every fp32 call
with k <= 2048 on any GPU. On gfx1250 the first topk_select call therefore
builds module_topk_plain, and that build fails: topk_plain_kernels.cu's
`>= 2 * opus::get_warp_size()` static_asserts do not hold at wave32. It fails
the same way without this branch; every other topk translation unit builds
for gfx1250.

plain is now offered, and its module asked, on gfx942 and gfx950 only. The
other shape rules ask it only where plain is in the set or the arch is one of
those two, so a gfx1250 call routes among argmax, small_k, decode and stream
without touching the module. test_plain_off_its_arches routes as gfx1250 with
every module_topk_plain binding refusing: all 450 of its calls asked one
before this change, none after.
JH-Leon-KIM-AMD added a commit that referenced this pull request Oct 28, 2026
main's reland of #5686 (#7014) rewrote the dispatch the decode gate sits
in, so four files conflicted.

- topk_select.py: main's `_dispatch` now returns gathered values and
  takes `with_values`; `max_row_len` is carried alongside it, at the new
  call site too.
- test_topk_per_row.py: main grew `--regressions` with five `sampled`
  checks while this branch had replaced it with `--sections`. The checks
  are now a `regressions` section that runs `--regressions`' list, so
  `--sections adaptive` still runs only the adaptive tests and a plain
  `python3 <file>` runs everything once.
- `_choose` gained `stride0`, `device` and `allow_sampled`; the bounded
  entry-point test passes them as `topk_select` itself does. This did not
  conflict and failed only at run time.

`top_k_per_row_decode()` is unchanged on main, so the gate's fallback is
the same kernel it was fitted against. What did change is that
`topk_select` now sends gfx950 ragged k=2048 rows up to width 8191 to
`stream`, and past width 65535 or at 256+ rows to its general rules, ahead
of the decode arm; the band timings have not been re-taken for that.

test_topk_per_row.py, test_topk_per_row_stable.py and test_topk_select.py
pass on MI355X (gfx950, 256 CU) with FlyDSL 0.4.0. gfx942 was not re-run.
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
…ing topk_plain on gfx1250 (#7014)

* Reapply "[HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 (#5686)" (#6991)

This reverts commit 93d4679.

* topk_select: keep plain's module off the arches it does not build for

topk_plain_batches_ragged_rows now asks plain's module (topk_plain_uses_radix)
rather than a Python mirror of it, and _available asks it for every fp32 call
with k <= 2048 on any GPU. On gfx1250 the first topk_select call therefore
builds module_topk_plain, and that build fails: topk_plain_kernels.cu's
`>= 2 * opus::get_warp_size()` static_asserts do not hold at wave32. It fails
the same way without this branch; every other topk translation unit builds
for gfx1250.

plain is now offered, and its module asked, on gfx942 and gfx950 only. The
other shape rules ask it only where plain is in the set or the arch is one of
those two, so a gfx1250 call routes among argmax, small_k, decode and stream
without touching the module. test_plain_off_its_arches routes as gfx1250 with
every module_topk_plain binding refusing: all 450 of its calls asked one
before this change, none after.
MengqingCao added a commit to ROCm/ATOM that referenced this pull request Dec 3, 2026
The FlyDSL prewarm note had been inserted between ROCm/aiter#7014 and the
"fp4" clause of the minimum-aiter sentence, so #7057, #7060, #7061 and #7056
read as part of the warmup steps. The sentence is whole again and the note
follows the minimum-aiter paragraph; it now also names 20480 tokens as where
gfx950 TP1 prefill first reaches the 256-block bucket.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants