Skip to content

[HIP] fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency - #4843

Merged
zufayu merged 2 commits into
mainfrom
sampling_rocm10
Aug 20, 2026
Merged

zufayu merged 2 commits into
mainfrom
sampling_rocm10

Conversation

@fsx950223

@fsx950223 fsx950223 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Re-enable the cpp_itfs sampling kernels (top_p_sampling_from_probs,
top_k_renorm_probs, top_k_top_p_sampling_from_probs) on ROCm 10.

PR #4754 disabled these kernels on ROCm 10 because
csrc/cpp_itfs/sampling/sampling.cuh did not compile with the ROCm 10
toolchain. This PR fixes the actual toolchain incompatibilities and removes the
guard.

Root cause

ROCm 10 ships hipcub built on CCCL 3.0, which drops several long-deprecated
symbols that sampling.cuh (radix_topk + the sampling kernels) relied on:

  1. hipcub::Traits<T> — removed. Used for
    hipcub::Traits<T>::UnsignedBits in twiddle_in / twiddle_out /
    Counter::kth_value_bits / choose_bucket (7 sites).
  2. hipcub::Max() / hipcub::Min() functors — no longer exposed as
    hipcub::Max / hipcub::Min (CCCL points callers at
    hip::maximum / hip::minimum). Used as the reduction operator in
    BlockReduce().Reduce(..., hipcub::Max()/Min()) (5 sites).

Reproduction (before this PR)

Environment: rocm/ufb-private:vllm-0.27.0-ubuntu24.04-py3.14-prereleases-device-all-rocm10.0.0rc3-...
(ROCm 10.0.0rc3, hipcub 5.0 / CCCL 3.0, torch 2.12.0+rocm10.0.0rc3, MI308X/gfx942).

Building any sampling op JIT-compiles sampling.cuh and fails. First the
Traits errors:

sampling.cuh:87:29: error: no type named 'Traits' in namespace 'hipcub'
   87 | __device__ typename hipcub::Traits<T>::UnsignedBits twiddle_in(T key, bool select_min) {
sampling.cuh:101:43: error: no type named 'Traits' in namespace 'hipcub'
  101 | __device__ T twiddle_out(typename hipcub::Traits<T>::UnsignedBits bits, bool select_min) {

and, once those are addressed, the reduction-operator errors:

sampling.cuh:508:117: error: no member named 'Min' in namespace 'hipcub'
sampling.cuh:1066:44: error: no member named 'Max' in namespace 'hipcub'; did you mean 'max'?

Because of #4754 these compile failures surface to users as
ImportError: AITER cpp_itfs sampling is disabled on ROCm 10 and later ...,
and op_tests/test_sampling.py is skipped.

Minimal repro (torch-free), against the image's hipcc:

# any generated <op>.cpp that #includes sampling.cuh
hipcc -x hip -std=c++20 -D__HIP_PLATFORM_AMD__=1 --offload-arch=gfx942 \
  -c gen_top_k_top_p.cpp
# -> no type named 'Traits' in namespace 'hipcub'  (then, after that, 'Max'/'Min')

Fix (csrc/cpp_itfs/sampling/sampling.cuh)

Both fixes are self-contained so the code no longer depends on hipcub symbols
that come and go across ROCm versions:

  • Add radix_traits<float>{ using UnsignedBits = uint32_t; } and route all
    hipcub::Traits<T> uses through it. radix_topk is fp32-only; the float
    twiddle_in / twiddle_out bit math is byte-identical to the previous float
    branch (select_min was already a no-op for float), so numerics are unchanged.
  • Add small AiterMaxOp / AiterMinOp reduction functors and use them in place
    of hipcub::Max() / hipcub::Min(). Same semantics as the hipcub functors.

With the incompatibilities gone, revert the ROCm 10 disable from #4754:

  • delete csrc/cpp_itfs/sampling/__init__.py (the import guard); the directory
    keeps working as a namespace package, same as mla/ and moe/.
  • restore the plain from aiter.ops import sampling in
    op_tests/test_sampling.py (drop the ROCm 10 skip).

Validation (after this PR)

On the same rocm10.0.0rc3 image (torch 2.12.0+rocm10.0.0rc3, matched runtime):

  • Compile — all three ops build clean for gfx942 and gfx950 (warnings
    only); no hipcub::Traits / hipcub::Max / hipcub::Min references remain.
  • op_tests/test_sampling.py — 348 passed, 4 skipped (the skips are the
    expected k > vocab_size cases). Run with the matched rocm10 torch and
    without HIP_LAUNCH_BLOCKING, so the 50k-iteration statistical
    distribution tests exercise the kernels under normal async launches. The 2
    chi-squared warnings are the test's own expected statistical-noise warnings,
    not failures.

Note for reviewers

radix_topk only instantiates T = float; radix_traits is specialized
accordingly and guarded with a static_assert in the twiddle helpers. If a
future caller needs another dtype, add the corresponding radix_traits<>
specialization.

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]>
@fsx950223
fsx950223 requested review from a team and a lite review from Copilot August 19, 2026 04:54
@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; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4843 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

@github-actions github-actions Bot changed the title fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency [HIP] fix(sampling): support ROCm 10 by dropping hipcub::Traits dependency Aug 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Re-enables the cpp_itfs sampling kernels on ROCm 10 by removing the dependency on the removed hipcub::Traits<T> API and by undoing the ROCm 10 import/test guard introduced in #4754.

Changes:

  • Replace hipcub::Traits<T>::UnsignedBits usage in radix_topk with a local radix_traits (fp32-only) to restore ROCm 10 compilation.
  • Remove the ROCm 10 ImportError guard by deleting csrc/cpp_itfs/sampling/__init__.py.
  • Un-skip sampling tests on ROCm 10 by restoring a normal from aiter.ops import sampling import.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
op_tests/test_sampling.py Restores unconditional import to re-enable sampling test coverage on ROCm 10.
csrc/cpp_itfs/sampling/sampling.cuh Drops hipcub::Traits dependency via local radix_traits to compile on ROCm 10.
csrc/cpp_itfs/sampling/init.py Removes ROCm 10 import guard so the JIT path is reachable again.
Suppressed comments (1)

csrc/cpp_itfs/sampling/sampling.cuh:113

  • twiddle_out returns reinterpret_cast<T&>(bits), which is the same strict-aliasing type-pun issue as twiddle_in. Use a bit-cast to convert the uint32 bit pattern back to float in a defined way.
    uint32_t mask = (bits >> 31) ? 0u : 0x7fffffffu;
    bits ^= mask;
    return reinterpret_cast<T&>(bits);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread csrc/cpp_itfs/sampling/sampling.cuh Resolved
Comment thread csrc/cpp_itfs/sampling/sampling.cuh Resolved
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]>
Copilot AI review requested due to automatic review settings August 19, 2026 07:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

csrc/cpp_itfs/sampling/sampling.cuh:114

  • radix_traits is only forward-declared, so radix_traits<T>::UnsignedBits is undefined for non-float instantiations and will error out before the static_assert in twiddle_in/twiddle_out is reached. Defining the primary radix_traits template with an UnsignedBits alias (and the dtype guard) makes compile failures deterministic and produces the intended error message if a non-fp32 dtype is ever instantiated.
template <typename T>
struct radix_traits;
template <>
struct radix_traits<float> {
    using UnsignedBits = uint32_t;

@zufayu zufayu removed the ci:all label Aug 20, 2026
@zufayu
zufayu requested a review from valarLip August 20, 2026 03:21
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]>
@zufayu
zufayu merged commit 906709c into main Aug 20, 2026
78 of 79 checks passed
@zufayu
zufayu deleted the sampling_rocm10 branch August 20, 2026 05:20
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 21, 2026
…dency (ROCm#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 ROCm#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]>
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]>
nsakkine pushed a commit to nsakkine/aiter that referenced this pull request Aug 24, 2026
…dency (ROCm#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 ROCm#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants