Repository navigation
Clean rocprim/hipcub in hip kernels - #4594
Merged
Merged
Conversation
De-torch module_mhc so its heavy kernel translation unit no longer pulls in LibTorch/ATen/c10 headers, with zero numerical change. - mhc_kernels.cu: torch::Tensor& -> aiter_tensor_t&; ATen device guard/ stream -> HipDeviceGuard + aiter::getCurrentHIPStream; AITER_DISPATCH_FLOATING16_TYPES + t2opus -> _rmTorch variant + hip2opus; TORCH_CHECK -> AITER_CHECK (sizes() compare -> per-dim compare); drop py_itfs_common.h / dispatch_utils.h / ATen guard includes and define AITER_NO_TORCH_TYPES so aiter_opus_plus.h skips the c10 include. - mhc.h: aiter_tensor_t signatures, launch_mhc_post_raw takes AiterDtype instead of c10::ScalarType, drop torch/extension.h + ATen/hip/HIPContext.h. - fused_ar_mhc_post.cu: sole external caller of launch_mhc_post_raw -- scalar_type_for_ar_mhc_post -> aiter_dtype_for_ar_mhc_post, thread AiterDtype through run_ar_mhc_post_split. The file itself keeps its torch::Tensor API. - pybind + rocm_ops: add aiter_stream.h and AITER_SET_STREAM_PYBIND. - ops/mhc.py: add develop=True to the 5 module_mhc ops (auto-converts torch.Tensor args/kwargs and sets the HIP stream). Validated on gfx950: 132 output tensors (5 ops x hidden 1280/2560/4096/7168 x m 17/128/1024) are bit-identical to the pre-change build. hipcc -M reports 0 torch/ATen/c10 headers and nm reports 0 c10::/at:: undefined symbols in mhc_kernels.cuda.o. op_tests/test_mhc.py passes for default / --fuse_rmsnorm / --hc_head / --fn_pack_bf16 / --largeM (hip_err 0); module_fused_ar_mhc builds and its tp2 multigpu smoke test passes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mhc_kernels.cu references no rocprim:: or hipcub:: symbol -- the two includes were dead. Removing them keeps the TU's include set to what it actually uses; build-time effect is negligible (~0.3s of 19s on mhc_kernels.cuda.o), the point is hygiene. Output stays bit-identical (same 132-tensor check as the parent commit); module_fused_ar_mhc, which also compiles this TU, still builds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
hip_reduce.h used exactly two rocPRIM primitives -- warp_move_dpp (28 call sites) and warp_shuffle (6) -- to pull in all of <rocprim/rocprim.hpp>. Both are thin word-wise wrappers over compiler builtins, so reimplement them in a local aiter_dpp namespace and drop the include. warp_move_dpp additionally lived in rocprim::detail, an internal namespace we should not have been depending on; the new move_dpp keeps the same template parameters and defaults (row_mask/bank_mask 0xf, bound_ctrl false), and word_wise mirrors rocprim::detail::warp_shuffle_op including its split between the bit_cast fast path and the memcpy path for sizes that are not a multiple of 4. The file already used this bit_cast idiom in warp_permlanex16 / thread_broadcast, so the new helpers match local style. Blast radius is 17 TUs / 14 modules, since aiter_opus_plus.h includes this header. Validated on gfx950: - all 14 modules rebuild from scratch; - 167 output tensors bit-identical to the rocPRIM build -- 132 from the 5 mhc ops plus 35 covering dynamic_per_token / per_group quant (group_size 32/128, i.e. the narrow 2/4/8/16-thread multithread_reduce widths), rmsnorm, silu_and_mul and topk_gating (all 3 score_funcs, exercising wave_reduce and multithread_reduce_max_dpp); - op tests pass: test_moe_topk_gating 908 passed, test_rmsnorm2d 810, test_activation 789, test_mhc hip_err 0. Build time drops only where hip_reduce.h was the sole source of rocprim, as expected: module_mhc 27.4s -> 25.6s, module_cache 21.4 -> 19.8, module_moe_topk 40.6 -> 38.3; module_quant / module_activation are flat because their TUs still include <rocprim/rocprim.hpp> themselves. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Ten kernel TUs pulled in <hipcub/hipcub.hpp> for two things: the comparison functors (Max/Min/Sum/ArgMax/ArgMin plus KeyValuePair) and BlockReduce. Reimplement the functors in hip_reduce.h under namespace aiter, move the 10 BlockReduce call sites onto the block_reduce that already lives in that header, and drop the includes. The functors are transcribed rather than rewritten: Max/Min compare the second argument against the first, which is what decides the winner when one operand is NaN, and ArgMax/ArgMin break value ties on the smaller key so the result does not depend on the order lanes happen to be combined in. Both match hipcub expression for expression, so no call site shifts results. block_reduce needed one fix before it could take the BlockReduce<KeyValuePair> callers: its cross-wave staging buffer was hardcoded to `__shared__ float smem[waves]` regardless of T. That has a side effect outside this diff -- cache_kernels.cu:555 reduces an int through block_reduce, so the old code round-tripped the value int -> float -> int, visible as a v_cvt_f32_i32 / v_cvt_i32_f32 pair in reshape_and_cache_with_block_quant that is now gone. It narrowed silently above 2^24; tokens_in_block never gets that large in practice, but the type is now honest and the kernel is 2 instructions shorter. Two of the ten TUs (topk_plain_kernels.cu, dsv4_rotate_quant.cu) referenced no hipcub symbol at all -- those includes were dead. csrc/cpp_itfs/sampling/ sampling.cuh still uses hipcub for BlockLoad / BlockStore / BlockScan / Traits, which have no local equivalent; it is out of scope here. Validated on gfx950. hip_reduce.h reaches 15 modules, so the check is on compiled output rather than on tests alone: every affected module was rebuilt both ways and compared instruction by instruction, over all code objects in .hip_fatbin rather than just the first bundle. - 13 of 16 modules are byte-identical ISA, i.e. every pure functor swap compiles to exactly the same machine code: quant, rmsnorm_quant, activation, fused_qk_rmsnorm_group_quant, dsv4_rotate_quant, smoothquant, gated_rmsnorm_quant, moe_topk, mhc, fused_ar_mhc, fused_qk_norm_rope_cache_quant_shuffle, inverse_rope_group_quant, topk_plain. - module_sample: 15 kernels change, all 4-8% fewer instructions, VGPR/SGPR unchanged, no spills, LDS deltas under 128B. - module_moe_asm: 4 kernels change out of 630 (moeSoftmax x3 dtypes, moeTopK); moeSoftmax drops 18 -> 16 VGPR and moeTopK 60 -> 58 SGPR. - module_cache: the 12 reshape_and_cache_with_block_quant instantiations, -2 instructions each, identical resource usage. Op tests on the three modules that changed, new/old interleaved over 4 rounds: - test_moeTopkSoftmax -e 160 (a non-power-of-2 expert count is what reaches moeSoftmax/moeTopK; powers of 2 go to the untouched warp-specialized kernel) is faster at every shape -- token 1/32/256/2048/16384 gives -2.0 / -1.6 / -1.5 / -2.0 / -3.8% median. The biased_grouped_topk block of the same test compiles to identical ISA and so doubles as the noise control: +-0.6% on best-of, +-3% on median. Read the small numbers with that in mind. - test_sample -m 1 8 32 128 512: greedy 0 to -2.7%, random/mixed with outer exponential -4.4 to +0.3%, the inner-exponential variants within +-1% (that path is dominated by hiprand philox, not by the reduce). - test_kvcache_blockscale: prefill +0.1 / +1.0%, i.e. noise, which is what 2 instructions out of 2044 in a bandwidth-bound kernel should look like. Correctness: test_sample passes at atol=0 rtol=0, test_moeTopkSoftmax reports hip err 0, test_kvcache_blockscale keeps the same pass / not-all-close split as before (it seeds nothing, so its numbers move run to run on one build too). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Co-authored-by: Cursor <[email protected]>
zufayu
approved these changes
Aug 13, 2026
zufayu
added a commit
that referenced
this pull request
Aug 20, 2026
…ependency (#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]>
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]>
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]>
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.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist