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

【Hackathon 5th No.51】 为 Paddle 新增 flatten 的 spmd 切分推导规则 #57875

Merged
merged 9 commits into from
Oct 17, 2023

Conversation

WintersMontagne10335
Copy link
Contributor

@WintersMontagne10335 WintersMontagne10335 commented Oct 4, 2023

PR types

Others

PR changes

Others

Description

为 Paddle 新增 flatten 的 spmd 切分推导规则
#57262

@paddle-bot
Copy link

paddle-bot bot commented Oct 4, 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 added the contributor External developers label Oct 4, 2023
@WintersMontagne10335
Copy link
Contributor Author

@pkuzyc 老师您好,ci过了,您有时间的话,麻烦审核一下哈~~

@@ -0,0 +1,284 @@
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

把单测加到 Paddle/test/auto_parallel/spmd_rules/CMakeLists.txt里,否则ci里单测运行不到

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (axis >= ndim) {
axis = ndim - 1;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

api里没有约定axis超过ndim时取最后一维,不要这么操作,可以直接报错

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

} else {
tgt_shape[tgt_shape.size() - 1] *= src_shape[i];
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

tgt_shape后面似乎没有用?没有用的话去掉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

老师您好,后面会输出tgt_shape,有用到的

Copy link
Contributor

Choose a reason for hiding this comment

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

参考后面的评论,输出 start_axis 和 stop_axis,tgt_shape 可以去掉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

<< "] dims_mapping_dst: [" << str_join(dims_mapping_vec[0])
<< "]\n Out dims_mapping: [" << str_join(dims_mapping_vec[1])
<< "]\n\n";

Copy link
Contributor

Choose a reason for hiding this comment

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

把 Out 的输出另用一个VLOG,这样看起来清楚,跑单测的时候输出调试信息看一下:
VLOG(4) << "X dims_mapping_src: [" << str_join(x_dims_mapping)
<< "] dims_mapping_dst: [" << str_join(dims_mapping_vec[0]) << "]";
VLOG(4) << "Out dims_mapping: [" << str_join(dims_mapping_vec[1]) << "]\n\n";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done



class TestFlattenSPMDRule(unittest.TestCase):
def setUp(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

补一个[8,16,8,24]-->[8,16824]、不同切分状态的单测

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@WintersMontagne10335
Copy link
Contributor Author

@pkuzyc 已按照review修改代码,ci通过了,老师有时间可以复审一下哈

out_dist_attr.set_dims_mapping(dims_mapping_vec[1]);

VLOG(4) << "FlattenInferSpmd: X shape: [" << str_join(src_shape)
<< "] Out shape: [" << str_join(tgt_shape) << "]";
Copy link
Contributor

Choose a reason for hiding this comment

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

这里输出 start_axis 和 stop_axis,不要输出 tgt_shape 了,把前面 tgt_shape 的计算也去掉。start_axis 和 stop_axis 是组网给定的,推导的时候用的也是这两个,没有用到 tgt_shape,VLOG 还是输出推导直接用到的内容,方便调试。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

} else {
tgt_shape[tgt_shape.size() - 1] *= src_shape[i];
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

参考后面的评论,输出 start_axis 和 stop_axis,tgt_shape 可以去掉

@WintersMontagne10335
Copy link
Contributor Author

@pkuzyc 修改完毕,ci通过了

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

@JZ-LIANG JZ-LIANG merged commit 034df76 into PaddlePaddle:develop Oct 17, 2023
28 checks passed
hitywt pushed a commit to hitywt/Paddle that referenced this pull request Oct 24, 2023
…#57875)

* Adding flatten spmd segmentation and derivation rules for Paddle

* fix bugs

* add unit test code

* modified:   test/auto_parallel/spmd_rules/CMakeLists.txt

* modify the code according to the review

* modified:   paddle/phi/infermeta/spmd_rules/flatten.cc
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 26, 2023
…#57875)

* Adding flatten spmd segmentation and derivation rules for Paddle

* fix bugs

* add unit test code

* modified:   test/auto_parallel/spmd_rules/CMakeLists.txt

* modify the code according to the review

* modified:   paddle/phi/infermeta/spmd_rules/flatten.cc
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…#57875)

* Adding flatten spmd segmentation and derivation rules for Paddle

* fix bugs

* add unit test code

* modified:   test/auto_parallel/spmd_rules/CMakeLists.txt

* modify the code according to the review

* modified:   paddle/phi/infermeta/spmd_rules/flatten.cc
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.

4 participants