Skip to content

Commit b8cb285

Browse files
fbgheithfacebook-github-bot
authored andcommitted
Log REMOTE_CACHE_VERSION
Summary: X-link: pytorch/pytorch#140174 title Differential Revision: D65667421
1 parent abaca22 commit b8cb285

File tree

1 file changed

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

1 file changed

+23
-0
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

+23
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@
149149
timer_counter = itertools.count()
150150

151151

152+
class FBCodeSpecific:
153+
@property
154+
def remote_cache_version(self) -> Optional[int]:
155+
""" Returns the remote cache version if it is available, otherwise None.
156+
Needs to be defensive because:
157+
(1) REMOTE_CACHE_VERSION is fbcode only
158+
(2) There is a circular dependency (through dynamic_typed) between
159+
dynamo and inductor. This is why the imports are not top-level
160+
"""
161+
try:
162+
from torch._environment import is_fbcode
163+
if not is_fbcode():
164+
return None
165+
from torch._inductor.fb.remote_cache import REMOTE_CACHE_VERSION
166+
return REMOTE_CACHE_VERSION
167+
except Exception:
168+
return None
169+
170+
fbCodeSpecific: FBCodeSpecific = FBCodeSpecific()
171+
172+
152173
# Abstraction on top of counters.
153174
class ReInplaceTrigger(enum.Enum):
154175
AUTO_FUNC_V1 = 1
@@ -419,6 +440,7 @@ def dynamo_timed(
419440
fail_type=fail_type,
420441
fail_reason=fail_reason,
421442
remote_cache_time_saved_s=remote_cache_time_saved,
443+
remote_cache_version=fbCodeSpecific.remote_cache_version,
422444
structured_logging_overhead_s=structured_logging_overhead_s,
423445
is_forward=False, # is_forward
424446
num_triton_bundles=codecache_metrics.get(
@@ -898,6 +920,7 @@ class CompilationMetrics:
898920
# a compiled frame
899921
has_guarded_code: Optional[bool] = None
900922
remote_cache_time_saved_s: Optional[float] = None
923+
remote_cache_version: Optional[int] = None
901924
structured_logging_overhead_s: Optional[float] = None
902925
config_suppress_errors: Optional[bool] = None
903926
config_inline_inbuilt_nn_modules: Optional[bool] = None

0 commit comments

Comments
 (0)