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

get_grad_norm_direct: fix a case of empty norm group #5148

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

nelyahu
Copy link
Contributor

@nelyahu nelyahu commented Feb 18, 2024

fix for #5145
empty norm group create a norm tensor with shape=[1], while other norms will be shapeless. torch.stack does not support such case. Fixing empty group norm to be shapless as well, instead of shape=[1].

empty norm group create a norm tensor with shape=[1], while other norms
will be shapeless. torch.stack does not support such case.
Fixing empty group norm to be shapless as well, instead of shape=[1].
@lekurile lekurile self-requested a review February 20, 2024 19:45
@lekurile
Copy link
Contributor

Hello @nelyahu,

Thanks for the PR, had to make a quick change from:

total_norm = torch.FloatTensor(0.0).to(self.device)

to:

total_norm = torch.tensor(0.0, dtype=torch.float32).to(self.device)

due to torch.FloatTensor not supporting initialization in that manner i.e.:

TypeError: new(): data must be a sequence (got float)

Tested the prallelism again and all looks good:

TP PP DP Pass/Fail
2 1 1 PASS
1 2 1 PASS
1 1 2 PASS
2 2 1 PASS
1 2 2 PASS
2 1 2 PASS
2 2 2 PASS

@lekurile lekurile added this pull request to the merge queue Feb 20, 2024
Merged via the queue into microsoft:master with commit f062a1b Feb 20, 2024
12 checks passed
ShellyNR pushed a commit to ShellyNR/DeepSpeed that referenced this pull request Mar 11, 2024
fix for [microsoft#5145 ](microsoft#5145)
empty norm group create a norm tensor with shape=[1], while other norms
will be shapeless. torch.stack does not support such case. Fixing empty
group norm to be shapless as well, instead of shape=[1].

---------

Co-authored-by: Lev Kurilenko <[email protected]>
Co-authored-by: Lev Kurilenko <[email protected]>
rraminen pushed a commit to ROCm/DeepSpeed that referenced this pull request May 9, 2024
fix for [microsoft#5145 ](microsoft#5145)
empty norm group create a norm tensor with shape=[1], while other norms
will be shapeless. torch.stack does not support such case. Fixing empty
group norm to be shapless as well, instead of shape=[1].

---------

Co-authored-by: Lev Kurilenko <[email protected]>
Co-authored-by: Lev Kurilenko <[email protected]>
@nelyahu nelyahu deleted the fix_get_grad_norm_direct branch June 9, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants