Skip to content

[Compat] add device.XXX and cuda.XXX#75692

Merged
yongqiangma merged 11 commits intoPaddlePaddle:developfrom
fxyfxy777:device_related_api
Oct 13, 2025
Merged

[Compat] add device.XXX and cuda.XXX#75692
yongqiangma merged 11 commits intoPaddlePaddle:developfrom
fxyfxy777:device_related_api

Conversation

@fxyfxy777
Copy link
Copy Markdown
Contributor

@fxyfxy777 fxyfxy777 commented Oct 9, 2025

PR Category

User Experience

PR Types

Bug fixes

Description

对齐torch的api和paddle的api

New API (under paddle.device) Equivalent API (under paddle.cuda) Description
paddle.device.device paddle.cuda.device Context manager for setting and restoring CUDA device.
paddle.device.is_bf16_supported paddle.cuda.is_bf16_supported Check whether the current CUDA device supports bfloat16 (BF16) dtype. 注意新增的参数including_emulation,
paddle.device.manual_seed paddle.cuda.manual_seed Set the random seed for CUDA devices to ensure reproducible results.
paddle.device.max_memory_allocated paddle.cuda.max_memory_allocated 弥补cpu下没有这个函数的问题,但cpu下直接报错并给出报错提示
paddle.device.reset_peak_memory_stats paddle.cuda.reset_peak_memory_stats Reset the peak size of memory that is allocated to tensor of the given device.
paddle.cuda.set_stream paddle.cuda.set_stream 顺手修改了paddle.device.Stream的不太合理的一处,规范化使得paddle.device.Stream和paddle.cuda.Stream等价
paddle.device.Event paddle.cuda.Event 并补充paddle.Event,这三个类等价,和torch的对比应该还缺少两个成员函数,有待进一步的修改

paddle.get_device的输入兼容torch的张量输入,输出张量的设备id

card-67164

@fxyfxy777 fxyfxy777 changed the title [Compat] add device.device cuda.device [Compat] add device.XXX and cuda.XXX Oct 9, 2025
@fxyfxy777 fxyfxy777 changed the title [Compat] add device.XXX and cuda.XXX [Draft] add device.XXX and cuda.XXX Oct 9, 2025
@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Oct 9, 2025

你的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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 9, 2025

Codecov Report

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

Files with missing lines Patch % Lines
python/paddle/device/cpu.py 45.45% 6 Missing ⚠️
python/paddle/device/custom_device.py 16.66% 5 Missing ⚠️
python/paddle/device/xpu/__init__.py 16.66% 5 Missing ⚠️
python/paddle/device/cuda/__init__.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #75692   +/-   ##
==========================================
  Coverage           ?   73.43%           
==========================================
  Files              ?        6           
  Lines              ?       64           
  Branches           ?        0           
==========================================
  Hits               ?       47           
  Misses             ?       17           
  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.

@fxyfxy777 fxyfxy777 changed the title [Draft] add device.XXX and cuda.XXX add device.XXX and cuda.XXX Oct 10, 2025
@fxyfxy777
Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@fxyfxy777 fxyfxy777 changed the title add device.XXX and cuda.XXX [Compat] add device.XXX and cuda.XXX Oct 13, 2025
Copy link
Copy Markdown
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@fxyfxy777
Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@yongqiangma yongqiangma merged commit 4edb367 into PaddlePaddle:develop Oct 13, 2025
110 of 115 checks passed
@fxyfxy777 fxyfxy777 deleted the device_related_api branch October 13, 2025 07:52
SigureMo pushed a commit to cattidea/Paddle that referenced this pull request Oct 14, 2025
* add device.device cuda.device

* reset_max_memory_allocated reset_max_memory_reserved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants