[dynamo] [guard] Add caching for inside torch.compile.disable function to avoid unnecessary recompilation. (#160934)

Fixes #157399
cherry pick of d6a5c03

@mlazos

Pull Request resolved: https://github.com/pytorch/pytorch/pull/160934
Approved by: https://github.com/mlazos
This commit is contained in:
thenumberouscode
2025-08-19 06:01:22 +00:00
committed by PyTorch MergeBot
parent 29afde2020
commit 8f31aa97a3
5 changed files with 91 additions and 7 deletions

View File

@ -614,6 +614,8 @@ class TestAutograd(TestCase):
with disable_gc():
unpack_hook_ref = scope()
if torch._dynamo.is_compiling():
torch._dynamo.reset()
self.assertIsNone(unpack_hook_ref())
def test_will_engine_execute_node(self):