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

PyTorch C++-generated module "not found as" itself? #658

Open
ringohoffman opened this issue May 14, 2024 · 1 comment
Open

PyTorch C++-generated module "not found as" itself? #658

ringohoffman opened this issue May 14, 2024 · 1 comment

Comments

@ringohoffman
Copy link

ringohoffman commented May 14, 2024

My example is in the latest version of torch==2.3.0:

$ pip install torch dill

There is a module in torch._C._dynamo called eval_frame that is not importable as such:

import torch._C._dynamo

print(torch._C._dynamo.eval_frame)  # <module 'torch._C._dynamo.eval_frame'>

import torch._C._dynamo.eval_frame  # ModuleNotFoundError: No module named 'torch._C._dynamo.eval_frame'; 'torch._C._dynamo' is not a package

I suppose it is like an imported module. It is a C++ binding: https://github.com/pytorch/pytorch/blob/556e4ec6c93d4ccfbf84cffe462308340417a95b/torch/csrc/dynamo/init.cpp#L58

When I try to pickle attributes of eval_frame using dill, I get a PicklingError:

import dill
import torch._C._dynamo

print(torch._C._dynamo.eval_frame._CacheEntry)  # <class 'torch._C._dynamo.eval_frame._CacheEntry'>

with open("a.pkl", "wb") as f:
    dill.dump(torch._C._dynamo.eval_frame._CacheEntry, f)  # PicklingError: Can't pickle <class 'torch._C._dynamo.eval_frame._CacheEntry'>: it's not found as torch._C._dynamo.eval_frame._CacheEntry

Is this being mishandled by dill or could there be something malformed about the eval_frame module?

@ringohoffman ringohoffman changed the title Non-dill-picklable module? PyTorch C++-generated module "not found as" itself? May 14, 2024
@ringohoffman
Copy link
Author

Seems like it could be a more fundamental issue with pickle:

Looking for feedback.

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

No branches or pull requests

1 participant