Skip to content

Conversation

@SigureMo
Copy link
Member

@SigureMo SigureMo commented Mar 31, 2025

PR Category

Execute Infrastructure

PR Types

Performance

Description

paddle.get_device 添加非打断支持,模拟的函数只有 CUDAPlace.get_device_id 不支持,添加 dispatch 后可以确保无打断,且 guard 能正常工作,切换 place 能重新触发组网

@paddle-bot
Copy link

paddle-bot bot commented Mar 31, 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.

@SigureMo SigureMo requested a review from Copilot March 31, 2025 14:13
Copy link
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 adds support for non-breakgraph execution of place.get_device_id by introducing a new PlaceVariable type and updating related dispatchers.

  • Introduces PlaceVariable to handle get_device_id operations.
  • Registers place_get_device_id within the dispatcher and updates import statements accordingly.
  • Removes a redundant line in paddle/device/init.py to clean up duplicate formatting.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py Adds the PlaceVariable class and implements get_device_id logic.
python/paddle/jit/sot/opcode_translator/executor/variables/init.py Exports the new PlaceVariable.
python/paddle/jit/sot/opcode_translator/executor/variable_dispatch.py Registers place_get_device_id for PlaceVariable.
python/paddle/jit/sot/opcode_translator/executor/dispatch_functions.py Adds a stub for place_get_device_id.
python/paddle/device/init.py Removes a duplicate device string formatting line.


def place_get_device_id(x):
pass
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

The function 'place_get_device_id' is currently a stub (using 'pass'). If this function is meant to be implemented in this PR, consider raising a NotImplementedError or adding a TODO comment to clarify its intended behavior.

Suggested change
pass
raise NotImplementedError("place_get_device_id function is not yet implemented.")
Copilot uses AI. Check for mistakes.
…ic.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SigureMo SigureMo changed the title [SOT] Support no breakgraph for place.get_device_id [SOT] Non-break support for place.get_device_id Apr 1, 2025
@SigureMo SigureMo changed the title [SOT] Non-break support for place.get_device_id [SOT] Non-break support for paddle.get_device Apr 1, 2025

This comment was marked as duplicate.

@SigureMo SigureMo requested a review from Copilot April 1, 2025 03:01
Copy link
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 adds non-break support for paddle.get_device by introducing a new PlaceVariable for device dispatching and by updating tests to verify that device switching triggers a rebuild of the graph.

  • Added unit tests to validate the new device guard and expected behavior for different device types (cpu, gpu, xpu).
  • Added a new PlaceVariable in the opcode translator to support get_device_id and get_device_type dispatch.
  • Updated variable dispatch and removed duplicate assignment for IPUPlace in paddle.get_device.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/sot/test_sot_place.py Added tests for device guard and ensuring graph rebuild after switching device
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py Introduced PlaceVariable and updated import order to support new dispatch functions
python/paddle/jit/sot/opcode_translator/executor/variables/init.py Registered PlaceVariable for use in the translator
python/paddle/jit/sot/opcode_translator/executor/variable_dispatch.py Registered dispatcher functions for PlaceVariable operations
python/paddle/jit/sot/opcode_translator/executor/dispatch_functions.py Added stubs for place_get_device_id and place_get_device_type
python/paddle/device/init.py Removed a duplicate assignment in device string formatting


def place_get_device_id():
pass
Copy link

Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

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

The function 'place_get_device_id' remains unimplemented. Add an appropriate implementation or provide a comment explaining why it is intentionally left as a stub.

Suggested change
pass
import paddle
device = paddle.device.get_device()
device_id = int(device.split(':')[-1]) if ':' in device else 0
return device_id
Copilot uses AI. Check for mistakes.
Comment on lines +68 to +69
def place_get_device_type():
pass
Copy link

Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

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

The function 'place_get_device_type' remains unimplemented. Add an appropriate implementation or provide a comment explaining why it is intentionally left as a stub.

Suggested change
def place_get_device_type():
pass
def place_get_device_type(place):
if place.is_gpu_place():
return "GPU"
elif place.is_cpu_place():
return "CPU"
else:
raise ValueError("Unsupported place type")
Copilot uses AI. Check for mistakes.
SigureMo and others added 2 commits April 1, 2025 11:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SigureMo SigureMo changed the title [SOT] Non-break support for paddle.get_device [SOT][3.13] Non-break support for paddle.get_device Apr 1, 2025
@SigureMo SigureMo changed the title [SOT][3.13] Non-break support for paddle.get_device [SOT] Non-break support for paddle.get_device Apr 1, 2025
@SigureMo SigureMo merged commit 85fe498 into PaddlePaddle:develop Apr 1, 2025
40 of 53 checks passed
@SigureMo SigureMo deleted the sot/support-no-breakgraph-for-place-get-device-id branch April 1, 2025 15:31
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
--------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants