trunk/23341ddcfe7cc4813eb7ef760847d9b786336e1e: [dynamo] Restore autocast state between tests in TestCase (#195662)
- PyTorch: 1027 events in the last 90 days
- PyTorch: 1016th Release in the last 90 days
- Previous: earlier the same day · trunk/542330ebe79bfc3e9275d7610f9adcf489e3abf9: Fix scaled-MM DeepSeek indexing and contraction validation (#197028)
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