From 2dadc2c8fc8f373a1106ae46b64d979b236be46d Mon Sep 17 00:00:00 2001 From: Oguz Ulgen Date: Sun, 1 Sep 2024 19:02:09 +0000 Subject: [PATCH] Log fx graph cache bypass reasons (#134792) Summary: Lets track when we bypass and why Test Plan: unit tests Differential Revision: D61994739 Pull Request resolved: https://github.com/pytorch/pytorch/pull/134792 Approved by: https://github.com/jamesjwu --- torch/_inductor/codecache.py | 3 +++ torch/_utils_internal.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/torch/_inductor/codecache.py b/torch/_inductor/codecache.py index af86b71f567..e3c4faedcb9 100644 --- a/torch/_inductor/codecache.py +++ b/torch/_inductor/codecache.py @@ -60,6 +60,7 @@ from torch._inductor.codegen.rocm.compile_command import ( rocm_compile_command, rocm_compiler, ) +from torch._utils_internal import log_cache_bypass T = TypeVar("T") @@ -1359,6 +1360,8 @@ class FxGraphCache: cache_state = "bypass" log.info("Bypassing FX Graph Cache because '%s'", e) cache_info["cache_bypass_reason"] = str(e) + if remote: + log_cache_bypass("bypass_fx_graph", str(e)) cache_event_time = time_ns() if not compiled_graph: compiled_graph = compile_fx_fn( diff --git a/torch/_utils_internal.py b/torch/_utils_internal.py index 87785624354..f2542174520 100644 --- a/torch/_utils_internal.py +++ b/torch/_utils_internal.py @@ -132,6 +132,10 @@ def log_trace_structured_event(*args, **kwargs) -> None: pass +def log_cache_bypass(*args, **kwargs) -> None: + pass + + def log_torchscript_usage(api: str, **kwargs): _ = api return