Skip to content

Conversation

@HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Jul 10, 2025

PR Category

User Experience

PR Types

New features

Description

Pcard-75624

参考paddle.device.stream_guard,添加设备上下文管理器 paddle.device.device_guard(...),主要功能与 torch.device(...) 对齐;同时添加了相关单测

Note

paddle.device.device_guard仅适用于动态图

@paddle-bot
Copy link

paddle-bot bot commented Jul 10, 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.

@HydrogenSulfate HydrogenSulfate changed the title [Device] Add device_guard to public API [Device] Add paddle.device.device_guard to public API Jul 10, 2025
@HydrogenSulfate HydrogenSulfate force-pushed the add_place_guard branch 2 times, most recently from 89704c3 to f117c65 Compare July 10, 2025 08:03
@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2025

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (develop@7e472d2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/device/__init__.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## develop #73964 +/- ## ========================================== Coverage ? 94.11% ========================================== Files ? 1 Lines ? 17 Branches ? 0 ========================================== Hits ? 16 Misses ? 1 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.
set_grad_enabled,
)
from .device import ( # noqa: F401
device_guard,
Copy link
Member

Choose a reason for hiding this comment

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

这里是想暴露到 paddle.device_guard?具体公开 API 是哪个?paddle.device.device_guard 还是 paddle.device_guard

如果确定是公开 API 需要将其加到对应模块的 __all__

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已添加

Place(gpu:0)
>>> # Set the global default device to GPU:0
>>> paddle.set_device("gpu:0")
Copy link
Member

Choose a reason for hiding this comment

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

加到公开 API 后,预期这一行会挂,#73982 已确定现在 CI 环境有问题,#73992 在修

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

@HydrogenSulfate HydrogenSulfate changed the title [Device] Add paddle.device.device_guard to public API [Device] Add paddle.device.device_guard to public API for eager mode only Jul 14, 2025
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

Copy link
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

@HydrogenSulfate HydrogenSulfate merged commit b789a4e into PaddlePaddle:develop Jul 15, 2025
95 of 101 checks passed
@HydrogenSulfate HydrogenSulfate deleted the add_place_guard branch July 15, 2025 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants