Avoid calling _free_fp16_param_shard() too early#1164
Open
jiecaoyu wants to merge 7 commits intongoyal_changes_for_pp_fp8from
Open
Avoid calling _free_fp16_param_shard() too early#1164jiecaoyu wants to merge 7 commits intongoyal_changes_for_pp_fp8from
jiecaoyu wants to merge 7 commits intongoyal_changes_for_pp_fp8from
Conversation
|
Thanks! With this PR we no longer have extra all gathers in bwd for the multi modal model? If so how much speed up do we see? |
Author
|
@jspark1105 Actually this PR is for fixing the error of P1187153460 when enabling PP with https://github.com/fairinternal/xlformers/tree/mm-pp-test. |
d1bf367 to
f2bb56f
Compare
awgu
reviewed
Feb 22, 2024
| self._free_full_params([param]) | ||
|
|
||
| if self.mixed_precision: | ||
| if self.mixed_precision and (self._require_backward_grad_sync or self.reshard_after_forward): |
There was a problem hiding this comment.
IIUC, this added and (...) condition is only needed for the _is_sharded == False case. Should we still free it for the _is_sharded == True case?
Co-authored-by: Jie Wang <jiewang@meta.com>
* Changed to only run reshard hook if all gradients computed * Fix decreasing it/s with multi-grad hook
Co-authored-by: Jie Wang <jiewang@meta.com>
* optimize memory * clean up * allocate GPU memory directly * add comment * rename fp32_grads to fp32_flat_grad * update doc
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
With PP, we are calling _free_fp16_param_shard() too early. Therefore, we need to add more conditions to only call _free_fp16_param_shard() when we finished all the usage of the FP16 shard.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.