Skip to content

[Build] Fix CUDA arch detection producing kernel-less builds on SM121 - #49904

Merged
simon-mo merged 1 commit into
vllm-project:mainfrom
ayush1399:fix-cuda-arch-detect-sm121
Jul 28, 2026
Merged

simon-mo merged 1 commit into
vllm-project:mainfrom
ayush1399:fix-cuda-arch-detect-sm121

Conversation

@ayush1399

Copy link
Copy Markdown
Contributor

Purpose

On GB10 / DGX Spark (compute capability 12.1, CUDA 13), this shows up on the default source-build path from the docs, uv pip install -e . with TORCH_CUDA_ARCH_LIST unset. No special flags or custom arch list needed. The build looks fine but has no CUTLASS kernels in it. The .so only contains sm_75 cubins. Serving any FP8 model then fails at startup:

RuntimeError: cutlass_scaled_mm, csrc/.../scaled_mm_entry.cu:265,
NotImplementedError: No compiled cutlass_scaled_mm for a compute capability
less than CUDA device capability: 121

The cause is an old line in torch's vendored select_compute_arch.cmake:

string(REPLACE "2.1" "2.1(2.0)" compute_capabilities "${compute_capabilities}")

It was written for Fermi . The string 12.1 contains 2.1, so torch rewrites it to 12.1(2.0) and emits -gencode arch=compute_20,code=sm_121.

vLLM's extract_unique_cuda_archs_ascending() reads the arch=compute_* part of that flag, so it sees arch 2.0. Nothing in CUDA_SUPPORTED_ARCHS matches 2.0, so every arch-gated kernel is skipped. The rest of the sources build at nvcc's default sm_75, and the build reports success.

There is an upstream fix in progress (pytorch/pytorch#185993), but every torch release up to 2.11 has the bug so there should be a fix in vLLM as well.

Changes

  • cmake/utils.cmake: read the code=sm_* part of each gencode flag instead of arch=compute_*, since that is the real SASS target. Fall back to arch=compute_* for PTX-only entries. This gets 12.1 back, and cuda_archs_loose_intersection() maps it to the 12.0f family target.
  • CMakeLists.txt: if no supported arch matches, stop with an error instead of building a binary with no kernels.

Not a duplicate

AI assistance disclosure

AI assistance was used for root-cause analysis, and drafting this description. The code changes were made and tested by me, reviewed with AI.

Test Plan

.venv/bin/python -m pytest tests/test_cmake_utils.py -v

On GB10: rebuild with TORCH_CUDA_ARCH_LIST unset, check the compiled archs with cuobjdump --list-elf, then serve the FP8 model from the issue.

Test Result

GB10 (aarch64, CUDA 13.0.88, torch 2.11.0+cu130), uv pip install -e ., no TORCH_CUDA_ARCH_LIST set.

Before:

-- Autodetected CUDA architecture(s):  12.1(2.0)
-- Added CUDA NVCC flags for: -gencode;arch=compute_20,code=sm_121
-- CUDA target architectures: 2.0
-- CUDA supported target architectures:
-- Not building scaled_mm_c3x_120 as no compatible archs found ...

_C_stable_libtorch.abi3.so has only sm_75 cubins. vllm serve RedHatAI/gemma-4-31B-it-FP8-block crashes in profile_run.

After:

-- CUDA target architectures: 12.1
-- CUDA supported target architectures: 12.0
-- Building scaled_mm_c3x_sm120 for archs: 12.0f

The rebuild works and the same model serves fine (Application startup complete).

I am attaching the full vllm serve startup logs for both cases, the crash before the fix and the clean startup after it.

FP8_SM121_bug_startup_logs.md
FP8_SM121_bugfix_startup_logs.md

tests/test_cmake_utils.py::test_exact_family_arch_precedes_generic_family_fallback PASSED
tests/test_cmake_utils.py::test_extract_archs_prefers_sass_target_over_corrupted_virtual_arch PASSED

2 passed in 0.26s

This only changes the build system and touches no numerics, so I did not run evals.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model. No documentation update is required for this build-only fix.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@ayush1399 ayush1399 changed the title [Build] Fix CUDA arch detection producing kernel-less builds on SM121… [Build] Fix CUDA arch detection producing kernel-less builds on SM121 Jul 26, 2026

@Harry-Chen Harry-Chen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch! This reminds me of the story of why Windows 9 was not released 🤦

@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA Jul 27, 2026
@Harry-Chen Harry-Chen added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 27, 2026
@Harry-Chen

Copy link
Copy Markdown
Member

@ayush1399 Please finish the DCO requirement before we can get this merged.

… (GB10)

Signed-off-by: Ayushman Singh <40520701+ayush1399@users.noreply.github.com>
@ayush1399
ayush1399 force-pushed the fix-cuda-arch-detect-sm121 branch from 64fa6d8 to 404f218 Compare July 27, 2026 12:21
@ayush1399

Copy link
Copy Markdown
Contributor Author

@Harry-Chen updated my commit with a signed-off by for the DCO requirement, lmk if there's anything else I might have missed

@Harry-Chen
Harry-Chen enabled auto-merge (squash) July 28, 2026 04:54
@simon-mo
simon-mo merged commit 7458793 into vllm-project:main Jul 28, 2026
241 of 245 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA Jul 28, 2026
@ayush1399
ayush1399 deleted the fix-cuda-arch-detect-sm121 branch July 28, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build nvidia ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants