-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
FSDP grad accum fix #34645
FSDP grad accum fix #34645
Conversation
@ArthurZucker @muellerzr for review |
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 for catching this!
is it possible to also trigger the slow tests for this PR too to make sure the new test passes? |
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.
Make sense ! Thanks for fixing !
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
Thank you.
Newly added tests are passing (in this PR) and failed on main
. So it does its job.
The change in trainer
seems reasonable to me too.
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.
Sorry for being late on this, thanks 🤗 will patch
* add gradient accumulation steps tests for fsdp * invert no_sync context to fix training for fsdp
* add gradient accumulation steps tests for fsdp * invert no_sync context to fix training for fsdp
* add gradient accumulation steps tests for fsdp * invert no_sync context to fix training for fsdp
* add gradient accumulation steps tests for fsdp * invert no_sync context to fix training for fsdp
What does this PR do?
8c62a92#diff-ed55888e6665791fe92cc8fc0c499da54f4ace6738551cd9a2591881cda076deL2473-R2480 seems to have broken FSDP training as we need to wrap the train step in no_sync on every step except the last step in the gradient accumulation batch. Without this, during the optimizer.step(), I get the error:
this wasn't caught by the fsdp tests since gradient accumulation wasn't part of those tests, so I also added tests for that as well.
see https://muellerzr.github.io/blog/gradient_accumulation.html#what-is-the-right-way-then
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.