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
Add an API to DDP for dynamically updating the underlying process group. #113580
Add an API to DDP for dynamically updating the underlying process group. #113580
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113580
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 3c754c4 with merge base a2c32b8 (): BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
this PR has a lot of re-formatting which I suggest we exclude. |
@XilunWu This came from |
actually while i hate to be pedantic i think in this case since there are so many lines of code affected, it'd be worth splitting the PR into a stack where the first PR just applies lintrunner and the second PR just has your 'real' changes. |
@rohan-varma @fegin any issue with this PR? (I can do a more detailed review if you dont want to but any objection on the addition of these APIs in principle?) |
So I had to run |
my suggestion was to create a 'stack' where your first pr does the lint changes and then your second PR which is 'on top' does the changes. (are you familiar with ghstack? |
Looks like maybe there was something broken in my local setup causing the linter to change files. Removing the formatting still passes CI though |
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.
Overall, this looks good to me. Unblock for now but one thing I am not sure is that, are the changes in the reducer the only places we need to change? tbh, I am not reading reducer's code enough. Maybe, can @rohan-varma or @fegin also take a look? I also added more CI lables.
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Forgot to leave the comments. The PR looks good to me. |
#113580 introduced the `DDP._update_process_group` API. However, the implementation did not correctly reset all of the necessary state in the reducer. In particular if an error occurred during backward, DDP would end up in an incorrect state. As a result, in this PR I've enhanced the unit test to test for this case and also appropriately fixed resetting Reducer state. Pull Request resolved: #114194 Approved by: https://github.com/rohan-varma
pytorch#113580 introduced the `DDP._update_process_group` API. However, the implementation did not correctly reset all of the necessary state in the reducer. In particular if an error occurred during backward, DDP would end up in an incorrect state. As a result, in this PR I've enhanced the unit test to test for this case and also appropriately fixed resetting Reducer state. Pull Request resolved: pytorch#114194 Approved by: https://github.com/rohan-varma
Motivation
If we would like to reinitialize DDP with a different PG with
torch.compile
, we need to do the following:This results in recompilation of the entire model and is very expensive. Since the only thing we need to update is the PG, we should be able to do this without having to compile the model again.
Proposal
As a result, in this PR I've introduced an
_update_process_group
API which can dynamically update the underlying ProcessGroup used by DDP without needing to reinitialize DDP again.cc @mrshenli @zhaojuanmao @satgera @rohan-varma @gqchen @aazzolini @osalpekar @jiayisuse @H-Huang @kwen2501 @awgu @penguinwu @fegin @XilunWu @wanchaol @fduwjj @wz337 @tianyu-l @wconstab @yf225 @kiukchung @d4l3k @LucasLLC