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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequential/Partial unpickling and loading of models #97196

Open
ollelogdahl opened this issue Mar 20, 2023 · 1 comment
Open

Sequential/Partial unpickling and loading of models #97196

ollelogdahl opened this issue Mar 20, 2023 · 1 comment
Labels
module: pickle Problems related to pickling of PyTorch objects triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@ollelogdahl
Copy link

ollelogdahl commented Mar 20, 2023

馃殌 The feature, motivation and pitch

Given a 90GB model file that should not be run, but rather just inspected, you might want to load it partially.

Example usage:

descriptors = torch.load_tensors_desc(filename)
# at this state, the memory usage should be close to zero.
for desc in descriptors:
    tensor = torch.load_tensor_from_desc(filename, desc)
    # at this state, the mamory usage should be about the size of the tensor.

This is not a suggestion regarding syntax. At the moment, this is hardly possible:

  • A normal torch.load will use about 90GB to load the model.
  • Implementing a custom pickle.Unpickler still wants to construct the torch.storage's for all tensors, which conceptually should not be neccessary (also, doesn't work as some tensors may share storage)
  • Reimplementing the pickle-format is tedious.

I'm not sure this is an easy patch, or if it even is possible. Please leave any suggestions in the comments.

Alternatives

No response

Additional context

No response

@ollelogdahl ollelogdahl changed the title Sequential unpickling and loading of models Sequential/Partial unpickling and loading of models Mar 20, 2023
@SherlockNoMad SherlockNoMad added module: pickle Problems related to pickling of PyTorch objects triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Mar 21, 2023
@vadimkantorov
Copy link
Contributor

Related: #79967

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: pickle Problems related to pickling of PyTorch objects triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants