[tests] reset logs in torch.compile test (#37894)
This commit is contained in:
@@ -2175,6 +2175,8 @@ class GenerationTesterMixin:
|
|||||||
|
|
||||||
compiled_outputs = []
|
compiled_outputs = []
|
||||||
# Uses a context manager to catch recompilation logs. If there is any recompilation, this test fails.
|
# 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)
|
torch._logging.set_logs(recompiles_verbose=True)
|
||||||
logger = logging.get_logger("torch._dynamo.guards")
|
logger = logging.get_logger("torch._dynamo.guards")
|
||||||
with CaptureLogger(logger) as cl:
|
with CaptureLogger(logger) as cl:
|
||||||
@@ -2192,6 +2194,8 @@ class GenerationTesterMixin:
|
|||||||
self.assertTrue(decoder_cache.is_compileable)
|
self.assertTrue(decoder_cache.is_compileable)
|
||||||
# our auto compile should have been called
|
# our auto compile should have been called
|
||||||
self.assertTrue(hasattr(model_to_be_compiled, "_compiled_call"))
|
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):
|
if "Recompiling" in cl.out or ("guard" in cl.out and "failure" in cl.out):
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
|
|||||||
Reference in New Issue
Block a user