Repository navigation
[HIP] fix(topk_per_row): support ROCm 10 by dropping hipcub::Traits dependency - #4853
Merged
Merged
Conversation
topk_per_row_kernels.cu declares its own entry points taking std::optional<aiter_tensor_t> (L2849/2854/2962) but never includes <optional>; it does not include its own header csrc/include/topk_per_row.h, which does. The TU only compiled because something else in the include set happened to drag <optional> in. On ROCm 7.0.0 nothing does, and pristine upstream fails to build: topk_per_row_kernels.cu:2849:33: error: no template named 'optional' in namespace 'std' topk_per_row_kernels.cu:2854:75: error: no member named 'nullopt' in namespace 'std' Most likely fallout from #4702 de-torching this TU: dropping the torch headers dropped the transitive <optional> with them, and the ROCm 7.2 CI image still supplies it by another path so nobody noticed. Include what we use. No functional change -- the code object is bit-identical either way; this only decides whether the file compiles. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ROCm 10 ships hipcub built on CCCL 3.0, which removed the public hipcub::Traits<> class. topk_per_row_kernels.cu used it in 13 places (11 live, 2 inside a commented-out twiddle_out), so the two modules that compile this TU -- module_top_k_per_row and module_topk_plain -- cannot be built on ROCm 10. This is the same breakage #4843 is fixing in csrc/cpp_itfs/sampling/ sampling.cuh, and literally the same code: the radix top-k twiddle_in was written in this file (#1394, 2025-11), copied within it a second time (#3087, 2026-05-10), and copied into sampling.cuh two weeks later (#3217). #4843 fixes the third copy; this fixes the first two. Rather than add a third private stand-in, put it where #4594 already moved the hipcub comparison functors -- csrc/include/hip_reduce.h now also carries aiter::radix_traits. #4594 skipped sampling.cuh because Traits "had no local equivalent"; this adds that equivalent, so #4843's local radix_traits can collapse onto it later (sampling is built through cpp_itfs, whose include list is an explicit file whitelist, so that needs three one-line changes in csrc/cpp_itfs/sampling/*.py -- out of scope here). radix_traits<float>::UnsignedBits is uint32_t, which is exactly what hipcub resolved: NumericTraits<float> -> BaseTraits<FLOATING_POINT, true, false, unsigned int, float>. It is deliberately left undefined for every other T: every instantiation of this file's radix paths is <float, ...> (mb::standalone_stable_radix_topk and ob::dispatch_topk_oneblock, 14 call sites), so a new dtype should fail to compile rather than silently pick a width. The non-float branch of twiddle_in is dropped for the same reason and replaced by a static_assert; select_min was already dead there for float (the mask is symmetric, the ordering flip lives at the call sites). The float bit math is transcribed unchanged. Validated on gfx942 + gfx950, ROCm 7.0.0 / hipcc 7.0.51831, by compiled output rather than tests alone: - ISA is byte-identical, both arches. .text, .rodata and the full disassembly of every code object in .hip_fatbin all match the pre-change build (gfx942 .text d115e671f0ea2eeb, 19 kernels, 138991 lines; gfx950 .text 051fa067e0199306, 19 kernels, 138548 lines). The raw ELF bytes are not a usable check -- .dynsym/.dynstr/.strtab/.hash differ between two builds of the *same* source -- so the harness was first self-checked by building the baseline twice and confirming .text and the disassembly are stable. - No new warnings. The 3 -Wc++23-extensions warnings the TU now emits come from block_reduce in hip_reduce.h and are pre-existing: the unmodified header alone emits the same 3, as does topk_softmax_kernels.cu and every other consumer. - module_top_k_per_row builds (19.6s). op_tests/test_topk_per_row.py 737/737 rows pass plus mb_workspace_reuse PASS; test_topk_per_row_stable.py "RESULT: ALL PASS"; test_topk_row_prefill.py standard and fast kernels both pass. Known gaps, deliberately not addressed: - Not verified on ROCm 10 -- no such toolchain here. The claim rests on this being the same edit #4843 validated in a rocm10.0.0rc3 container, removing the one symbol that errored there. - This TU still uses hipcub BlockScan / BlockLoad / BlockStore, which #4843 proves survive CCCL 3.0, and BlockRadixSort, whose ROCm 10 status neither PR covers. So this makes topk_per_row build on ROCm 10 as far as Traits is concerned; it does not make the file hipcub-free. - module_topk_plain still cannot be built here, but for an unrelated pre-existing reason: topk_plain_kernels.cu fails with ComputeTypeTraits<unsigned short> not specialized (12 errors on pristine upstream too). That file does not include hip_reduce.h. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
junhaha666
approved these changes
Aug 20, 2026
gyohuangxin
pushed a commit
to gyohuangxin/aiter
that referenced
this pull request
Aug 20, 2026
…ependency (ROCm#4853) * [topk_per_row] include <optional> where it is used topk_per_row_kernels.cu declares its own entry points taking std::optional<aiter_tensor_t> (L2849/2854/2962) but never includes <optional>; it does not include its own header csrc/include/topk_per_row.h, which does. The TU only compiled because something else in the include set happened to drag <optional> in. On ROCm 7.0.0 nothing does, and pristine upstream fails to build: topk_per_row_kernels.cu:2849:33: error: no template named 'optional' in namespace 'std' topk_per_row_kernels.cu:2854:75: error: no member named 'nullopt' in namespace 'std' Most likely fallout from ROCm#4702 de-torching this TU: dropping the torch headers dropped the transitive <optional> with them, and the ROCm 7.2 CI image still supplies it by another path so nobody noticed. Include what we use. No functional change -- the code object is bit-identical either way; this only decides whether the file compiles. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [topk_per_row] drop the hipcub::Traits dependency ROCm 10 ships hipcub built on CCCL 3.0, which removed the public hipcub::Traits<> class. topk_per_row_kernels.cu used it in 13 places (11 live, 2 inside a commented-out twiddle_out), so the two modules that compile this TU -- module_top_k_per_row and module_topk_plain -- cannot be built on ROCm 10. This is the same breakage ROCm#4843 is fixing in csrc/cpp_itfs/sampling/ sampling.cuh, and literally the same code: the radix top-k twiddle_in was written in this file (ROCm#1394, 2025-11), copied within it a second time (ROCm#3087, 2026-05-10), and copied into sampling.cuh two weeks later (ROCm#3217). ROCm#4843 fixes the third copy; this fixes the first two. Rather than add a third private stand-in, put it where ROCm#4594 already moved the hipcub comparison functors -- csrc/include/hip_reduce.h now also carries aiter::radix_traits. ROCm#4594 skipped sampling.cuh because Traits "had no local equivalent"; this adds that equivalent, so ROCm#4843's local radix_traits can collapse onto it later (sampling is built through cpp_itfs, whose include list is an explicit file whitelist, so that needs three one-line changes in csrc/cpp_itfs/sampling/*.py -- out of scope here). radix_traits<float>::UnsignedBits is uint32_t, which is exactly what hipcub resolved: NumericTraits<float> -> BaseTraits<FLOATING_POINT, true, false, unsigned int, float>. It is deliberately left undefined for every other T: every instantiation of this file's radix paths is <float, ...> (mb::standalone_stable_radix_topk and ob::dispatch_topk_oneblock, 14 call sites), so a new dtype should fail to compile rather than silently pick a width. The non-float branch of twiddle_in is dropped for the same reason and replaced by a static_assert; select_min was already dead there for float (the mask is symmetric, the ordering flip lives at the call sites). The float bit math is transcribed unchanged. Validated on gfx942 + gfx950, ROCm 7.0.0 / hipcc 7.0.51831, by compiled output rather than tests alone: - ISA is byte-identical, both arches. .text, .rodata and the full disassembly of every code object in .hip_fatbin all match the pre-change build (gfx942 .text d115e671f0ea2eeb, 19 kernels, 138991 lines; gfx950 .text 051fa067e0199306, 19 kernels, 138548 lines). The raw ELF bytes are not a usable check -- .dynsym/.dynstr/.strtab/.hash differ between two builds of the *same* source -- so the harness was first self-checked by building the baseline twice and confirming .text and the disassembly are stable. - No new warnings. The 3 -Wc++23-extensions warnings the TU now emits come from block_reduce in hip_reduce.h and are pre-existing: the unmodified header alone emits the same 3, as does topk_softmax_kernels.cu and every other consumer. - module_top_k_per_row builds (19.6s). op_tests/test_topk_per_row.py 737/737 rows pass plus mb_workspace_reuse PASS; test_topk_per_row_stable.py "RESULT: ALL PASS"; test_topk_row_prefill.py standard and fast kernels both pass. Known gaps, deliberately not addressed: - Not verified on ROCm 10 -- no such toolchain here. The claim rests on this being the same edit ROCm#4843 validated in a rocm10.0.0rc3 container, removing the one symbol that errored there. - This TU still uses hipcub BlockScan / BlockLoad / BlockStore, which ROCm#4843 proves survive CCCL 3.0, and BlockRadixSort, whose ROCm 10 status neither PR covers. So this makes topk_per_row build on ROCm 10 as far as Traits is concerned; it does not make the file hipcub-free. - module_topk_plain still cannot be built here, but for an unrelated pre-existing reason: topk_plain_kernels.cu fails with ComputeTypeTraits<unsigned short> not specialized (12 errors on pristine upstream too). That file does not include hip_reduce.h. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
gyohuangxin
added a commit
that referenced
this pull request
Aug 20, 2026
* [HIP] fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency (#4843) * fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency ROCm 10's hipcub removed the deprecated `hipcub::Traits<T>` class, so `csrc/cpp_itfs/sampling/sampling.cuh` failed to compile: error: no type named 'Traits' in namespace 'hipcub' which is why #4754 disabled cpp_itfs sampling on ROCm 10 entirely. The radix_topk code only used `hipcub::Traits<T>::UnsignedBits`, and only ever with T=float. Replace it with a self-contained `radix_traits<float>` (UnsignedBits = uint32_t). The float twiddle logic is byte-identical to the previous float branch (select_min was already a no-op for float), so runtime behavior is unchanged. With the toolchain incompatibility fixed, re-enable the kernels on ROCm 10: - remove the ROCm-10 import guard (csrc/cpp_itfs/sampling/__init__.py) - revert the ROCm-10 skip in op_tests/test_sampling.py Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(sampling): drop removed hipcub::Max/Min functors for ROCm 10 ROCm 10 hipcub (CCCL 3.0) no longer exposes the deprecated hipcub::Max / hipcub::Min reduction functors, so BlockReduce().Reduce(..., hipcub::Max()/Min()) failed with "no member named 'Max'/'Min' in namespace 'hipcub'". This surfaced only on the real ROCm 10 image after the hipcub::Traits fix. Replace them with self-contained AiterMaxOp / AiterMinOp functors (same semantics), keeping sampling.cuh independent of hipcub symbols that change across ROCm versions. Validated on rocm/ufb-private ...rocm10.0.0rc3 (hipcub 5.0 / CCCL 3.0, torch 2.12.0+rocm10.0.0rc3, MI308X): all three sampling ops compile for gfx942/gfx950 and op_tests/test_sampling.py passes 348 passed, 4 skipped (matched runtime, no HIP_LAUNCH_BLOCKING). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: sixifang <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> * [HIP] fix(topk_per_row): support ROCm 10 by dropping hipcub::Traits dependency (#4853) * [topk_per_row] include <optional> where it is used topk_per_row_kernels.cu declares its own entry points taking std::optional<aiter_tensor_t> (L2849/2854/2962) but never includes <optional>; it does not include its own header csrc/include/topk_per_row.h, which does. The TU only compiled because something else in the include set happened to drag <optional> in. On ROCm 7.0.0 nothing does, and pristine upstream fails to build: topk_per_row_kernels.cu:2849:33: error: no template named 'optional' in namespace 'std' topk_per_row_kernels.cu:2854:75: error: no member named 'nullopt' in namespace 'std' Most likely fallout from #4702 de-torching this TU: dropping the torch headers dropped the transitive <optional> with them, and the ROCm 7.2 CI image still supplies it by another path so nobody noticed. Include what we use. No functional change -- the code object is bit-identical either way; this only decides whether the file compiles. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [topk_per_row] drop the hipcub::Traits dependency ROCm 10 ships hipcub built on CCCL 3.0, which removed the public hipcub::Traits<> class. topk_per_row_kernels.cu used it in 13 places (11 live, 2 inside a commented-out twiddle_out), so the two modules that compile this TU -- module_top_k_per_row and module_topk_plain -- cannot be built on ROCm 10. This is the same breakage #4843 is fixing in csrc/cpp_itfs/sampling/ sampling.cuh, and literally the same code: the radix top-k twiddle_in was written in this file (#1394, 2025-11), copied within it a second time (#3087, 2026-05-10), and copied into sampling.cuh two weeks later (#3217). #4843 fixes the third copy; this fixes the first two. Rather than add a third private stand-in, put it where #4594 already moved the hipcub comparison functors -- csrc/include/hip_reduce.h now also carries aiter::radix_traits. #4594 skipped sampling.cuh because Traits "had no local equivalent"; this adds that equivalent, so #4843's local radix_traits can collapse onto it later (sampling is built through cpp_itfs, whose include list is an explicit file whitelist, so that needs three one-line changes in csrc/cpp_itfs/sampling/*.py -- out of scope here). radix_traits<float>::UnsignedBits is uint32_t, which is exactly what hipcub resolved: NumericTraits<float> -> BaseTraits<FLOATING_POINT, true, false, unsigned int, float>. It is deliberately left undefined for every other T: every instantiation of this file's radix paths is <float, ...> (mb::standalone_stable_radix_topk and ob::dispatch_topk_oneblock, 14 call sites), so a new dtype should fail to compile rather than silently pick a width. The non-float branch of twiddle_in is dropped for the same reason and replaced by a static_assert; select_min was already dead there for float (the mask is symmetric, the ordering flip lives at the call sites). The float bit math is transcribed unchanged. Validated on gfx942 + gfx950, ROCm 7.0.0 / hipcc 7.0.51831, by compiled output rather than tests alone: - ISA is byte-identical, both arches. .text, .rodata and the full disassembly of every code object in .hip_fatbin all match the pre-change build (gfx942 .text d115e671f0ea2eeb, 19 kernels, 138991 lines; gfx950 .text 051fa067e0199306, 19 kernels, 138548 lines). The raw ELF bytes are not a usable check -- .dynsym/.dynstr/.strtab/.hash differ between two builds of the *same* source -- so the harness was first self-checked by building the baseline twice and confirming .text and the disassembly are stable. - No new warnings. The 3 -Wc++23-extensions warnings the TU now emits come from block_reduce in hip_reduce.h and are pre-existing: the unmodified header alone emits the same 3, as does topk_softmax_kernels.cu and every other consumer. - module_top_k_per_row builds (19.6s). op_tests/test_topk_per_row.py 737/737 rows pass plus mb_workspace_reuse PASS; test_topk_per_row_stable.py "RESULT: ALL PASS"; test_topk_row_prefill.py standard and fast kernels both pass. Known gaps, deliberately not addressed: - Not verified on ROCm 10 -- no such toolchain here. The claim rests on this being the same edit #4843 validated in a rocm10.0.0rc3 container, removing the one symbol that errored there. - This TU still uses hipcub BlockScan / BlockLoad / BlockStore, which #4843 proves survive CCCL 3.0, and BlockRadixSort, whose ROCm 10 status neither PR covers. So this makes topk_per_row build on ROCm 10 as far as Traits is concerned; it does not make the file hipcub-free. - module_topk_plain still cannot be built here, but for an unrelated pre-existing reason: topk_plain_kernels.cu fails with ComputeTypeTraits<unsigned short> not specialized (12 errors on pristine upstream too). That file does not include hip_reduce.h. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: who who who <[email protected]> Co-authored-by: sixifang <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: zufayu <[email protected]> Co-authored-by: zufayu <[email protected]>
nsakkine
pushed a commit
to nsakkine/aiter
that referenced
this pull request
Aug 21, 2026
…ependency (ROCm#4853) * [topk_per_row] include <optional> where it is used topk_per_row_kernels.cu declares its own entry points taking std::optional<aiter_tensor_t> (L2849/2854/2962) but never includes <optional>; it does not include its own header csrc/include/topk_per_row.h, which does. The TU only compiled because something else in the include set happened to drag <optional> in. On ROCm 7.0.0 nothing does, and pristine upstream fails to build: topk_per_row_kernels.cu:2849:33: error: no template named 'optional' in namespace 'std' topk_per_row_kernels.cu:2854:75: error: no member named 'nullopt' in namespace 'std' Most likely fallout from ROCm#4702 de-torching this TU: dropping the torch headers dropped the transitive <optional> with them, and the ROCm 7.2 CI image still supplies it by another path so nobody noticed. Include what we use. No functional change -- the code object is bit-identical either way; this only decides whether the file compiles. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [topk_per_row] drop the hipcub::Traits dependency ROCm 10 ships hipcub built on CCCL 3.0, which removed the public hipcub::Traits<> class. topk_per_row_kernels.cu used it in 13 places (11 live, 2 inside a commented-out twiddle_out), so the two modules that compile this TU -- module_top_k_per_row and module_topk_plain -- cannot be built on ROCm 10. This is the same breakage ROCm#4843 is fixing in csrc/cpp_itfs/sampling/ sampling.cuh, and literally the same code: the radix top-k twiddle_in was written in this file (ROCm#1394, 2025-11), copied within it a second time (ROCm#3087, 2026-05-10), and copied into sampling.cuh two weeks later (ROCm#3217). ROCm#4843 fixes the third copy; this fixes the first two. Rather than add a third private stand-in, put it where ROCm#4594 already moved the hipcub comparison functors -- csrc/include/hip_reduce.h now also carries aiter::radix_traits. ROCm#4594 skipped sampling.cuh because Traits "had no local equivalent"; this adds that equivalent, so ROCm#4843's local radix_traits can collapse onto it later (sampling is built through cpp_itfs, whose include list is an explicit file whitelist, so that needs three one-line changes in csrc/cpp_itfs/sampling/*.py -- out of scope here). radix_traits<float>::UnsignedBits is uint32_t, which is exactly what hipcub resolved: NumericTraits<float> -> BaseTraits<FLOATING_POINT, true, false, unsigned int, float>. It is deliberately left undefined for every other T: every instantiation of this file's radix paths is <float, ...> (mb::standalone_stable_radix_topk and ob::dispatch_topk_oneblock, 14 call sites), so a new dtype should fail to compile rather than silently pick a width. The non-float branch of twiddle_in is dropped for the same reason and replaced by a static_assert; select_min was already dead there for float (the mask is symmetric, the ordering flip lives at the call sites). The float bit math is transcribed unchanged. Validated on gfx942 + gfx950, ROCm 7.0.0 / hipcc 7.0.51831, by compiled output rather than tests alone: - ISA is byte-identical, both arches. .text, .rodata and the full disassembly of every code object in .hip_fatbin all match the pre-change build (gfx942 .text d115e671f0ea2eeb, 19 kernels, 138991 lines; gfx950 .text 051fa067e0199306, 19 kernels, 138548 lines). The raw ELF bytes are not a usable check -- .dynsym/.dynstr/.strtab/.hash differ between two builds of the *same* source -- so the harness was first self-checked by building the baseline twice and confirming .text and the disassembly are stable. - No new warnings. The 3 -Wc++23-extensions warnings the TU now emits come from block_reduce in hip_reduce.h and are pre-existing: the unmodified header alone emits the same 3, as does topk_softmax_kernels.cu and every other consumer. - module_top_k_per_row builds (19.6s). op_tests/test_topk_per_row.py 737/737 rows pass plus mb_workspace_reuse PASS; test_topk_per_row_stable.py "RESULT: ALL PASS"; test_topk_row_prefill.py standard and fast kernels both pass. Known gaps, deliberately not addressed: - Not verified on ROCm 10 -- no such toolchain here. The claim rests on this being the same edit ROCm#4843 validated in a rocm10.0.0rc3 container, removing the one symbol that errored there. - This TU still uses hipcub BlockScan / BlockLoad / BlockStore, which ROCm#4843 proves survive CCCL 3.0, and BlockRadixSort, whose ROCm 10 status neither PR covers. So this makes topk_per_row build on ROCm 10 as far as Traits is concerned; it does not make the file hipcub-free. - module_topk_plain still cannot be built here, but for an unrelated pre-existing reason: topk_plain_kernels.cu fails with ComputeTypeTraits<unsigned short> not specialized (12 errors on pristine upstream too). That file does not include hip_reduce.h. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This was referenced Aug 21, 2026
nsakkine
pushed a commit
to nsakkine/aiter
that referenced
this pull request
Aug 24, 2026
…ependency (ROCm#4853) * [topk_per_row] include <optional> where it is used topk_per_row_kernels.cu declares its own entry points taking std::optional<aiter_tensor_t> (L2849/2854/2962) but never includes <optional>; it does not include its own header csrc/include/topk_per_row.h, which does. The TU only compiled because something else in the include set happened to drag <optional> in. On ROCm 7.0.0 nothing does, and pristine upstream fails to build: topk_per_row_kernels.cu:2849:33: error: no template named 'optional' in namespace 'std' topk_per_row_kernels.cu:2854:75: error: no member named 'nullopt' in namespace 'std' Most likely fallout from ROCm#4702 de-torching this TU: dropping the torch headers dropped the transitive <optional> with them, and the ROCm 7.2 CI image still supplies it by another path so nobody noticed. Include what we use. No functional change -- the code object is bit-identical either way; this only decides whether the file compiles. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [topk_per_row] drop the hipcub::Traits dependency ROCm 10 ships hipcub built on CCCL 3.0, which removed the public hipcub::Traits<> class. topk_per_row_kernels.cu used it in 13 places (11 live, 2 inside a commented-out twiddle_out), so the two modules that compile this TU -- module_top_k_per_row and module_topk_plain -- cannot be built on ROCm 10. This is the same breakage ROCm#4843 is fixing in csrc/cpp_itfs/sampling/ sampling.cuh, and literally the same code: the radix top-k twiddle_in was written in this file (ROCm#1394, 2025-11), copied within it a second time (ROCm#3087, 2026-05-10), and copied into sampling.cuh two weeks later (ROCm#3217). ROCm#4843 fixes the third copy; this fixes the first two. Rather than add a third private stand-in, put it where ROCm#4594 already moved the hipcub comparison functors -- csrc/include/hip_reduce.h now also carries aiter::radix_traits. ROCm#4594 skipped sampling.cuh because Traits "had no local equivalent"; this adds that equivalent, so ROCm#4843's local radix_traits can collapse onto it later (sampling is built through cpp_itfs, whose include list is an explicit file whitelist, so that needs three one-line changes in csrc/cpp_itfs/sampling/*.py -- out of scope here). radix_traits<float>::UnsignedBits is uint32_t, which is exactly what hipcub resolved: NumericTraits<float> -> BaseTraits<FLOATING_POINT, true, false, unsigned int, float>. It is deliberately left undefined for every other T: every instantiation of this file's radix paths is <float, ...> (mb::standalone_stable_radix_topk and ob::dispatch_topk_oneblock, 14 call sites), so a new dtype should fail to compile rather than silently pick a width. The non-float branch of twiddle_in is dropped for the same reason and replaced by a static_assert; select_min was already dead there for float (the mask is symmetric, the ordering flip lives at the call sites). The float bit math is transcribed unchanged. Validated on gfx942 + gfx950, ROCm 7.0.0 / hipcc 7.0.51831, by compiled output rather than tests alone: - ISA is byte-identical, both arches. .text, .rodata and the full disassembly of every code object in .hip_fatbin all match the pre-change build (gfx942 .text d115e671f0ea2eeb, 19 kernels, 138991 lines; gfx950 .text 051fa067e0199306, 19 kernels, 138548 lines). The raw ELF bytes are not a usable check -- .dynsym/.dynstr/.strtab/.hash differ between two builds of the *same* source -- so the harness was first self-checked by building the baseline twice and confirming .text and the disassembly are stable. - No new warnings. The 3 -Wc++23-extensions warnings the TU now emits come from block_reduce in hip_reduce.h and are pre-existing: the unmodified header alone emits the same 3, as does topk_softmax_kernels.cu and every other consumer. - module_top_k_per_row builds (19.6s). op_tests/test_topk_per_row.py 737/737 rows pass plus mb_workspace_reuse PASS; test_topk_per_row_stable.py "RESULT: ALL PASS"; test_topk_row_prefill.py standard and fast kernels both pass. Known gaps, deliberately not addressed: - Not verified on ROCm 10 -- no such toolchain here. The claim rests on this being the same edit ROCm#4843 validated in a rocm10.0.0rc3 container, removing the one symbol that errored there. - This TU still uses hipcub BlockScan / BlockLoad / BlockStore, which ROCm#4843 proves survive CCCL 3.0, and BlockRadixSort, whose ROCm 10 status neither PR covers. So this makes topk_per_row build on ROCm 10 as far as Traits is concerned; it does not make the file hipcub-free. - module_topk_plain still cannot be built here, but for an unrelated pre-existing reason: topk_plain_kernels.cu fails with ComputeTypeTraits<unsigned short> not specialized (12 errors on pristine upstream too). That file does not include hip_reduce.h. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
2 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
Re-enable
topk_per_rowon ROCm 10 by removing itshipcub::Traitsdependency,and put the replacement where aiter already keeps its hipcub stand-ins
(
csrc/include/hip_reduce.h).This is the same breakage #4843 is fixing in
csrc/cpp_itfs/sampling/sampling.cuh,in the other file that has it. The two are not merely similar — they are copies of
the same code (see below). #4843 fixes one copy; this fixes the other two.
Root cause
ROCm 10 ships hipcub built on CCCL 3.0, which removed the public
hipcub::Traits<>class.csrc/kernels/topk_per_row_kernels.cuuses it in 13places (11 live, 2 inside a commented-out
twiddle_out), so both modules thatcompile this TU —
module_top_k_per_rowandmodule_topk_plain— fail to buildon ROCm 10 with the same error #4843 reports:
Why there are three copies
git blameon the radix top-ktwiddle_in:topk_per_row_kernels.cuL105 (aiter::mb)topk_per_row_kernels.cuL971 (aiter::ob)sampling.cuhL87Same function body, character for character. #4843 covers the third row only.
Fix
csrc/include/hip_reduce.h— addaiter::radix_traits, next to theMax/Min/Sum/ArgMax/ArgMinfunctors #4594 moved there.radix_traits<float>::UnsignedBitsis
uint32_t, which is exactly what hipcub resolved:NumericTraits<float>→BaseTraits<FLOATING_POINT, true, false, unsigned int, float>.Deliberately left undefined for every other
T.#4594's message noted it skipped
sampling.cuhbecauseTraits"had no localequivalent". This adds that equivalent, so #4843's file-local
radix_traitscancollapse onto it afterwards. That is a follow-up, not this PR: sampling builds
through
cpp_itfs, whose include set is an explicit file whitelist, so it needsthree one-line changes in
csrc/cpp_itfs/sampling/*.py.csrc/kernels/topk_per_row_kernels.cu— route all 11 live uses throughaiter::radix_traits. Bothtwiddle_incopies lose their non-floatelsebranchin favour of a
static_assert; every instantiation of this file's radix paths is<float, ...>(mb::standalone_stable_radix_topkandob::dispatch_topk_oneblock,14 call sites), so a new dtype should fail to compile rather than silently pick a
width.
select_minwas already dead in the float branch — the mask is symmetric andthe ordering flip lives at the call sites. The float bit math is transcribed
unchanged. The commented-out
twiddle_outis deleted; it referencedhipcub::Traits<T>::TwiddleOut.The first commit is separate and unrelated to
Traits: this TU declares its ownentry points taking
std::optional<aiter_tensor_t>but never includes<optional>(it does not include its own header, which does). On ROCm 7.0.0 nothing supplies it
transitively and pristine upstream does not compile. Probably fallout from #4702
de-torching this TU. Split out so it can be taken or dropped on its own.
Validation
gfx942 + gfx950, ROCm 7.0.0 / hipcc 7.0.51831 / torch 2.9.1+rocm7.0.
ISA is byte-identical on both arches.
.text,.rodata, and the fulldisassembly of every code object in
.hip_fatbinall match the pre-change build:.textd115e671f0ea2eebunchanged051fa067e0199306unchangedNote for anyone reproducing this: the raw code-object ELF bytes are not a usable
check —
.dynsym/.dynstr/.strtab/.hashdiffer between two builds of thesame source. The harness was self-checked first by building the baseline twice and
confirming
.textand the disassembly are stable across runs.No new warnings. The 3
-Wc++23-extensionswarnings this TU now emits come fromblock_reduceinhip_reduce.hand are pre-existing: the unmodified header on itsown emits the same 3, as does
topk_softmax_kernels.cuand every other consumer.Build and tests.
module_top_k_per_rowbuilds in 19.6s.op_tests/test_topk_per_row.py737/737 rows pass plusmb_workspace_reusePASS;op_tests/test_topk_per_row_stable.pyreportsRESULT: ALL PASS;op_tests/test_topk_row_prefill.pystandard and fast kernels both pass.Known gaps
Listing these so the PR is not read as "topk_per_row is ROCm 10 clean now".
this being the same edit [HIP] fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency #4843 validated in a
rocm10.0.0rc3container, removingthe one symbol that errored there. Someone with that image should confirm.
BlockScan/BlockLoad/BlockStore, which [HIP] fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency #4843 shows survive CCCL 3.0, andBlockRadixSort, whoseROCm 10 status neither PR covers. Fixing
Traitsis what unblocks the build; itis not the whole hipcub surface.
module_topk_plainstill does not build here, for an unrelated pre-existingreason:
topk_plain_kernels.cufails withComputeTypeTraits<unsigned short>notspecialized (12 errors on pristine upstream as well). That file does not include
hip_reduce.hand is untouched here..github/pins ROCm 7.2 throughout and mentions 10 nowhere, soneither this nor [HIP] fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency #4843 is guarded against regression. Worth a separate issue.
Relationship to #4843
Independent — different file, different modules, different tests. Either can merge
first. Once both are in, #4843's local
radix_traitsand this one should become asingle definition.
🤖 Generated with Claude Code