← Back to events
ActiveAIRelease

trunk/23341ddcfe7cc4813eb7ef760847d9b786336e1e: [dynamo] Restore autocast state between tests in TestCase (#195662)

Photo: PyTorch Releases

What happened

Fixes #195487 . torch._dynamo.test_case.TestCase.setUp / tearDown already snapshots torch.is_grad_enabled() and restores it (with a warning) in tearDown if a test left it changed, but has no equivalent for autocast. All four pieces of autocast state -- enabled, dtype, cache_enabled, and the nesting counter -- survive past the end of a test into whichever test runs next. A test that leaks this state (e.g. by calling…

Summary assembled by rule from the sources below

Why it's spreading

Sources