[dynamo 3.11] enable other torch 3.11 dynamo-related tests (#99180)
Notes:
- No segfaults observed in any CI tests: dynamo unittests, inductor unittests, dynamo-wrapped pytorch tests. So we remove the warning that using dynamo 3.11 may result in segfaults.
- Some dynamo-wrapped pytorch tests hang. They will be skipped in the dynamo-wrapped test suite and will be addressed in a future PR
Pull Request resolved: https://github.com/pytorch/pytorch/pull/99180
Approved by: https://github.com/malfet
diff --git a/test/inductor/test_minifier.py b/test/inductor/test_minifier.py
index 2002c03..76b8d74 100644
--- a/test/inductor/test_minifier.py
+++ b/test/inductor/test_minifier.py
@@ -172,12 +172,9 @@
if __name__ == "__main__":
- import sys
-
from torch._dynamo.test_case import run_tests
# Skip CI tests on mac since CPU inductor does not seem to work due to C++ compile errors,
# also skip on ASAN due to https://github.com/pytorch/pytorch/issues/98262
- # also skip on Py 3.11+ since unhandled exceptions can cause segfaults
- if not IS_MACOS and not TEST_WITH_ASAN and sys.version_info < (3, 11):
+ if not IS_MACOS and not TEST_WITH_ASAN:
run_tests()
diff --git a/test/inductor/test_perf.py b/test/inductor/test_perf.py
index 9279e4a..b60c52f 100644
--- a/test/inductor/test_perf.py
+++ b/test/inductor/test_perf.py
@@ -1,6 +1,5 @@
# Owner(s): ["module: inductor"]
import contextlib
-import sys
from unittest.mock import patch
import functorch
@@ -25,8 +24,7 @@
return compile_fx(gm, example_inputs, inner_compile=count_bytes_inner)
-# TODO remove version check once dynamo supports 3.11
-if sys.version_info < (3, 11) and not IS_WINDOWS:
+if not IS_WINDOWS:
@torch._dynamo.optimize("count_bytes_inductor")
def f(x):
diff --git a/test/test_linalg.py b/test/test_linalg.py
index bbe3019..86a3185 100644
--- a/test/test_linalg.py
+++ b/test/test_linalg.py
@@ -4207,6 +4207,7 @@
@skipCUDAIfNoMagma
@skipCPUIfNoLapack
@unittest.skipIf(not TEST_SCIPY, "SciPy not found")
+ @skipIfTorchDynamo("hangs mysteriously on dynamo 3.11")
@dtypes(*floating_and_complex_types())
def test_triangular_solve_batched_broadcasting(self, device, dtype):
from scipy.linalg import solve_triangular as tri_solve
diff --git a/test/test_tensor_creation_ops.py b/test/test_tensor_creation_ops.py
index 76bc2ef..3b7c9ef 100644
--- a/test/test_tensor_creation_ops.py
+++ b/test/test_tensor_creation_ops.py
@@ -3815,21 +3815,25 @@
check(same_dtype=False, dtype=other, copy=True)
@skipMeta
+ @skipIfTorchDynamo("hangs on 3.11 when running full suite for unknown reason")
@dtypes(*all_types_and_complex_and(torch.half, torch.bool, torch.bfloat16))
def test_copy_tensor(self, device, dtype):
self._test_copy_with_cvt(identity, device, dtype)
@onlyCPU
+ @skipIfTorchDynamo("hangs on 3.11 when running full suite for unknown reason")
@dtypes(*set(numpy_to_torch_dtype_dict.values()))
def test_copy_from_numpy(self, device, dtype):
self._test_copy_with_cvt(to_numpy, device, dtype)
@skipMeta
+ @skipIfTorchDynamo("hangs on 3.11 when running full suite for unknown reason")
@dtypes(*all_types_and_complex_and(torch.half, torch.bfloat16))
def test_copy_from_dlpack(self, device, dtype):
self._test_copy_with_cvt(to_dlpack, device, dtype)
@onlyCPU
+ @skipIfTorchDynamo("hangs on 3.11 when running full suite for unknown reason")
@dtypes(*set(numpy_to_torch_dtype_dict.values()))
def test_copy_from_buffer(self, device, dtype):
self._test_copy_with_cvt(to_memview, device, dtype, shape=(5,), only_with_dtype=True)
diff --git a/torch/_dynamo/eval_frame.py b/torch/_dynamo/eval_frame.py
index e404817..a984d4c 100644
--- a/torch/_dynamo/eval_frame.py
+++ b/torch/_dynamo/eval_frame.py
@@ -479,11 +479,6 @@
raise RuntimeError("Windows not yet supported for torch.compile")
if sys.version_info >= (3, 12):
raise RuntimeError("Python 3.12+ not yet supported for torch.compile")
- elif sys.version_info >= (3, 11):
- warnings.warn(
- "torch.compile support of Python 3.11 is experimental. "
- "Program may segfault."
- )
def is_dynamo_supported():
diff --git a/torch/csrc/dynamo/eval_frame.c b/torch/csrc/dynamo/eval_frame.c
index 9d05e20..059118a 100644
--- a/torch/csrc/dynamo/eval_frame.c
+++ b/torch/csrc/dynamo/eval_frame.c
@@ -437,7 +437,6 @@
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
// THP_EVAL_API_FRAME_OBJECT (_PyInterpreterFrame) is a regular C struct, so
// it should be safe to use system malloc over Python malloc, e.g. PyMem_Malloc
- // FIXME: leaking for now, since it seems to prevent some segfaults???
THP_EVAL_API_FRAME_OBJECT* shadow = malloc(size * sizeof(PyObject*));
if (shadow == NULL) {
Py_DECREF(func);
diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py
index 69ab7b7..404c134 100644
--- a/torch/testing/_internal/common_utils.py
+++ b/torch/testing/_internal/common_utils.py
@@ -2226,10 +2226,9 @@
skipped_before = 0 if result is None else len(result.skipped)
super_run = super().run
- # TODO remove version check once dynamo supports 3.11
- if TEST_WITH_TORCHINDUCTOR and sys.version_info < (3, 11):
+ if TEST_WITH_TORCHINDUCTOR:
super_run = torch._dynamo.optimize("inductor")(super_run)
- elif TEST_WITH_TORCHDYNAMO and sys.version_info < (3, 11):
+ elif TEST_WITH_TORCHDYNAMO:
# TorchDynamo optimize annotation
super_run = torch._dynamo.optimize("eager")(super_run)