Revert "Add infra to run CPython tests under Dynamo (#150787)"

This reverts commit 7c96dd8f0c9a7e17f598612405f002441c7f07ae.

Reverted https://github.com/pytorch/pytorch/pull/150787 on behalf of https://github.com/huydhn due to Sorry for reverting your change but a failed test is showing up in trunk ([comment](https://github.com/pytorch/pytorch/pull/150787#issuecomment-2852818113))
This commit is contained in:
PyTorch MergeBot
2025-05-06 00:20:02 +00:00
parent 0e9874849f
commit 103fe856e1
13 changed files with 1608 additions and 175 deletions

View File

@ -3157,13 +3157,6 @@ class TestCase(expecttest.TestCase):
def wrap_with_cuda_memory_check(self, method):
return self.wrap_method_with_policy(method, self.assertLeaksNoCudaTensors)
def _dynamo_test_key(self):
return f"{self.__class__.__name__}.{self._testMethodName}"
def compile_fn(self, fn, backend, nopython):
# Allows subclasses to control compilation
return torch._dynamo.optimize(backend, nopython=nopython)(fn)
def _run_custom(self, result=None):
using_unittest = isinstance(result, unittest.TestResult)
@ -3239,16 +3232,16 @@ class TestCase(expecttest.TestCase):
with unittest.mock.patch("torch._dynamo.config.suppress_errors", suppress_errors), maybe_disable_size_asserts:
if TEST_WITH_AOT_EAGER:
super_run = self.compile_fn(super_run, "aot_eager_decomp_partition", nopython)
super_run = torch._dynamo.optimize("aot_eager_decomp_partition")(super_run)
elif TEST_WITH_TORCHDYNAMO or TEST_WITH_TORCHINDUCTOR:
if TEST_WITH_TORCHINDUCTOR:
super_run = self.compile_fn(super_run, "inductor", nopython)
super_run = torch._dynamo.optimize("inductor")(super_run)
else:
# Assume eager-generated GraphModules will not error out.
# If we do, this is probably a Dynamo bug!
super_run = self.compile_fn(super_run, "eager_noexcept", nopython)
super_run = torch._dynamo.optimize("eager_noexcept", nopython=nopython)(super_run)
key = self._dynamo_test_key()
key = f"{self.__class__.__name__}.{self._testMethodName}"
def expect_failure(f, file_name):
@wraps(f)