-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[AutoParallel] Support disttensor for Tensor.copy_ #58369
[AutoParallel] Support disttensor for Tensor.copy_ #58369
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
@@ -128,6 +136,60 @@ void Tensor::copy_(const Tensor &src, | |||
auto *dev_ctx = pool.GetMutable( | |||
place.GetType() == target_place.GetType() ? target_place : place); | |||
|
|||
#ifdef PADDLE_WITH_DISTRIBUTE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto parallel可以放在DenseTensor kernel的分支,是DenseTensor Kernel的一个扩展机制
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
paddle/phi/api/lib/tensor_method.cc
Outdated
|
||
// 1. InferSpmd (Infer DistAttr of Inputs&Outputs) | ||
auto meta_dist_input_x = MakeDistMetaTensor(*src.impl()); | ||
auto spmd_info = phi::distributed::ElementwiseUnaryInferSpmd( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里咱们是不是直接创建一个输出,把输入的设置上去就行,不用走InferSpmd,这个elementwise的逻辑还挺多的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不会出现:这个Tensor不需要在这个卡上计算的情况吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哦,我理解错了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
paddle/phi/api/lib/tensor_method.cc
Outdated
// 4. Select Kernel | ||
|
||
// 5. Reshard Input | ||
auto dist_input_x = ReshardApiInputToKernelInput( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好像也不需要reshard,原先的值给输出copy过去就行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
paddle/phi/api/lib/tensor_method.cc
Outdated
phi::Copy(*dev_ctx, *input_x, target_place, blocking, dense_out); | ||
|
||
// 9. Reshard Partial Output to Replicated (Temporary) | ||
ReshardOutputPartialAxisToReplicated(dev_ctx, dist_out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也可以省略
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
phi::UnchangedInferMeta(MakeMetaTensor(*(src.impl_)), &meta_dist_out); | ||
|
||
if (rank_is_in_current_mesh) { | ||
// 4. Select Kernel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的注释感觉和代码对不上,是不是可以删一删
// API `copy_` does not need to set DistAttr for output. | ||
return; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的条件宏是不是没必要呀
* support disttensor for tensor.copy_
PR types
Others
PR changes
Others
Description
Tensor.copy_是典型的PHI api逻辑,会传入DistTensor。需要补充DistTensor分支。
PCard-70444