PyTorch C++-generated module "not found as" itself?
Opened this issue · 1 comments
ringohoffman commented
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 commented
Seems like it could be a more fundamental issue with pickle
:
Looking for feedback.