cccl icon indicating copy to clipboard operation
cccl copied to clipboard

[BUG]: Deterministic DeviceBatchedTopK triggers forced-baseline static_assert on SM120 / compute_90

Open ylwang0701 opened this issue 2 days ago • 0 comments

Is this a duplicate?

  • [x] I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug

Compile-time Error

Component

CUB

Describe the bug

Compiling a deterministic cub::DeviceBatchedTopK call in strict mode (without CUB_DISABLE_TOPK_UNSUPPORTED_ARCH_ASSERT) fails on SM90+ targets such as -arch=sm_120 and compute_90 PTX with the forced-baseline static_assert in cub/cub/device/dispatch/dispatch_batched_topk.cuh (line 1110 on main).

Even though the automatic policy selector chooses topk_algorithm::cluster and if constexpr (active_policy.backend == topk_algorithm::baseline) is discarded, static_assert(!deterministic, ...) depends only on the outer template parameters Determinism and TieBreak of dispatch_select, not on the generic lambda parameter policy_getter. NVCC 13.0 evaluates that static_assert while instantiating dispatch_select.

How to Reproduce

Compile the existing strict public-API fixture cub/test/test_device_batched_topk_unsupported_arch_fail.cu for sm_120 (or compute_90) without CUB_DISABLE_TOPK_UNSUPPORTED_ARCH_ASSERT:

nvcc -std=c++20 -arch=sm_120 \
  -Icub -Ithrust -Ilibcudacxx/include \
  -c cub/test/test_device_batched_topk_unsupported_arch_fail.cu -o test.o

Compilation fails with:

cub/cub/device/dispatch/dispatch_batched_topk.cuh(1110): error: static assertion failed with "cub::DeviceBatchedTopK: a tuned policy selector forced the baseline backend for a deterministic / tie-break request it cannot serve (only the SM 9.0+ cluster backend is deterministic). Drop the override, relax the determinism / tie-break requirement, or define CUB_DISABLE_TOPK_UNSUPPORTED_ARCH_ASSERT to defer the diagnosis to runtime (cudaErrorNotSupported)."
          static_assert(
          ^

The same failure occurs with -std=c++17 -arch=sm_120 and with -gencode=arch=compute_90,code=compute_90 in both C++17 and C++20.

Expected behavior

Compiling a deterministic cub::DeviceBatchedTopK request solely for SM90+ targets (sm_120, compute_90) should succeed when the automatic selector selects the cluster backend. The forced-baseline diagnostic should fire only when a tuned selector actually returns topk_algorithm::baseline for a deterministic or tie-break request.

Operating System

Ubuntu 24.04

NVCC version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Wed_Aug_20_01:58:59_PM_PDT_2025
Cuda compilation tools, release 13.0, V13.0.88
Build cuda_13.0.r13.0/compiler.36424714_0

ylwang0701 avatar Dec 02 '26 03:12 ylwang0701