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

[auto parallel] complete elementwise ops spmd rules of LLaMa2 for eager semi auto parallel #58474

Merged
merged 5 commits into from
Oct 31, 2023

Conversation

cxxly
Copy link
Contributor

@cxxly cxxly commented Oct 30, 2023

PR types

New features

PR changes

Others

Description

Pcard-73145

  1. Overload elementwise grad spmdrules
  • ElementwiseUnaryGradInferSpmd(x, out, out_grad)
  • ElementwiseBinaryGradInferSpmd(x, y, out, out_grad)
  1. Support bool dtype for sharding

  2. Add yaml config and unittest for follow ops, which are used in LLaMa2 model.

  • multiply
  • divide
  • bitwise_and
  • bitwise_not
  • elementwise_pow
  • equal
  • exp
  • rsqrt
  • silu
  • sin
  • cos
  • not_equal
  1. Prompt rtol tolerance from 1e-5 to 1e-6

@cxxly cxxly changed the title [Auto Parallel] Add element-wise ops spmd ruls for semi auto parallel on dygraph mode [Auto Parallel] Add element-wise ops yaml config and unittests for eager semi auto parallel Oct 30, 2023
@cxxly cxxly changed the title [Auto Parallel] Add element-wise ops yaml config and unittests for eager semi auto parallel [auto parallel] add element-wise ops yaml config and unittests for eager semi auto parallel Oct 30, 2023
@cxxly cxxly force-pushed the spmd_elementwise branch 3 times, most recently from 32e2513 to 0e6e506 Compare October 30, 2023 08:47
@cxxly cxxly changed the title [auto parallel] add element-wise ops yaml config and unittests for eager semi auto parallel [auto parallel] enable element-wise ops spmd rules for eager semi auto parallel Oct 30, 2023
@cxxly cxxly force-pushed the spmd_elementwise branch 4 times, most recently from bf27068 to 8f37184 Compare October 30, 2023 13:07
@paddle-bot paddle-bot bot added the contributor External developers label Oct 30, 2023
@cxxly cxxly force-pushed the spmd_elementwise branch 4 times, most recently from fa0f150 to 9382027 Compare October 31, 2023 02:57
@cxxly cxxly changed the title [auto parallel] enable element-wise ops spmd rules for eager semi auto parallel [auto parallel] complete element-wise ops spmd rules of LLaMa2 for eager semi auto parallel Oct 31, 2023
@cxxly cxxly changed the title [auto parallel] complete element-wise ops spmd rules of LLaMa2 for eager semi auto parallel [auto parallel] complete elementwise ops spmd rules of LLaMa2 for eager semi auto parallel Oct 31, 2023
@@ -30,6 +30,10 @@ SpmdInfo ElementwiseUnaryInferSpmdReverse(const DistMetaTensor& x,
SpmdInfo ElementwiseUnaryGradInferSpmd(const DistMetaTensor& x,
const DistMetaTensor& out_grad);

SpmdInfo ElementwiseUnaryGradInferSpmd(const DistMetaTensor& x,
Copy link
Contributor

Choose a reason for hiding this comment

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

缺少单规则模块的单测,可以参考 test/auto_parallel/spmd_rules/test_elementwise_rule.py

Copy link
Contributor Author

@cxxly cxxly Oct 31, 2023

Choose a reason for hiding this comment

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

新提一个PR补充

@@ -42,5 +46,11 @@ SpmdInfo ElementwiseBinaryGradInferSpmd(const DistMetaTensor& x,
const DistMetaTensor& out_grad,
int64_t axis = -1);

SpmdInfo ElementwiseBinaryGradInferSpmd(const DistMetaTensor& x,
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

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

新提交一个PR补充

@@ -30,6 +30,10 @@ SpmdInfo ElementwiseUnaryInferSpmdReverse(const DistMetaTensor& x,
SpmdInfo ElementwiseUnaryGradInferSpmd(const DistMetaTensor& x,
const DistMetaTensor& out_grad);

SpmdInfo ElementwiseUnaryGradInferSpmd(const DistMetaTensor& x,
Copy link
Contributor

Choose a reason for hiding this comment

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

重载是为了适配 api 么?是不是可以加些注释说明一下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

适配不同API签名,比如一元逐元素运算,部分算子反向只依赖输入,部分依赖输入输出,sin_grad(const Tensor& x, const Tensor& out_grad, Tensor* x_grad), silu_grad(const Tensor& x, const Tensor& out, const Tensor& out_grad, Tensor* x_grad)

Copy link
Contributor

@XieYunshen XieYunshen 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

@zyfncg zyfncg 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 file

@cxxly cxxly merged commit 7ecbc1e into PaddlePaddle:develop Oct 31, 2023
28 checks passed
Copy link

paddle-bot bot commented Nov 2, 2023

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

@paddle-bot paddle-bot bot removed the contributor External developers label Nov 3, 2023
zeroRains pushed a commit to zeroRains/Paddle that referenced this pull request Nov 8, 2023
…er semi auto parallel (PaddlePaddle#58474)


* add elementwise spmd rules for eager semi auto parallel

* support bool dtype for s_to_r_reshared

* increase test_semi_auto_parallel_basic timeout for pass ci

* prompt rtol tolerance from 1e-5 to 1e-6

---------

Co-authored-by: xiaoguoguo626807 <100397923+xiaoguoguo626807@users.noreply.github.com>
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…er semi auto parallel (PaddlePaddle#58474)


* add elementwise spmd rules for eager semi auto parallel

* support bool dtype for s_to_r_reshared

* increase test_semi_auto_parallel_basic timeout for pass ci

* prompt rtol tolerance from 1e-5 to 1e-6

---------

Co-authored-by: xiaoguoguo626807 <100397923+xiaoguoguo626807@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants