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

Stage 2 zero grad fix #44

Open
wants to merge 1 commit into
base: main
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 fastDP/privacy_engine_dist_stage23.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,13 @@ def reduce_partition_and_remove_grads(*notneeded):
# deepspeed stage 2 modification-----------
from deepspeed.runtime.zero.stage_1_and_2 import DeepSpeedZeroOptimizer

def zero_grad_DP_stage2(self, set_grads_to_None=True):
def zero_grad_DP_stage2(self, set_grads_to_None=True, set_to_none=None):
"""
Zero FP16 parameter grads.
"""
if set_to_none is not None:
# In transformers 4.29, set_grads_to_None is renamed to set_to_none
set_grads_to_None = set_to_none
#print(self.micro_step_id)

# FP32 grad should never exist.
Expand Down