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

Enhanced pickle support for state_dict retrieval from nested dictionaries in .pth files #1671

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

antimora
Copy link
Contributor

@antimora antimora commented Feb 6, 2024

Fixes #1663

This PR enhances pickle to retrieve the state_dict with a specified optional key. Sometimes the state_dict is stored at the top level of a dictionary, alongside other metadata within a .pth file, as seen with OpenAI's Whisper model. This modification allows the direct retrieval of states, rather than requiring the .pth file to be resaved using Python.

This solution was discussed and agreed upon here: #1663 (comment)

The fix has been tested with a new unit test and with the Whisper model (although the model cannot currently be read entirely because the data is not saved in a contiguous manner).

@LaurentMazare LaurentMazare merged commit b75e894 into huggingface:main Feb 6, 2024
@LaurentMazare
Copy link
Collaborator

Thanks!

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.

pickle::read_all returns empty when loading open-ai's whisper pt file.
2 participants