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

[OPT]Set order for hybridparallel setting #51781

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions paddle/fluid/framework/distributed_strategy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ message HybridConfig {
optional int32 mp_degree = 2 [ default = 1 ];
optional int32 pp_degree = 3 [ default = 1 ];
optional int32 sharding_degree = 4 [ default = 1 ];
repeated string order = 5 ;
}

message AMPConfig {
Expand Down
5 changes: 4 additions & 1 deletion python/paddle/distributed/fleet/base/distributed_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,8 @@ def hybrid_configs(self):

**pp_degree(int)**: set number of GPUs in a pipeline parallel group. Default 1

**order(list(string))**: set hybrid parallel dimensions, the order is from outside to inside. Default ['dp','pp','sharding','mp']

Examples:
.. code-block:: python

Expand All @@ -1681,7 +1683,8 @@ def hybrid_configs(self):
strategy.hybrid_configs = {
"dp_degree": 1,
"mp_degree": 2,
"pp_degree": 1}
"pp_degree": 1,
"order":['dp','pp','sharding','mp']}

"""
return get_msg_dict(self.strategy.hybrid_configs)
Expand Down
28 changes: 21 additions & 7 deletions python/paddle/distributed/fleet/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,28 @@ def _init_hybrid_parallel_env(self):

self.dp_degree = max(self.dp_degree, 1)

d_hybrid_degree = {
"dp": ["data", self.dp_degree],
"pp": ['pipe', self.pp_degree],
"sharding": ['sharding', self.sharding_degree],
"mp": ['model', self.mp_degree],
}

order = self.hybrid_configs["order"]
if not order:
order = ['dp', 'pp', 'sharding', 'mp']
if order[:].sort() != list(d_hybrid_degree.keys())[:].sort():
assert False, "The order of hybrid_config setting is incorrect."

hybrid_group_names = []
dims = []
for h_name in order:
name, degree = d_hybrid_degree[h_name]
hybrid_group_names.append(name)
dims.append(degree)

self._topology = tp.CommunicateTopology(
hybrid_group_names=["data", "pipe", "sharding", "model"],
dims=[
self.dp_degree,
self.pp_degree,
self.sharding_degree,
self.mp_degree,
],
hybrid_group_names=hybrid_group_names, dims=dims
)

self._hcg = tp.HybridCommunicateGroup(self._topology)
Expand Down