-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Addressing Issue #5241: Updating deepspeed/runtime/zero/stage_1_and_2.py #5252
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the following work? Based on the non-offload code path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea here is to warn the user that this is an unexpected behavior and ususally it would cause/is caused by an error in the gradients. I'm fine with the current temporary fix, but I still hope we can probably throw an exception here or print some warning information to let the user know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@desire2020, I was making two points
total_norm
should be tensors in both paths, and same logging behavior.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tjruwase , yes I checked there is no subsequent overflow message warning. The code immediately crashed, after returning -1 here and then when calculating the grad norm elsewhere, PyTorch throws an uncaught exception when we are trying to calculate the norm of an (autocasted) torch.int64. I was using deepspeed directly with the official huggingface lm example code with mixed precision of bf16, didn't change too much of it. For the error message, please refer to Issue #5241. It's the same in my case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@desire2020, thanks for the response. I think you have stumbled on a bigger problem in our code. Normally, we check for overflows before [computing gradient norms]. We assume that the conditions for an overflow are the same as for gradient norm of
-1
, and so norm computation is skipped on overflows. For bf16 training, we don't check for overflows because we assume overflows are impossible. But it seems your test case contradicts our assumption. Can you try enabling overflow checks for bf16 training to see if overflow is detected? Thanks!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tjruwase , sorry if I'm asking a stupid question, is this a currently supported feature or we'd be expecting it in the next release of deepspeed? 'Cause I don't find related implementation of this feature in the current version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@desire2020, no worries, I was not clear. I was asking if you could add this feature to your PR? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More specifically, the desired feature is to add "check_overflow" option into the "bf16" dict of the ds_config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjruwase Ok, do you think I should add it for fp16 at the same time? If people are certain that their objective is stable and simple, they can use this option to further boost their fp16 mixed precision training too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but let's make the fp16 option true by default to preserve BC. Thanks!