Skip to content

Query nvcc for default CUDA build targets - #2154

Open
ylwang0701 wants to merge 1 commit into
bitsandbytes-foundation:mainfrom
ylwang0701:fix/detect-cuda-targets-with-nvcc
Open

ylwang0701 wants to merge 1 commit into
bitsandbytes-foundation:mainfrom
ylwang0701:fix/detect-cuda-targets-with-nvcc

Conversation

@ylwang0701

Copy link
Copy Markdown

The documented CUDA source build fails with CMake 3.31.1 and CUDA 13.0.88. CMake's architecture table starts at SM50 and ends at SM90. The first CUDA compilation fails with nvcc fatal: Unsupported gpu architecture 'compute_50', and the table omits Blackwell.

When COMPUTE_CAPABILITY is unset, query the selected toolkit's nvcc --list-gpu-code and keep its generic SM50 and newer targets. This also replaces the hand-maintained table for CMake 3.22. Explicit target lists, including the wheel build lists, continue to take precedence.

To reproduce from a fresh build directory:

cmake -DCOMPUTE_BACKEND=cuda -S . -B build
cmake --build build --parallel 4

On CUDA 13.0.88 the default build now completes and cuobjdump --list-elf shows an SM120 cubin. On an RTX 5090 with PTX JIT disabled, the following selection passed all 768 NF4/FP4 matmul cases with the resulting library; the same selection passed on main with an explicit SM120 build.

CUDA_DISABLE_PTX_JIT=1 python -m pytest -q tests/test_functional.py \
  -k 'test_matmul_4bit and cuda and (fp16 or bf16)'

Also configured with CUDA 12.9.86 and CMake 3.22.1. The default selected SM50 through SM121, and an explicit -DCOMPUTE_CAPABILITY="80;90" produced 80-real;90.

@ylwang0701

Copy link
Copy Markdown
Author

@matthewdouglas, could you approve the PR Tests run for this CUDA build change? The default build now produces an SM120 cubin, and all 768 selected 4-bit matmul tests passed on a 5090 with PTX JIT disabled.

This branch has not been deployed

No deployments
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.

1 participant