-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Stateful Checkpointing for Distributed [1/N] #113867
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113867
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 3c2dcb7 with merge base ec124b9 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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.
LGTM, the failing test is real.
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.
LGTM! Thanks!
| @@ -0,0 +1,104 @@ | |||
| # Owner(s): ["oncall: distributed"] | |||
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.
We can later move this to https://github.com/pytorch/examples or update this tutorial in https://github.com/pytorch/tutorials/blob/main/recipes_source/distributed_checkpoint_recipe.rst.
From what I learned, we should not keep the examples PT repo, but we still have a couples for checkpoint and other distributed componenets.
| return torch.rand(8, 8, device="cuda") | ||
|
|
||
|
|
||
| def _make_stateful(model, optim): |
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.
what does this do? should users rely on it, or should they write their own state function on their model?
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.
This question is a bit loaded, I'm still thinking about the best UX around this item in particular. In general, if users are defining objects with custom Stateful behavior, they should define state_dict and load_state_dict on those objects.
For model/optim, which need to call get_state_dict and set_state_dict in state_dict and load_state_dict, the two options so far are:
- Create a wrapper:
class DOptim: def __init__(self, model, optim): self.model = model self.optim = optim ...
We're still evaluating whether it makes sense to include the wrapper as part of DCP since it can be a little tricky and could lead to a less then ideal UX
- The other option, which I don't think is a bad one, is using the
_patchmethods as above. The patch methods are still in testing but I think it's pretty reasonable
|
@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 |
First pass at adding a save/load API, as well as definition of Stateful objects. Amongst a couple todo's, we still need to explore adding an `all_gather` & potentially a `barrier` while iterating through state keys. Pull Request resolved: pytorch#113867 Approved by: https://github.com/fegin, https://github.com/wz337
First pass at adding a save/load API, as well as definition of Stateful objects.
Amongst a couple todo's, we still need to explore adding an
all_gather& potentially abarrierwhile iterating through state keys.cc @mrshenli @pritamdamania87 @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