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

compiled model state_dict() workaround #639

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

EIFY
Copy link
Contributor

@EIFY EIFY commented Sep 18, 2023

Pytorch 2.0 adds _orig_mod. prefix to keys of state_dict() of compiled models. For compatibility, we save state_dict() of the original model, which shares the weights without the prefix.

I have verified this workaround by resuming model training from a checkpoint created after a few epochs of compiled model training. The behaviors are within the expected randomness from the original trajectory. See also PyTorch forum topic "How to save/load a model with torch.compile".

Pytorch 2.0 adds '_orig_mod.' prefix to keys of state_dict() of compiled models.
For compatibility, we save state_dict() of the original model, which shares the
weights without the prefix.
@rwightman rwightman merged commit 905fc54 into mlfoundations:main Sep 22, 2023
5 checks passed
@EIFY EIFY deleted the save-compiled branch September 22, 2023 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants