-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[AutoParallel]Fix get_group method of processmesh #73099
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
Merged
+304
−4
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7414b7d
fix bug -- get_group重复创建通信组
zty-king ec93598
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
zty-king bb9bd86
添加fleet类中的self._hcg成员变量的初始化,用于判断此时是否存在hybrid_communicate_group,同时增加id…
zty-king baf400c
新增hcg判断方法
zty-king f056bd8
修改_hcg属性的判断方式
zty-king 9ef21c6
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
zty-king fea3e64
rerun CI
zty-king 6867d1c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
zty-king 3a3b0e7
rerun CI
zty-king 64084e4
Remove the redundant variables
zty-king 70fea2e
merge the different_hybrid_configs test
zty-king 05e8979
fix the code style
zty-king File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import paddle.distributed as dist | ||
| from paddle.distributed import fleet | ||
|
|
||
|
|
||
| def test_dp_parallel(): | ||
| dist_strategy = fleet.DistributedStrategy() | ||
| dist_strategy.hybrid_configs = { | ||
| "dp_degree": 2, | ||
| "mp_degree": 1, | ||
| "pp_degree": 1, | ||
| } | ||
| fleet.init(is_collective=True, strategy=dist_strategy) | ||
|
|
||
| mesh = dist.ProcessMesh([0, 1], dim_names=["dp"]) | ||
|
|
||
| hcg = fleet.get_hybrid_communicate_group() | ||
|
|
||
| group = mesh.get_group(dim_name="dp") | ||
| hcg_group = hcg.get_data_parallel_group() | ||
|
|
||
| group_ranks = group.ranks | ||
| hcg_group_ranks = hcg_group.ranks | ||
| assert set(group_ranks) == set(hcg_group_ranks) | ||
| group_id = group.id | ||
| hcg_group_id = hcg_group.id | ||
| assert group_id == hcg_group_id | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_dp_parallel() | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import paddle.distributed as dist | ||
| from paddle.distributed import fleet | ||
|
|
||
|
|
||
| def test_mp_parallel(): | ||
| dist_strategy = fleet.DistributedStrategy() | ||
| dist_strategy.hybrid_configs = { | ||
| "dp_degree": 1, | ||
| "mp_degree": 2, | ||
| "pp_degree": 1, | ||
| } | ||
| fleet.init(is_collective=True, strategy=dist_strategy) | ||
|
|
||
| mesh = dist.ProcessMesh([0, 1], dim_names=["mp"]) | ||
|
|
||
| hcg = fleet.get_hybrid_communicate_group() | ||
|
|
||
| group = mesh.get_group(dim_name="mp") | ||
| hcg_group = hcg.get_model_parallel_group() | ||
|
|
||
| group_ranks = group.ranks | ||
| hcg_group_ranks = hcg_group.ranks | ||
| assert set(group_ranks) == set(hcg_group_ranks) | ||
| group_id = group.id | ||
| hcg_group_id = hcg_group.id | ||
| assert group_id == hcg_group_id | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_mp_parallel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import paddle.distributed as dist | ||
| from paddle.distributed import fleet | ||
|
|
||
|
|
||
| def test_pp_parallel(): | ||
| dist_strategy = fleet.DistributedStrategy() | ||
| dist_strategy.hybrid_configs = { | ||
| "dp_degree": 1, | ||
| "mp_degree": 1, | ||
| "pp_degree": 2, | ||
| } | ||
| fleet.init(is_collective=True, strategy=dist_strategy) | ||
|
|
||
| mesh = dist.ProcessMesh([0, 1], dim_names=["pp"]) | ||
|
|
||
| hcg = fleet.get_hybrid_communicate_group() | ||
|
|
||
| group = mesh.get_group(dim_name="pp") | ||
| hcg_group = hcg.get_pipe_parallel_group() | ||
|
|
||
| group_ranks = group.ranks | ||
| hcg_group_ranks = hcg_group.ranks | ||
| assert set(group_ranks) == set(hcg_group_ranks) | ||
| group_id = group.id | ||
| hcg_group_id = hcg_group.id | ||
| assert group_id == hcg_group_id | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_pp_parallel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import paddle.distributed as dist | ||
| from paddle.distributed import fleet | ||
|
|
||
|
|
||
| def test_sep_parallel(): | ||
| dist_strategy = fleet.DistributedStrategy() | ||
| dist_strategy.hybrid_configs = { | ||
| "dp_degree": 1, | ||
| "mp_degree": 1, | ||
| "pp_degree": 1, | ||
| "sep_degree": 2, | ||
| } | ||
| fleet.init(is_collective=True, strategy=dist_strategy) | ||
|
|
||
| mesh = dist.ProcessMesh([0, 1], dim_names=["sep"]) | ||
|
|
||
| hcg = fleet.get_hybrid_communicate_group() | ||
|
|
||
| group = mesh.get_group(dim_name="sep") | ||
| hcg_group = hcg.get_sep_parallel_group() | ||
|
|
||
| group_ranks = group.ranks | ||
| hcg_group_ranks = hcg_group.ranks | ||
| assert set(group_ranks) == set(hcg_group_ranks) | ||
| group_id = group.id | ||
| hcg_group_id = hcg_group.id | ||
| assert group_id == hcg_group_id | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_sep_parallel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import paddle.distributed as dist | ||
| from paddle.distributed import fleet | ||
|
|
||
|
|
||
| def test_sharding_parallel(): | ||
| dist_strategy = fleet.DistributedStrategy() | ||
| dist_strategy.hybrid_configs = { | ||
| "dp_degree": 1, | ||
| "mp_degree": 1, | ||
| "pp_degree": 1, | ||
| "sharding_degree": 2, | ||
| } | ||
| fleet.init(is_collective=True, strategy=dist_strategy) | ||
|
|
||
| mesh = dist.ProcessMesh([0, 1], dim_names=["sharding"]) | ||
|
|
||
| hcg = fleet.get_hybrid_communicate_group() | ||
|
|
||
| group = mesh.get_group(dim_name="sharding") | ||
| hcg_group = hcg.get_sharding_parallel_group() | ||
|
|
||
| group_ranks = group.ranks | ||
| hcg_group_ranks = hcg_group.ranks | ||
| assert set(group_ranks) == set(hcg_group_ranks) | ||
| group_id = group.id | ||
| hcg_group_id = hcg_group.id | ||
| assert group_id == hcg_group_id | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_sharding_parallel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
冗余变量,在if set(group.ranks) == set(self._process_ids)分支下直接返回 group就好
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