Skip to content

Commit

Permalink
Log REMOTE_CACHE_VERSION
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#140174

title

Differential Revision: D65667421
  • Loading branch information
fbgheith authored and facebook-github-bot committed Nov 11, 2024
1 parent abaca22 commit b8cb285
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,27 @@
timer_counter = itertools.count()


class FBCodeSpecific:
@property
def remote_cache_version(self) -> Optional[int]:
""" Returns the remote cache version if it is available, otherwise None.
Needs to be defensive because:
(1) REMOTE_CACHE_VERSION is fbcode only
(2) There is a circular dependency (through dynamic_typed) between
dynamo and inductor. This is why the imports are not top-level
"""
try:
from torch._environment import is_fbcode
if not is_fbcode():
return None
from torch._inductor.fb.remote_cache import REMOTE_CACHE_VERSION
return REMOTE_CACHE_VERSION
except Exception:
return None

fbCodeSpecific: FBCodeSpecific = FBCodeSpecific()


# Abstraction on top of counters.
class ReInplaceTrigger(enum.Enum):
AUTO_FUNC_V1 = 1
Expand Down Expand Up @@ -419,6 +440,7 @@ def dynamo_timed(
fail_type=fail_type,
fail_reason=fail_reason,
remote_cache_time_saved_s=remote_cache_time_saved,
remote_cache_version=fbCodeSpecific.remote_cache_version,
structured_logging_overhead_s=structured_logging_overhead_s,
is_forward=False, # is_forward
num_triton_bundles=codecache_metrics.get(
Expand Down Expand Up @@ -898,6 +920,7 @@ class CompilationMetrics:
# a compiled frame
has_guarded_code: Optional[bool] = None
remote_cache_time_saved_s: Optional[float] = None
remote_cache_version: Optional[int] = None
structured_logging_overhead_s: Optional[float] = None
config_suppress_errors: Optional[bool] = None
config_inline_inbuilt_nn_modules: Optional[bool] = None
Expand Down

0 comments on commit b8cb285

Please sign in to comment.