Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion multipy/runtime/interpreter/interpreter_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,16 @@ import importlib.abc
import linecache
from zipfile import ZipFile

class DummyMultiPyModule:
def __getattr__(self, key):
return self

def __call__(self, *args, **kwargs):
return self

# Disable Python library registration since it's not compatible with multipy.
sys.modules["torch._meta_registrations"] = object
sys.modules["torch._meta_registrations"] = DummyMultiPyModule()
sys.modules["torch._decomp"] = DummyMultiPyModule()

class RegisterModuleImporter(importlib.abc.InspectLoader):
def __init__(self, find_module_source):
Expand Down Expand Up @@ -160,6 +168,8 @@ class RegisterModuleImporter(importlib.abc.InspectLoader):
# print("modules:", sys.modules)

import torch # has to be done serially otherwise things will segfault
torch._decomp = DummyMultiPyModule()

import multipy.utils
try:
import torch.version # for some reason torch doesn't import this and cuda fails?
Expand Down