-
Notifications
You must be signed in to change notification settings - Fork 282
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
Avoid calling _free_fp16_param_shard() too early #1164
base: ngoyal_changes_for_pp_fp8
Are you sure you want to change the base?
Avoid calling _free_fp16_param_shard() too early #1164
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? |
@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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
* Changed to only run reshard hook if all gradients computed * Fix decreasing it/s with multi-grad hook
Co-authored-by: Jie Wang <[email protected]>
* optimize memory * clean up * allocate GPU memory directly * add comment * rename fp32_grads to fp32_flat_grad * update doc
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.