Repository navigation
[Bugfix][Build] host code compiles as C++20 on torch 2.14, C++17 before (needed by RFC #420 final_distributed_h3_run) - #734
Conversation
torch 2.14's headers require C++20 (#error 'C++20 or later compatible compiler is required', std::strong_ordering, requires-clauses); the CUDA/ROCm extension passed -std=c++17 to the host compiler and stopped there. Pick the host standard from torch's version: C++20 from 2.14, C++17 before, so builds against older torch are unchanged. PyTorch already chooses nvcc's -std itself; the MUSA and Ascend compilers keep their flags. Signed-off-by: Wenbo Ji <[email protected]>
Covers _host_cxx_standard on version strings (numeric minor compare, local and pre-release suffixes) and checks that the CUDA and ROCm extension configs carry exactly one -std, C++17 for torch 2.13 and C++20 for torch 2.14. Signed-off-by: Wenbo Ji <[email protected]>
|
Warning Review limit reachedThis review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry. Next included review available in 24 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… feat/h3-omni-rollout-model at 8ecfed9; TP4 runs at 463d719 + RL-Align#734) Signed-off-by: Wenbo Ji <[email protected]>
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
📄
|
|
|
||
| platform_define = "-DKERNEL_ALIGN_WITH_ROCM" if is_rocm else "-DKERNEL_ALIGN_WITH_CUDA" | ||
| cxx_flags = ["-O3", "-std=c++17", platform_define] | ||
| cxx_flags = ["-O3", f"-std={_host_cxx_standard()}", platform_define] |
There was a problem hiding this comment.
The new host standard only reaches the main _C extension. The separate _H3_C DSO built later in this function under RL_KERNEL_H3_STRICT still passes "cxx": ["-O3"] while compiling csrc/bindings/h3_ops.cpp against the same torch headers, so on torch >= 2.14 it inherits torch's/compiler's default C++17 and hits exactly the "C++20 or later compatible compiler is required" error this change is fixing for _C. Apply f"-std={_host_cxx_standard()}" to that extension too (the new build test only inspects ext_modules[0], so this gap is not covered). The MUSA branch above also hardcodes "cxx": ["-O3", "-std=c++17", ...] for its host compiler and will fail the same way once torch_musa is based on torch >= 2.14.
Suggestion:
| cxx_flags = ["-O3", f"-std={_host_cxx_standard()}", platform_define] | |
| cxx_flags = ["-O3", f"-std={_host_cxx_standard()}", platform_define] |
There was a problem hiding this comment.
Not changed: _H3_C passes no -std, so PyTorch's BuildExtension appends -std=c++20 itself (cpp_extension.py:866-873, append_std17_if_no_std_present). Only _C hard-coded -std=c++17, which this PR fixes. MUSA's hard-coded C++17 (extensions.py:380) is deliberately unchanged; its compiler keeps its own flags.
|
@fusheng-ji The automated OCR review has completed. Please review and address all automated review bot findings, then push your updates. Maintainers will begin manual review after the bot findings have been addressed. |
… feat/h3-omni-rollout-model at 8ecfed9; TP4 runs at 463d719 + RL-Align#734) Signed-off-by: Wenbo Ji <[email protected]>
… feat/h3-omni-rollout-model at 8ecfed9; TP4 runs at 463d719 + RL-Align#734) Signed-off-by: Wenbo Ji <[email protected]>
What
The CUDA / ROCm extension stops at its first host file on torch 2.14. torch 2.14's headers require C++20:
They also use
std::strong_orderingand requires-clauses.build_tools/extensions.pypasses-std=c++17to the host compiler.This PR picks the host standard from the installed torch: C++20 from 2.14 on, C++17 before. Builds against older torch keep the same flags. PyTorch already sets nvcc's own
-std, so only the host flags change here; the MUSA and Ascend compilers keep their flags.This is independent of H3. RFC #420's
final_distributed_h3_runneeds it because its rollout stack (vLLM 0.33, vLLM-Omni, verl-omni) requires torch 2.14. The rollout binding's measurements (#735) were built with the fix commit7cae99bd.Prior art & reuse decision
-stdBuildExtensionappends-std=c++20when the host flags carry none (append_std17_if_no_std_present, in both torch 2.13 and 2.14). It already passes nvcc-std=c++20on both, so the 15.cufiles compile as C++20 on torch 2.13 today; our flag decides only the one host file,csrc/bindings/ops.cppops.cppfrom C++17 to C++20. That is a small change, but this fix does not need it, and it is untested on ROCm, MUSA and Ascend. Easy to switch to if preferred_host_cxx_standard(): C++20 from 2.14 (what the headers require and what PyTorch itself passes), C++17 beforeResults
On one B200 at
dcc8535a, CUDA 13.0, a cleansetup.py build_ext --inplacefor each torch (the flags counted from the verbose build log):-stdin the build_Cimports from the checkoutpytest tests/buildc++(ops.cpp):-std=c++17;nvcc(15.cu):-std=c++20(PyTorch's)c++(ops.cpp):-std=c++20;nvcc(15.cu):-std=c++20Status
dcc8535a, ontest-h312e81c36. Two commits, both signed off: the fix and its test.Tests
tests/build/test_build_platform_collectives.py(11 new cases: version parsing, and exactly one-stdin the CUDA and ROCm configs for 2.13 and 2.14)pytest tests/buildafter a clean build of eachScope
-std, only for torch >= 2.14.Summary by CodeRabbit