diff --git a/test/inductor/test_triton_kernels.py b/test/inductor/test_triton_kernels.py index a6c8afeac9d..b8bd0ef6c5b 100644 --- a/test/inductor/test_triton_kernels.py +++ b/test/inductor/test_triton_kernels.py @@ -26,7 +26,7 @@ from torch.testing._internal.common_utils import ( TEST_WITH_ROCM, ) from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_CUDA, HAS_GPU, HAS_XPU -from torch.testing._internal.logging_utils import logs_to_string +from torch.testing._internal.logging_utils import log_settings, logs_to_string # Defines all the kernels for tests from torch.testing._internal.triton_utils import * # noqa: F403 @@ -3474,8 +3474,10 @@ class CustomOpTests(torch._inductor.test_case.TestCase): w = torch.randn(K, N, device=GPU_TYPE) torch._dynamo.decorators.mark_unbacked(x, 0) - torch._logging.set_logs(output_code=True) - with self.assertLogs(logger="torch._inductor", level=logging.DEBUG) as log: + + with log_settings("+output_code"), self.assertLogs( + logger="torch._inductor", level=logging.DEBUG + ) as log: foo(x, w) output = "\n".join(record.getMessage() for record in log.records)