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

[NaN check] Add NaN check to support bfloat16. #5879

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion deepspeed/runtime/zero/stage3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ def _overflow_clean_up(self, prev_scale):
def _overflow_check_and_loss_scale_update(self):

# First compute norm for all group so we know if there is overflow
if self.dtype == torch.float16:
if self.dtype in [torch.float16, torch.bfloat16]:
self.check_overflow()

#loss scaling related computation
Expand Down
2 changes: 1 addition & 1 deletion deepspeed/runtime/zero/stage_1_and_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ def step(self, closure=None):
see_memory_usage(f"In step before checking overflow")

# First compute norm for all group so we know if there is overflow
if self.dtype == torch.float16:
if self.dtype in [torch.float16, torch.bfloat16]:
self.check_overflow()

prev_scale = self.loss_scale
Expand Down
Loading