Repository navigation
[HIP] [FlyDSL] [JIT] Reland topk per row gfx950 (#5686) without building topk_plain on gfx1250 - #7014
Conversation
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.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
…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.
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.
…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.
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]>
Motivation
#5686 was reverted in #6991 because the first
topk_selectcall 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:
topk_plain_kernels.cu(module_topk_plain) does not build for gfx1250. Its>= 2 * opus::get_warp_size()static_asserts hold only at wave64. This was already the case before [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686.topk_plain_batches_ragged_rowsto calltopk_plain_uses_radixinmodule_topk_plain, instead of using a Python copy of the check.topk_select._availablecalls it for every fp32 call with k <= 2048, on any GPU. On gfx1250, the first call therefore JIT-buildsmodule_topk_plain, and that build fails.topk_per_row_kernels.cu,topk_per_row_sampled_kernels.cu, ...) build for gfx1250.Fix (
aiter/ops/topk_select.py):topk_selectoffersplain, and calls into its module, only on gfx942 and gfx950 (_PLAIN_ARCHES).plainis available or the arch is gfx942/gfx950. On gfx1250, routing therefore picks among argmax, small_k, decode and stream without touchingmodule_topk_plain.Test (
op_tests/test_topk_select.py):test_plain_off_its_archesroutes as gfx1250, with everymodule_topk_plainbinding replaced by one that raises. It needs no gfx1250 GPU, so it runs in the existing CI.test_plain_pitch_in_placereturns 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.GPU_ARCHS=gfx1250and the pinned CK submodule buildsmodule_topk_plain,module_top_k_per_rowandmodule_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.topk_selectuses on gfx1250 (argmax, stream, decode) were compiled withFLYDSL_GPU_ARCH=gfx1250, before and after [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686.op_tests/test_topk_select.pyop_tests/test_topk_per_row.pyop_tests/test_topk_plain.pyop_tests/test_topk_per_row_stable.pyop_tests/test_topk_row_prefill.pyTest Result
test_plain_off_its_arches: all 450 routing calls reachedmodule_topk_plainwithout the fix, and none do with it.module_topk_plainfails, on the same static_asserts as before [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686. The other two modules build. Every source gives the same result with both compilers, before and after [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686.topk_plain()directly on gfx1250 still fails to build, as it did before [HIP] [FlyDSL] [JIT] Feat/topk per row gfx950 #5686.Submission Checklist