-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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] Ensure that customized non tensor optimizer state can be saved #99214
Conversation
The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test. Differential Revision: [D45021331](https://our.internmc.facebook.com/intern/diff/D45021331/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/99214
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fd264bd: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test. Differential Revision: [D45021331](https://our.internmc.facebook.com/intern/diff/D45021331/) ghstack-source-id: 186204536 Pull Request resolved: #99214
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 the super fast fix! This looks good to me. I just left a few nits.
osd = FSDP.optim_state_dict(model, optim, optim_state_dict=original_osd) | ||
osd_to_load = FSDP.optim_state_dict_to_load(model, optim, osd ) | ||
for param_id, state in osd_to_load["state"].items(): | ||
# Addd customized value |
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.
nit: typo 😄
# Addd customized value | |
# Add customized value |
step() | ||
original_osd = deepcopy(optim.state_dict()) | ||
for param_id, state in original_osd["state"].items(): | ||
# Addd customized value |
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.
# Addd customized value | |
# Add customized value |
state["value2"] = None | ||
|
||
osd = FSDP.optim_state_dict(model, optim, optim_state_dict=original_osd) | ||
osd_to_load = FSDP.optim_state_dict_to_load(model, optim, osd ) |
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.
nit: I wonder if lint will complain about this one
osd_to_load = FSDP.optim_state_dict_to_load(model, optim, osd ) | |
osd_to_load = FSDP.optim_state_dict_to_load(model, optim, osd) |
…an be saved" The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test. Differential Revision: [D45021331](https://our.internmc.facebook.com/intern/diff/D45021331/) [ghstack-poisoned]
Pull Request resolved: #99214 The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test. ghstack-source-id: 186225950 Differential Revision: [D45021331](https://our.internmc.facebook.com/intern/diff/D45021331/)
…an be saved" The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test. This PR will solve #99079 Differential Revision: [D45021331](https://our.internmc.facebook.com/intern/diff/D45021331/) [ghstack-poisoned]
Pull Request resolved: #99214 The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test. ghstack-source-id: 186239769 Differential Revision: [D45021331](https://our.internmc.facebook.com/intern/diff/D45021331/)
@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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / macos-12-py3-arm64 / build Details for Dev Infra teamRaised by workflow job |
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 🎉 !
@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 |
Stack from ghstack (oldest at bottom):
The current logic does not actually handle all different non-tensor optimizer states correctly. This PR fixes the issue and adds a test.
This PR will solve #99079
Differential Revision: D45021331