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

multipy/runtime: mock _decomp #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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