Skip to content

[Cpp API Compatibility] Fix CUDAContext.h to align with Pytorch#78584

Merged
SigureMo merged 7 commits intoPaddlePaddle:developfrom
youge325:cRefactor
Apr 4, 2026
Merged

[Cpp API Compatibility] Fix CUDAContext.h to align with Pytorch#78584
SigureMo merged 7 commits intoPaddlePaddle:developfrom
youge325:cRefactor

Conversation

@youge325
Copy link
Copy Markdown
Contributor

@youge325 youge325 commented Apr 4, 2026

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

修复 #include <ATen/cuda/CUDAContext.h> 时没有 #include <c10/cuda/CUDAStream.h> 的错误,用于 DeepEP 的编译

对齐 getStreamFromPool 函数,详细兼容架构文档已在 PFCCLab/PaddleCppAPITest#59 中更新
Mermaid Chart - Create complex, visual diagrams with text -2026-04-04-140326

是否引起精度变化

Copilot AI review requested due to automatic review settings April 4, 2026 05:56
@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 4, 2026

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 the ATen CUDA compat header(s) to better match PyTorch’s include surface so that #include <ATen/cuda/CUDAContext.h> also brings in the CUDA stream definitions needed by downstream builds (e.g., DeepEP).

Changes:

  • Add missing transitive includes (ATen/cuda/Exceptions.h, c10/cuda/CUDAStream.h) to ATen/cuda/CUDAContext.h.
  • Update CUDAContext.cpp to include ATen/cuda/CUDAContext.h instead of CUDAContextLight.h.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
paddle/phi/api/include/compat/ATen/cuda/CUDAContext.h Adds missing includes for CUDA stream / exceptions, but changes conditional include behavior.
paddle/phi/api/include/compat/ATen/cuda/CUDAContext.cpp Switches to including the main CUDAContext header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 21 to +24
#include <ATen/cuda/CUDAContextLight.h>
#endif

#include <ATen/cuda/Exceptions.h>
#include <c10/cuda/CUDAStream.h>
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

CUDAContext.h used to only include CUDAContextLight.h when PADDLE_WITH_CUDA/PADDLE_WITH_HIP was enabled. After this change the header unconditionally includes CUDAContextLight.h and c10/cuda/CUDAStream.h, which pulls in CUDA-only APIs (e.g., cudaError_t / cudaStream_t) and will break compilation in non-CUDA/HIP builds that still include this header transitively. Please restore a build-flag guard around the CUDA-specific includes (or provide CPU stubs matching the previous behavior) while still adding c10/cuda/CUDAStream.h for CUDA/HIP builds.

Copilot uses AI. Check for mistakes.
@youge325
Copy link
Copy Markdown
Contributor Author

youge325 commented Apr 4, 2026

/re-run all-failed

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@2202902). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...dle/phi/api/include/compat/c10/cuda/CUDAStream.cpp 94.44% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #78584   +/-   ##
==========================================
  Coverage           ?   94.44%           
==========================================
  Files              ?        1           
  Lines              ?       72           
  Branches           ?        0           
==========================================
  Hits               ?       68           
  Misses             ?        4           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 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.

@SigureMo SigureMo merged commit 6533c69 into PaddlePaddle:develop Apr 4, 2026
84 of 85 checks passed
@youge325 youge325 deleted the cRefactor branch April 5, 2026 00:22
liuhao2638 pushed a commit to liuhao2638/Paddle that referenced this pull request Apr 7, 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.

4 participants