Build C++/CUDA extensions with -std=c++20 (torch 2.14 ATen requires C++20) - #1000
Open
atalman wants to merge 1 commit into
Open
Build C++/CUDA extensions with -std=c++20 (torch 2.14 ATen requires C++20)#1000atalman wants to merge 1 commit into
atalman wants to merge 1 commit into
Conversation
torch>=2.14 enforces a C++20 minimum in its ATen/torch headers (pytorch/pytorch#178150): including any ATen header under an older standard trips '#error C++20 or later compatible compiler is required to use ATen'. mamba's setup.py hardcodes -std=c++17 for both the cxx and nvcc flag lists. torch's cpp_extension only appends its default -std=c++20 when the extension passes no -std= flag, so the pinned c++17 wins and the host compile of selective_scan.cpp fails against torch 2.14 nightly. Bump the pinned standard to c++20 (CUDA and HIP branches). c++20 is already required by the toolchains this codebase targets (CUDA 12.x / Blackwell sm_121), so this is safe on stable torch as well. This PR was drafted with the assistance of an AI agent and reviewed by the author.
Contributor
|
c++20 for torch 2.14 makes sense. worth calling out in the readme that older nvcc toolchains might need a bump. |
|
Would it be preferable to remove the explicit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
torch>=2.14enforces a C++20 minimum in its ATen/torch headers (pytorch/pytorch#178150). Any translation unit that includes an ATen header while compiling under an older standard now trips:setup.pyhardcodes-std=c++17in both thecxxandnvccflag lists. torch'scpp_extensiononly appends its own default-std=c++20when the extension passes no-std=flag:so the pinned
c++17wins and the host compile ofselective_scan.cpp(which pulls in ATen headers) fails against torch 2.14 nightly.Change
Bump the pinned standard from
c++17toc++20in both the CUDA and HIP branches ofsetup.py(4 occurrences).c++20is already required by the toolchains this codebase targets (CUDA 12.x / Blackwellsm_121), so this is a no-op for stable torch builds and unblocks torch 2.14+.Context
Currently worked around downstream in vLLM CI (vllm-project/vllm#49600) by patching this exact
-std=flag at build time; this PR fixes it at the source so that workaround can be dropped.Test plan
pip install --no-build-isolation .against a torch 2.14 nightly build (previously failed at the ATen C++20 header guard, now compiles).