-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix CUDA 13 LTO architecture selection with older CMake #23862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 7 commits into
NVIDIA:main
from
wjxiz1992:codex/fix-cuda13-lto-architecture
Aug 31, 2026
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
492980e
Fix LTO architecture selection with older CMake
wjxiz1992 9938b82
Simplify LTO architecture selection
wjxiz1992 d5adef4
Merge branch 'main' into codex/fix-cuda13-lto-architecture
wjxiz1992 b3440be
Merge branch 'main' into codex/fix-cuda13-lto-architecture
robertmaynard f69a448
Merge branch 'main' into codex/fix-cuda13-lto-architecture
igorpeshansky 929f659
Merge branch 'main' into codex/fix-cuda13-lto-architecture
vyasr e27004c
Merge branch 'main' into codex/fix-cuda13-lto-architecture
igorpeshansky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # ============================================================================= | ||
| # cmake-format: off | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # cmake-format: on | ||
| # ============================================================================= | ||
|
|
||
| include_guard(GLOBAL) | ||
|
|
||
| # Select the common LTO base architecture and return it through output_variable. | ||
| function(cudf_select_lto_architecture output_variable) | ||
| set(selected_architecture "${CUDF_LTO_ARCHITECTURE}") | ||
|
|
||
| if(selected_architecture STREQUAL "") | ||
| # CMAKE_CUDA_ARCHITECTURES is resolved against the active compiler by rapids-cmake. Prefer it | ||
| # over CMAKE_CUDA_ARCHITECTURES_ALL, whose value depends on the CMake version and can therefore | ||
| # contain architectures that the active compiler no longer supports. | ||
| foreach(architecture IN LISTS CMAKE_CUDA_ARCHITECTURES) | ||
| string(REGEX MATCH "^[0-9]+" numeric_architecture "${architecture}") | ||
| if(numeric_architecture AND (NOT selected_architecture OR numeric_architecture LESS | ||
| selected_architecture) | ||
| ) | ||
| set(selected_architecture "${numeric_architecture}") | ||
| endif() | ||
| endforeach() | ||
| endif() | ||
|
|
||
| if(selected_architecture STREQUAL "") | ||
| # Preserve support for symbolic CMake values such as `all` and `all-major`. | ||
| foreach(architecture IN LISTS CMAKE_CUDA_ARCHITECTURES_ALL) | ||
| string(REGEX MATCH "^[0-9]+" numeric_architecture "${architecture}") | ||
| if(numeric_architecture AND (NOT selected_architecture OR numeric_architecture LESS | ||
| selected_architecture) | ||
| ) | ||
| set(selected_architecture "${numeric_architecture}") | ||
| endif() | ||
| endforeach() | ||
| endif() | ||
|
|
||
| if(NOT selected_architecture MATCHES "^[0-9]+$") | ||
| message(FATAL_ERROR "CUDF_LTO_ARCHITECTURE must be a numeric architecture") | ||
| endif() | ||
|
|
||
| set(${output_variable} | ||
| "${selected_architecture}" | ||
| PARENT_SCOPE | ||
| ) | ||
| endfunction() | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # ============================================================================= | ||
| # cmake-format: off | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # cmake-format: on | ||
| # ============================================================================= | ||
|
|
||
| include("${CUDF_REPOSITORY_DIR}/cpp/cmake/Modules/SelectLtoArchitecture.cmake") | ||
|
|
||
| # Verify that the selected LTO architecture matches the expected value. | ||
| function(assert_lto_architecture expected configured_architectures all_architectures override) | ||
| set(CMAKE_CUDA_ARCHITECTURES "${configured_architectures}") | ||
| set(CMAKE_CUDA_ARCHITECTURES_ALL "${all_architectures}") | ||
| set(CUDF_LTO_ARCHITECTURE "${override}") | ||
|
|
||
| cudf_select_lto_architecture(actual) | ||
|
|
||
| if(NOT actual STREQUAL expected) | ||
| message(FATAL_ERROR "Expected LTO architecture ${expected}, got ${actual}") | ||
| endif() | ||
| endfunction() | ||
|
|
||
| # CMake 4.0's static list still contains SM50 when paired with CUDA 13, while rapids-cmake's | ||
| # compiler-aware configured list correctly begins at SM75. | ||
| assert_lto_architecture( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't write CMake infra tests, please remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
| 75 "75-real;80-real;86-real;90a-real;100f-real;120a-real;120" "50;52;60;61;70;75;80;86;90" "" | ||
| ) | ||
|
|
||
| # CUDA 12 continues to use SM70 as its common LTO base. | ||
| assert_lto_architecture( | ||
| 70 "70-real;75-real;80-real;86-real;90a-real;90-virtual" "50;52;60;61;70;75;80;86;90" "" | ||
| ) | ||
|
|
||
| # An explicit user override remains authoritative. | ||
| assert_lto_architecture(80 "75-real;80-real" "50;52;60;61;70;75;80" 80) | ||
|
|
||
| # Preserve the existing fallback for symbolic CMake architecture values. | ||
| assert_lto_architecture(70 all "70;75;80;86;90" "") | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Clarify the FATAL_ERROR message for the non-override failure case.
The message states
"CUDF_LTO_ARCHITECTURE must be a numeric architecture", but this branch also triggers whenCUDF_LTO_ARCHITECTUREis empty and bothCMAKE_CUDA_ARCHITECTURESandCMAKE_CUDA_ARCHITECTURES_ALLcontain no numeric entries. In that case, the user never setCUDF_LTO_ARCHITECTURE, so the message points at the wrong variable and can mislead debugging.📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents