Skip to content

[Build] Enable CUDA C++20 with host code isolation - #79656

Open
gouzil wants to merge 8 commits into
PaddlePaddle:developfrom
gouzil:cuda/support_CUDA_STANDARD_20
Open

[Build] Enable CUDA C++20 with host code isolation#79656
gouzil wants to merge 8 commits into
PaddlePaddle:developfrom
gouzil:cuda/support_CUDA_STANDARD_20

Conversation

@gouzil

@gouzil gouzil commented Aug 13, 2026

Copy link
Copy Markdown
Member

PR Category

Environment Adaptation

PR Types

Improvements

Description

将 CUDA 编译标准从 C++17 升级到 C++20。Windows 构建仍由 cmake/flags.cmake 强制使用 C++17。

在 CUDA 12.9 与 GCC 13 的组合下,NVCC 编译包含较多 host STL、kernel orchestration 和注册逻辑的 .cu translation unit 时会触发 cudafe++ internal compiler error。参考 PyTorch 的处理方式,本 PR 将 host/device 编译边界拆开:

  • 将 FC 以及 fused attention、fused feedforward、fused gate attention 的 host orchestration 和 kernel registration 移到 .cc 文件,由 host compiler 编译。
  • .cu 文件中仅保留 CUDA/HIP launcher、device code 和显式模板实例化,并通过窄接口头文件连接两侧。
  • 更新 kernel source collection,保持 CUDA 与 ROCm 的源文件选择一致。

该修改不改变算子计算逻辑、输入输出或公开 API。

是否引起精度变化

Copilot AI lite review requested due to automatic review settings August 13, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Paddle’s CUDA CMake configuration to build CUDA sources with the C++20 language standard as part of environment/toolchain adaptation work.

Changes:

  • Switches CMAKE_CUDA_STANDARD from 17 to 20 in cmake/cuda.cmake.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmake/cuda.cmake
Comment on lines +326 to +328

# TODO: 感觉应该是需要跳过 win 的
set(CMAKE_CUDA_STANDARD 20)

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

序号 位置 优先级 规则来源 状态
1 Windows CUDA 标准选择 P0 仓库规则:构建平台兼容性 🚧
2 PR 描述 P3 仓库规则:PR 信息规范 🚧

问题说明

  1. cmake/cuda.cmake:328 仍无条件设置 CMAKE_CUDA_STANDARD 20,而 cmake/flags.cmake:47-50 对 Windows CUDA/MSVC 保持 C++17;Windows-GPU 与 Windows-Inference 使用的 CUDA 12.0/11.7 工具链仍可能进入未兼容的 C++20 路径。请按平台或已验证的工具链条件启用 C++20,并保留 Windows 的兼容路径。

  2. PR 标题和描述主体已补充变更动机、问题背景、主要改动及 Windows 兼容说明,但仍未给出本次改动后的实际构建/测试命令、平台范围和结果。请补充可复核的验证范围,使描述满足 PR 信息规范。

本轮复核

当前 head 未发生代码变化;已有 fused transformer host code 拆分结论不变,未发现新的可确认问题。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@paddle-bot paddle-bot Bot added the contributor External developers label Aug 13, 2026
@SigureMo SigureMo changed the title [WIP] support CUDA STANDARD 20 [Build] Support CUDA STANDARD 20 Aug 20, 2026

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

当前 head 仅合并了 develop,PR 自身改动未变化。cmake/cuda.cmake 仍无条件将 CUDA 标准设为 C++20,与 Windows 构建继续使用 C++17 的现有配置冲突;在按平台或工具链完成兼容处理前,继续请求修改。PR 标题已补充分类 Tag,但描述仍需补充变更动机、兼容范围和验证方式。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

诊断性改动已在当前 head 中移除,但以下问题仍未解决:

  1. cmake/cuda.cmake 仍无条件设置 CMAKE_CUDA_STANDARD 20,而 cmake/flags.cmake 对 Windows CUDA/MSVC 保持 C++17;Windows-GPU 与 Windows-Inference 使用的 CUDA 12.0/11.7 工具链仍可能进入未兼容的 C++20 路径。请按平台或已验证的工具链条件启用 C++20,并保留 Windows 的兼容路径。

  2. PR 描述仍未说明变更动机、受影响的平台/工具链、兼容策略和实际构建验证范围。请补充与最终实现一致的说明。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复核本次 FC host code 拆分:新增 .cc/.h 已纳入 funcs 的源码收集,CUDA/HIP 模板实例化与原实现保持一致,未发现新增问题。以下既有问题仍未解决:

  1. cmake/cuda.cmake 仍无条件设置 CMAKE_CUDA_STANDARD 20,而 cmake/flags.cmake 对 Windows CUDA/MSVC 保持 C++17;Windows-GPU 与 Windows-Inference 使用的 CUDA 12.0/11.7 工具链仍可能进入未兼容的 C++20 路径。请按平台或已验证的工具链条件启用 C++20,并保留 Windows 的兼容路径。

  2. PR 描述仍未说明变更动机、受影响的平台/工具链、兼容策略和实际构建验证范围。请补充与最终实现一致的说明。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复核当前 head 的新增提交:仅更新了 CUDA 标准旁的注释,FC host code 拆分未引入新的可确认问题。以下既有问题仍未解决:

  1. cmake/cuda.cmake 仍无条件设置 CMAKE_CUDA_STANDARD 20,而 cmake/flags.cmake 对 Windows CUDA/MSVC 保持 C++17;Windows-GPU 与 Windows-Inference 使用的 CUDA 12.0/11.7 工具链仍可能进入未兼容的 C++20 路径。请按平台或已验证的工具链条件启用 C++20,并保留 Windows 的兼容路径。

  2. PR 描述仍未说明变更动机、受影响的平台/工具链、兼容策略和实际构建验证范围。请补充与最终实现一致的说明。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@cca182d). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #79656   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         1           
  Lines              ?        33           
  Branches           ?         0           
===========================================
  Hits               ?        33           
  Misses             ?         0           
  Partials           ?         0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复核当前 head 44e5cf934ab4914310245ffba47bb61887aaef73 相对上一评审 head 的 fused transformer host code 拆分:新增 CUDA .cc/.cu 配对、显式模板实例化及 CUDA/HIP 源文件筛选与原实现契约一致,未发现新的可确认问题。以下既有问题仍未解决:

  1. cmake/cuda.cmake:328 仍无条件设置 CMAKE_CUDA_STANDARD 20,而 cmake/flags.cmake:47-50 对 Windows CUDA/MSVC 保持 C++17;Windows-GPU 与 Windows-Inference 使用的 CUDA 12.0/11.7 工具链仍可能进入未兼容的 C++20 路径。请按平台或已验证的工具链条件启用 C++20,并保留 Windows 的兼容路径。

  2. PR 描述仍未说明变更动机、受影响的平台/工具链、兼容策略和实际构建验证范围。请补充与最终实现一致的说明。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复核当前 head 44e5cf934ab4914310245ffba47bb61887aaef73 相对上一评审 head 的 fused transformer host code 拆分:新增 CUDA .cc/.cu 配对、显式模板实例化及 CUDA/HIP 源文件筛选与原实现契约一致,未发现新的可确认问题。以下既有问题仍未解决:

  1. cmake/cuda.cmake:328 仍无条件设置 CMAKE_CUDA_STANDARD 20,而 cmake/flags.cmake:47-50 对 Windows CUDA/MSVC 保持 C++17;Windows-GPU 与 Windows-Inference 使用的 CUDA 12.0/11.7 工具链仍可能进入未兼容的 C++20 路径。请按平台或已验证的工具链条件启用 C++20,并保留 Windows 的兼容路径。

  2. PR 描述仍未说明变更动机、受影响的平台/工具链、兼容策略和实际构建验证范围。请补充与最终实现一致的说明。

Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.

@gouzil gouzil changed the title [Build] Support CUDA STANDARD 20 [Build] Enable CUDA C++20 with host code isolation Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants