Skip to content

[Cherry-pcik]add release for color sharding (#68826) #68874

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
merged 1 commit into from
Oct 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,8 @@ def clear_grad_func(p):

if self.sd_release_grads and not self.pp_overlap:
for comm_buffer in self._comm_buffer_list:
comm_buffer._clear_grad_storage()
if comm_buffer.need_reduce_scale_sync():
comm_buffer._clear_grad_storage()

def filter_parameters(self, parameter_list, hcg):
parameter_list = [
Expand All @@ -834,8 +835,9 @@ def reduce_gradients(self, parameter_list, hcg):
with framework.no_grad():
for comm_buffer in self._comm_buffer_list:
if self.sd_release_grads and comm_buffer.grad_storage is None:
for param in comm_buffer.params:
comm_buffer._copy_grad_to_buffer(param)
if comm_buffer.need_reduce_scale_sync():
for param in comm_buffer.params:
comm_buffer._copy_grad_to_buffer(param)

if g_sharding_v2_check_zero_padding:
self._check_padding_zero()
Expand Down
3 changes: 3 additions & 0 deletions python/paddle/distributed/fleet/utils/tensor_fusion_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ def _copy_grad_to_buffer(self, param):
)

grad_var = param.main_grad if self.use_main_grad else param.grad
assert (
grad_var is not None
), f"The current parameter[{param.name}] has no gradient, its stop_grdient is {param.stop_gradient}"
grad_var.stop_gradient = True
grad_var.flatten_()

Expand Down