[tests] reset logs in torch.compile test (#37894)
This commit is contained in:
@@ -2175,6 +2175,8 @@ class GenerationTesterMixin:
|
||||
|
||||
compiled_outputs = []
|
||||
# Uses a context manager to catch recompilation logs. If there is any recompilation, this test fails.
|
||||
# Try/Finally is used to ensure that the log options are reset even if an error is raised.
|
||||
try:
|
||||
torch._logging.set_logs(recompiles_verbose=True)
|
||||
logger = logging.get_logger("torch._dynamo.guards")
|
||||
with CaptureLogger(logger) as cl:
|
||||
@@ -2192,6 +2194,8 @@ class GenerationTesterMixin:
|
||||
self.assertTrue(decoder_cache.is_compileable)
|
||||
# our auto compile should have been called
|
||||
self.assertTrue(hasattr(model_to_be_compiled, "_compiled_call"))
|
||||
finally:
|
||||
torch._logging.set_logs()
|
||||
|
||||
if "Recompiling" in cl.out or ("guard" in cl.out and "failure" in cl.out):
|
||||
raise RuntimeError(
|
||||
|
||||
Reference in New Issue
Block a user