Revert "[dynamo] Graph break on on user-defined class in compiled region (#161670)"

This reverts commit e2545487de3dbbe663e3f0adb699547a14da0f6a.

Reverted https://github.com/pytorch/pytorch/pull/161670 on behalf of https://github.com/huydhn due to Sorry for reverting your change but it is failing a trunk test ([comment](https://github.com/pytorch/pytorch/pull/161670#issuecomment-3272626391))
This commit is contained in:
PyTorch MergeBot
2025-09-09 23:40:26 +00:00
parent d2393c2d7d
commit a3e26d1727
374 changed files with 15 additions and 24 deletions

View File

@ -726,14 +726,14 @@ Call to `torch._dynamo.graph_break()`
Unsupported,
lambda: torch.compile(fn, backend="eager", fullgraph=True)(),
"""\
Attempted to call function marked as skipped
Explanation: Dynamo does not know how to trace the builtin `builtins.__build_class__.` This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind).
Hint: If it is a Python builtin, please file an issue on GitHub so the PyTorch team can add support for it and see the next case for a workaround.
Hint: If it is a third-party C/C++ Python extension, please either wrap it into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html for more details) or, if it is traceable, use `torch.compiler.allow_in_graph`.
LOAD_BUILD_CLASS bytecode not supported
Explanation: Dynamo does not support tracing classes that are defined in the compiled region.
Hint: Move the class definition out of the compiled region.
Hint: It may be possible to write Dynamo tracing rules for this code. Please report an issue to PyTorch if you encounter this graph break often and it is causing performance issues.
Developer debug context: module: builtins, qualname: __build_class__, skip reason: <missing reason>
Developer debug context:
For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0007.html
For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb0075.html
from user code:
File "test_error_messages.py", line N, in fn

View File

@ -12684,22 +12684,6 @@ fn
self.assertRaises(Unsupported, f, [])
self.assertRaises(Unsupported, f, "1 + j")
def test_compiled_class_graph_break(self):
counter = CompileCounter()
@torch.compile(backend=counter, fullgraph=False)
def f(x):
x += 1
class C:
pass
return x.sin()
x = torch.randn(3)
f(x)
self.assertEqual(counter.frame_count, 2)
class MiscTestsPyTree(torch._inductor.test_case.TestCase):
@parametrize_pytree_module

Some files were not shown because too many files have changed in this diff Show More