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

Avoid calling _free_fp16_param_shard() too early #1164

Open
wants to merge 7 commits into
base: ngoyal_changes_for_pp_fp8
Choose a base branch
from

Conversation

jiecaoyu
Copy link

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

  • Did you have fun?
    • Make sure you had fun coding 🙃
  • Did you read the contributor guideline?
  • Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
    • N/A
  • Did you make sure to update the docs?
    • N/A
  • Did you write any new necessary tests?
    • N/A
  • Did you update the changelog? (if needed)
    • N/A

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.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 20, 2024
@jspark1105
Copy link

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?

@jiecaoyu
Copy link
Author

jiecaoyu commented Feb 21, 2024

@jspark1105 Actually this PR is for fixing the error of P1187153460 when enabling PP with https://github.com/fairinternal/xlformers/tree/mm-pp-test.

@jiecaoyu jiecaoyu changed the base branch from ngoyal_changes_for_pp_fp8 to ngoyal_changes_for_pp_fp8_awgu February 21, 2024 11:34
@jiecaoyu jiecaoyu changed the base branch from ngoyal_changes_for_pp_fp8_awgu to ngoyal_changes_for_pp_fp8 February 21, 2024 11:35
@jiecaoyu jiecaoyu force-pushed the ngoyal_changes_for_pp_fp8_jiecaoyu_free_fp16_shard branch from d1bf367 to f2bb56f Compare February 21, 2024 11:39
self._free_full_params([param])

if self.mixed_precision:
if self.mixed_precision and (self._require_backward_grad_sync or self.reshard_after_forward):
Copy link

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?

whbldhwj and others added 5 commits March 25, 2024 11:56
* Changed to only run reshard hook if all gradients computed

* Fix decreasing it/s with multi-grad hook
* optimize memory

* clean up

* allocate GPU memory directly

* add comment

* rename fp32_grads to fp32_flat_grad

* update doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants