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

support reduce_avg for sharding v2 #62623

Merged
merged 1 commit into from
Mar 12, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ def __init__(self, optimizer, hcg):
self.pp_overlap = pp_config.sharding_comm_overlap
self.pp_release_grads = pp_config.release_gradients

# Check nccl reduce_avg setting
self.use_reduce_avg = sharding_config.use_reduce_avg
if self.use_reduce_avg and (not is_avg_reduce_op_supported()):
self.use_reduce_avg = False
warnings.warn(
"nccl reduce_avg requires paddle compiled with cuda and nccl>=2.10.0, please check compilation setups."
)

self._build_comm_buffers(acc_steps)
# NOTE(shenliang03): Sort the comm_buffers by dst rank,
# it will improve the performance in reduce communicate. Default
Expand Down Expand Up @@ -620,6 +628,7 @@ def _build_comm_buffers(self, acc_steps, group_size=256 * 1024 * 1024):
acc_steps,
act=HOOK_ACTION.REDUCE_SCATTER,
release_grads=self.pp_release_grads,
use_reduce_avg=self.use_reduce_avg,
)
self._comm_buffer_list.append(buffer)

Expand Down