Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spmd rule for amp ops #64202

Merged
merged 10 commits into from May 24, 2024
Merged

Conversation

zhiqiu
Copy link
Contributor

@zhiqiu zhiqiu commented May 10, 2024

PR Category

Auto Parallel

PR Types

Devs

Description

add spmd rule for amp ops

  • check_finite_and_unscale_
  • update_loss_scaling_

Fix spmd rule for layer_norm_grad

Pcard-67164

Copy link

paddle-bot bot commented May 10, 2024

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

}
auto dims_mapping = dist_attr.dims_mapping();
for (auto& m : dims_mapping) {
if (m != -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would be better to record split on which mesh and which dimension of mesh

TensorDistAttr found_infinite_attr =
CopyTensorDistAttrForOutput(scale.dist_attr());
if (splited) {
found_infinite_attr.set_partial(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

would be according to the mesh info recorded above, specific the partial dimension.
in which case, the synchronization would be limited in the specific group where the tensor are splited.
BUT here is also OK, since the found_infinite is a BOOL variable, synchronize it among the global world size.

bool splited = false;
for (auto& x : xs) {
auto dist_attr = x.dist_attr();
dist_attr.clean_partial_status();
Copy link
Contributor

Choose a reason for hiding this comment

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

could allow the partial status pass through to have better performance:
if not allow partial to get through, allreduce will be conducted before this operation, no matter checkfinite return False or True.
BUT if we allow the partial to get through, allreduce will be triggered by the later operation(e.g. adam) and if the checkfinite return True, not adam would be call and therefore not allreduce is conduct

std::vector<TensorDistAttr> xs_attrs;
for (auto& x : xs) {
auto dist_attr = x.dist_attr();
dist_attr.clean_partial_status();
Copy link
Contributor

Choose a reason for hiding this comment

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

the same as above

return {
{xs_attrs,
found_infinite_attr,
prev_loss_scaling.dist_attr(),
Copy link
Contributor

Choose a reason for hiding this comment

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

all these scalar tensor should be placemented on a merged mesh of all gradient tensors' mesh.

Copy link

paddle-ci-bot bot commented May 19, 2024

Sorry to inform you that e4026d0's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators May 22, 2024
@PaddlePaddle PaddlePaddle unlocked this conversation May 22, 2024
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators May 22, 2024
@PaddlePaddle PaddlePaddle unlocked this conversation May 22, 2024
Copy link
Contributor

@heavyrain-lzy heavyrain-lzy left a comment

Choose a reason for hiding this comment

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

LGTM for yaml

Copy link
Contributor

@JZ-LIANG JZ-LIANG left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@LiYuRio LiYuRio left a comment

Choose a reason for hiding this comment

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

lgtm

@zhiqiu zhiqiu merged commit c458863 into PaddlePaddle:develop May 24, 2024
32 checks passed
chen2016013 pushed a commit to chen2016013/Paddle that referenced this pull request May 26, 2024
* add spmd for check_finite_and_unscale

* add spmd for update_loss_scaling

* fix partial

* fix ut

* fix spmd

* fix custom_relu test

* fix hybrid test

* fix ut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants