Skip to content

op_builder: use C++20 for nvcc on CUDA 13+ - #8422

Merged
hwchen2017 merged 2 commits into
deepspeedai:masterfrom
bheu:fix-nvcc-cxx20-cuda13
Sep 6, 2026
Merged

op_builder: use C++20 for nvcc on CUDA 13+#8422
hwchen2017 merged 2 commits into
deepspeedai:masterfrom
bheu:fix-nvcc-cxx20-cuda13

Conversation

@bheu

@bheu bheu commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Problem

CUDAOpBuilder.nvcc_args() only passes -std=c++20 to nvcc when CUDA is 12.5+; on CUDA 13.x it falls back to -std=c++17. PyTorch >= 2.12 headers require C++20, so building DeepSpeed CUDA ops against CUDA 13 + torch >= 2.12 fails:

torch/include/torch/csrc/api/include/torch/all.h:5:2: error: #error C++20 or later compatible compiler is required to use PyTorch.
torch/include/ATen/ATen.h:5:2: error: #error C++20 or later compatible compiler is required to use ATen.
torch/include/c10/util/intrusive_ptr.h(775): error: namespace "std" has no member "strong_ordering"
...
error: command '/usr/bin/ccache' failed with exit code 255

Note that cxx_args() already selects -std=c++20 for torch >= 2.12 (see #8238), so only the nvcc path is broken.

Fix

Extend the C++20 condition in nvcc_args() to also cover CUDA 13+:

if (cuda_major == 12 and cuda_minor >= 5) or cuda_major >= 13:

Verification

Built DeepSpeed from source (DS_BUILD_OPS=1 pip install .) with CUDA 13.3, PyTorch 2.14.0, gcc-13: the build fails before this change with the errors above and completes successfully with it.

nvcc_args() only passes -std=c++20 when CUDA is 12.5+, so on CUDA 13.x
it falls back to -std=c++17. PyTorch >= 2.12 headers require C++20, so
CUDA op builds fail with '#error C++20 or later compatible compiler is
required to use PyTorch'. cxx_args() already handles torch >= 2.12;
extend the nvcc-side condition to cover CUDA 13+ as well.

Signed-off-by: Frank Tin <frank@bheu.net>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11250f027b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread op_builder/builder.py
@hwchen2017
hwchen2017 added this pull request to the merge queue Sep 6, 2026
Merged via the queue into deepspeedai:master with commit abf3dfa Sep 6, 2026
14 checks passed
@bheu
bheu deleted the fix-nvcc-cxx20-cuda13 branch September 6, 2026 22:24
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.

2 participants