Skip to content

[XPU] support unified ckpt function#9312

Merged
wawltor merged 1 commit into
PaddlePaddle:developfrom
cqulilujia:unified
Oct 25, 2024
Merged

[XPU] support unified ckpt function#9312
wawltor merged 1 commit into
PaddlePaddle:developfrom
cqulilujia:unified

Conversation

@cqulilujia

Copy link
Copy Markdown
Contributor

PR types

Function optimization

PR changes

Others

Description

Support unified ckpt function on XPU

@paddle-bot

paddle-bot Bot commented Oct 24, 2024

Copy link
Copy Markdown

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the XPU label Oct 24, 2024
@codecov

codecov Bot commented Oct 24, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 52.92%. Comparing base (7551730) to head (9cdabb6).
Report is 263 commits behind head on develop.

Files with missing lines Patch % Lines
paddlenlp/trainer/trainer.py 0.00% 5 Missing ⚠️
paddlenlp/trainer/plugins/unified_checkpoint.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9312      +/-   ##
===========================================
+ Coverage    52.80%   52.92%   +0.11%     
===========================================
  Files          660      660              
  Lines       106869   106875       +6     
===========================================
+ Hits         56434    56564     +130     
+ Misses       50435    50311     -124     

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

if paddle.is_compiled_with_xpu():
# XPU does not support all_reduce prod now, in XPU, bool is treated as int8,
# so temporarily use reduce_min instead
dist.all_reduce(local_resume, op=dist.ReduceOp.MIN)

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.

那就统一改成dist.all_reduce(local_resume, op=dist.ReduceOp.MIN)吧,不需要特地区分XPU和GPU

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

if paddle.is_compiled_with_xpu():
# XPU does not support all_reduce prod now, in XPU, bool is treated as int8,
# so temporarily use reduce_min instead
dist.all_reduce(local_resume, op=dist.ReduceOp.MIN)

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.

同上

DesmonDay
DesmonDay previously approved these changes Oct 24, 2024

@DesmonDay DesmonDay 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.

LGTM

@zhiqiu zhiqiu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@cqulilujia cqulilujia changed the title [XPU], support unified ckpt function [XPU] support unified ckpt function Oct 25, 2024
@wawltor wawltor merged commit b237ba7 into PaddlePaddle:develop Oct 25, 2024
if not len(checkpoint_rng_state["cuda"]) == core.get_xpu_device_count():
raise ValueError("Length of xpu state list shoule be equal to the xpu device count")
for i in range(core.get_xpu_device_count()):
core.default_xpu_generator(i).set_state(checkpoint_rng_state["cuda"][i])

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.

这里 xpu 很下面 custom device 处理会有不同吗?更适合框架测修改吧。

@cqulilujia cqulilujia Oct 25, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

在框架侧的device上XPU和GPU、CPU是同一级别的,custom device(如海光、昇腾等)是放在一起的

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants