Skip to content

Commit f3553c5

Browse files
msaroufimpytorchmergebot
authored andcommitted
ImportLib py3.10 bug in AOTInductor (pytorch#103277)
Other projects have seen a similar issue quantumlib/Cirq#4637 ## Before ``` (nightly) ubuntu@ip-172-31-2-131:~$ python /tmp/torchinductor_ubuntu/eq/ceqs7t4pesfhqllk6qf4k5spu2cm23l7quqdt2mkrp4rlcjl6kw5.py Traceback (most recent call last): File "/tmp/torchinductor_ubuntu/eq/ceqs7t4pesfhqllk6qf4k5spu2cm23l7quqdt2mkrp4rlcjl6kw5.py", line 47, in <module> module = CppWrapperCodeCache.load(cpp_wrapper_src, 'inductor_entry_cpp', 'czenwgemzbe2etzbh7hzhnwjhyamvwirgodyjlly75fayy4tp3rx', False) File "/opt/conda/envs/nightly/lib/python3.10/site-packages/torch/_inductor/codecache.py", line 846, in load assert isinstance(spec.loader, importlib.abc.Loader) AttributeError: module 'importlib' has no attribute 'abc'. Did you mean: '_abc'? ``` ## After ```sh (nightly) ubuntu@ip-172-31-2-131:~/test$ python /tmp/torchinductor_ubuntu/eq/ceqs7t4pesfhqllk6qf4k5spu2cm23l7quqdt2mkrp4rlcjl6kw5.py 0.000272 ``` Pull Request resolved: pytorch#103277 Approved by: https://github.com/desertfire
1 parent 4c03adc commit f3553c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torch/_inductor/codecache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from concurrent.futures import Future, ProcessPoolExecutor, ThreadPoolExecutor
2323
from ctypes import cdll
2424
from functools import partial
25+
from importlib import abc
2526
from threading import Thread
2627
from time import sleep, time
2728
from typing import Any, Callable, Dict, List, Union
@@ -843,7 +844,7 @@ def load(cls, source_code, func_name, key, cuda):
843844
spec = importlib.util.spec_from_file_location(name, filepath)
844845
assert spec is not None
845846
mod = importlib.util.module_from_spec(spec)
846-
assert isinstance(spec.loader, importlib.abc.Loader)
847+
assert isinstance(spec.loader, abc.Loader)
847848
spec.loader.exec_module(mod)
848849
log.debug("Cpp wrapper done loading %s", filepath)
849850

0 commit comments

Comments
 (0)