Skip to content

Commit a86ec7f

Browse files
jamesjwufacebook-github-bot
authored andcommitted
Set remote cache version and backend type once in compilation metrics
Summary: X-link: pytorch/pytorch#141967 (Got reverted due to a silly bug, fixed now.) This is causing FbFxGraphRemoteCache.init to no longer be idempotent, i.e. only safe to call once per compile. AOTAutogradCache initializes a new remote cache for the forward and the backward. Technically, we could make AOTAutogradCache smart and globally thread through a single FbFxGraphRemoteCache everywhere. But there's no reason to do so, as this class is just the handle to access the cache. Plus, it's very brittle for FbFxGraphRemoteCache to not be safe to call multiple times ghstack-source-id: 256244970 exported-using-ghexport Reviewed By: laithsakka Differential Revision: D66701970 fbshipit-source-id: a856faa8232a083725fecb802f7b14c0ac2cf09a
1 parent 711de8c commit a86ec7f

File tree

1 file changed

+20
-0
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+20
-0
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

+20
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,24 @@ def safe_str(item: Any) -> str:
996996
return ",".join(safe_str(item) for item in metric)
997997

998998
structured_logging_overhead_s = torch._logging.get_structured_logging_overhead()
999+
1000+
if torch._inductor.utils.should_use_remote_fx_graph_cache():
1001+
try:
1002+
from torch._inductor.fb.remote_cache import (
1003+
FbRemoteFxGraphCache,
1004+
REMOTE_CACHE_VERSION,
1005+
)
1006+
1007+
remote_cache_version = REMOTE_CACHE_VERSION
1008+
backend = FbRemoteFxGraphCache.get_remote_backend()
1009+
inductor_fx_remote_cache_backend_type = type(backend).__name__
1010+
except ModuleNotFoundError:
1011+
remote_cache_version = None
1012+
inductor_fx_remote_cache_backend_type = None
1013+
else:
1014+
inductor_fx_remote_cache_backend_type = None
1015+
remote_cache_version = None
1016+
9991017
common_metrics = {
10001018
"compile_id": str(torch._guards.CompileContext.current_compile_id()),
10011019
"start_time_us": start_time_ns // 1000,
@@ -1013,6 +1031,8 @@ def safe_str(item: Any) -> str:
10131031
"inductor_fx_remote_cache_miss_keys": _convert_collection_to_str(
10141032
"inductor_fx_remote_cache_miss_keys"
10151033
),
1034+
"remote_cache_version": remote_cache_version,
1035+
"inductor_fx_remote_cache_backend_type": inductor_fx_remote_cache_backend_type,
10161036
}
10171037

10181038
# TODO: The following are legacy fields, populated from the fields that replace

0 commit comments

Comments
 (0)