-
Notifications
You must be signed in to change notification settings - Fork 281
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
[FSDPv1] Only perform cat() during last microbatch backward() within FlattenParamsWrapper #1184
Merged
chrisxcai
merged 1 commit into
ngoyal_changes_for_pp_fp8_jiecaoyu_free_fp16_shard
from
chriscai_ngoyal_changes_for_pp_fp8_jiecaoyu_free_fp16_shard
May 16, 2024
Merged
Changes from all commits
Commits
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
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.
It's been a while to look at FSDP code so can be a silly question, but wonder for TransformerEngine modules that keep their weight grads in .main_grad in fp32 precision this can be a duplication.
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.
The fp32 weight grads being in
.main_grad
would be unexpected to me. My understanding was that we are not using that functionality and instead relying on FSDP to do the fp32 gradient accumulation since getting the weights'.main_grad
to backprop correctly into the FSDPFlatParameter
is tricky.I think that in the current approach,
.main_grad
should only be written to after the reduce-scatter:fairscale/fairscale/nn/data_parallel/fully_sharded_data_parallel.py
Line 1879 in 9cbb4a7
However, since the memory usage is higher, maybe somehow there is indeed some duplication with this approach.
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.
Thanks! I just checked we indeed don't use main_grad: https://github.com/fairinternal/xlformers/blob/main/src/model/te_layers.py#L104
I see https://github.com/fairinternal/xlformers/pull/1418 and #1142 were not merged but something we may want to consider to avoid gradient accumulation overhead.