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 for grad acc #1190

Open
wants to merge 1 commit into
base: ngoyal_changes_for_pp_fp8
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion fairscale/nn/data_parallel/fully_sharded_data_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,10 @@ def _post_reduction_hook(self, param: Parameter, reduced_grad: torch.Tensor) ->
param._saved_grad_shard.data += reduced_grad.data
reduced_grad = param._saved_grad_shard.data
elif (param.grad is None) and self.fp32_reduce_scatter:
param.main_grad = reduced_grad.data
if getattr(param, "main_grad", None) is not None:
param.main_grad.add_(reduced_grad.data)
else:
param.main_grad = reduced_grad.data

# Optionally move gradients to CPU, typically used if one is running the optimizer on the CPU. Once the full
# backwards pass completes, we will set `.grad` to the CPU copy.
Expand Down
Loading