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]: Support optional, inplace input and output for DistTensor. #57092

Merged
merged 19 commits into from
Sep 13, 2023

Conversation

GhostScreaming
Copy link
Contributor

@GhostScreaming GhostScreaming commented Sep 8, 2023

PR types

Others

PR changes

Others

Description

Pcard-73145

  1. Support paddle::optional<phi::Tensor> and paddle::optional<std::vector<phi::Tensor>> input and output for DistTensor. Expand_As, Bincount, Linear_Interp forward and backward are verified.
  2. Support inplace output. Including following inplace phi::Tensor, inplace std::vector<phi::Tensor>, inplace paddle::optional<phi::Tensor> and inplace paddle::optional<std::vector<phi::Tensor>> type of outputs. check_finite_and_unscale_, adamax_ and merged_adam_ are verified.
  3. Operators have output of std::tuple<...> are supported now as all type of output are supported.

…or output of operators.

Following testcases are passed.
1. concat: std::vector<phi::Tensor> -> phi::Tensor
2. unbind: phi::Tensor -> std::vector<phi::Tensor>
3. broadcast_tensors: std::vector<phi::Tensor> -> std::vector<phi::Tensor>
paddle::optional<std::vector<phi::Tensor>> input and output for DistTensor.
@paddle-bot
Copy link

paddle-bot bot commented Sep 8, 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.

@GhostScreaming GhostScreaming changed the title Dist tensor support [Auto Parallel]: Support paddle::optional<phi::Tensor> and paddle::optional<std::vector<phi::Tensor>> input and output for DistTensor. Sep 8, 2023
@GhostScreaming GhostScreaming changed the title [Auto Parallel]: Support paddle::optional<phi::Tensor> and paddle::optional<std::vector<phi::Tensor>> input and output for DistTensor. [Auto Parallel]: Support optional input and output for DistTensor. Sep 8, 2023
paddle/phi/api/yaml/generator/dist_api_gen.py Outdated Show resolved Hide resolved
OPTIONAL_GLOBAL_VECTOR_META_IN_TEMPLATE = """
OPTIONAL_GLOBAL_SINGLE_META_IN_TEMPLATE = """meta_dist_{}, """
OPTIONAL_GLOBAL_SINGLE_META_IN_DECL_TEMPLATE = """
phi::MetaTensor meta_dist_{name} = {name} ? MakeMetaTensor(*(*{name}).impl()) : phi::MetaTensor();
Copy link
Contributor

Choose a reason for hiding this comment

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

其实我们现在做了两遍meta tensor的构造,前面MakeDistMetaTensor也构造了一遍,后面我们可以看下能否在下面复用前面MakeDistMetaTensor的结果,从而降低调度开销

Copy link
Contributor Author

Choose a reason for hiding this comment

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

收到~

paddle/phi/api/yaml/generator/dist_api_gen.py Outdated Show resolved Hide resolved
test/auto_parallel/test_dist_tensor.py Outdated Show resolved Hide resolved
1, # align_mode
)
# print("local_out: ", local_out)
dist_out = paddle._C_ops.linear_interp(
Copy link
Contributor

Choose a reason for hiding this comment

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

这个用正式api paddle.nn.functional.interpolate 可以测试吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

需要测试linear_interppaddle::optional<phi::Tensor> out_sizepaddle::optional<std::vector<phi::Tensor>> size_tensor类型的输入,看了一下paddle.nn.functional.interpolate的代码实现,size_tensor是传不进去的。

…:optional<Tensor> and paddle::optional<std::vector<Tensor>>
@GhostScreaming GhostScreaming changed the title [Auto Parallel]: Support optional input and output for DistTensor. [Auto Parallel]: Support optional, inplace input and output for DistTensor. Sep 12, 2023
Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM

@LiYuRio LiYuRio merged commit 9f321c8 into PaddlePaddle:develop Sep 13, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…ensor. (PaddlePaddle#57092)

* [WIP] Support std::vector<phi::Tensor> input and output for DistTensor.
Concat forward and backward are verified.

* Polish code for new dist tensor implementation.

* Fix bug of DistTensor upgrade. Add support functions for std::vector<Tensor> -> std::vector<Tensor>.

* Add support for DistTensor type of std::vector<phi::Tensor> as input or output of operators.
Following testcases are passed.
1. concat: std::vector<phi::Tensor> -> phi::Tensor
2. unbind: phi::Tensor -> std::vector<phi::Tensor>
3. broadcast_tensors: std::vector<phi::Tensor> -> std::vector<phi::Tensor>

* Polish code. Remove useless comments.

* Add update_loss_scaling in skip_op_lists.

* Polish code.

* [Auto Parallel]: Support paddle::optional<Tensor> and
paddle::optional<std::vector<phi::Tensor>> input and output for DistTensor.

* Polish code.

* Polish code. And support inplace Tensor, std::vector<Tensor>, paddle::optional<Tensor> and paddle::optional<std::vector<Tensor>>

* Polish testcase code. Add testcase for inplace paddle::optional<phi::Tensor>.

* Remove useless codes in testcase code.

* Polish code style.

* Polish code style. And fix problems of testcases.
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.

3 participants