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

[Distributed] fix sharding on custom devices #62535

Merged
merged 1 commit into from
Mar 8, 2024
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
9 changes: 8 additions & 1 deletion python/paddle/distributed/communication/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def reduce(tensor, dst, op=ReduceOp.SUM, group=None, sync_op=True):
>>> # [[1, 2, 3], [1, 2, 3]] (2 GPUs, out for rank 1)
"""
# AVG is only supported when nccl >= 2.10
if op == ReduceOp.AVG and paddle.base.core.nccl_version() < 21000:
if op == ReduceOp.AVG and (not is_avg_reduce_op_supported()):
group = (
paddle.distributed.collective._get_global_group()
if group is None
Expand Down Expand Up @@ -201,3 +201,10 @@ def reduce(tensor, dst, op=ReduceOp.SUM, group=None, sync_op=True):
)
else:
raise ValueError(f"Unknown parameter: {op}.")


def is_avg_reduce_op_supported():
if paddle.is_compiled_with_cuda():
return paddle.base.core.nccl_version() >= 21000
else:
return False
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
from paddle.base.dygraph import base as imperative_base
from paddle.base.framework import EagerParamBase
from paddle.distributed import fleet
from paddle.distributed.communication.reduce import ReduceOp
from paddle.distributed.communication.reduce import (
ReduceOp,
is_avg_reduce_op_supported,
)

from ...utils.log_util import logger
from ...utils.tensor_fusion_helper import (
Expand Down Expand Up @@ -101,11 +104,10 @@ def __init__(self, optimizer, hcg):
self.use_reduce_avg = strategy.hybrid_configs[
'sharding_configs'
].use_reduce_avg
if self.use_reduce_avg and paddle.base.core.nccl_version() < 21000:
if self.use_reduce_avg and (not is_avg_reduce_op_supported()):
self.use_reduce_avg = False
warnings.warn(
"nccl reduce_avg requires nccl>=2.10.0, but current version is %s"
% paddle.base.core.nccl_version()
"nccl reduce_avg requires paddle compiled with cuda and nccl>=2.10.0, please check compilation setups."
)

pp_overlap = strategy.hybrid_configs['pp_configs'].sharding_comm_overlap
Expand Down