|
149 | 149 | timer_counter = itertools.count()
|
150 | 150 |
|
151 | 151 |
|
| 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 | + |
152 | 173 | # Abstraction on top of counters.
|
153 | 174 | class ReInplaceTrigger(enum.Enum):
|
154 | 175 | AUTO_FUNC_V1 = 1
|
@@ -419,6 +440,7 @@ def dynamo_timed(
|
419 | 440 | fail_type=fail_type,
|
420 | 441 | fail_reason=fail_reason,
|
421 | 442 | remote_cache_time_saved_s=remote_cache_time_saved,
|
| 443 | + remote_cache_version=fbCodeSpecific.remote_cache_version, |
422 | 444 | structured_logging_overhead_s=structured_logging_overhead_s,
|
423 | 445 | is_forward=False, # is_forward
|
424 | 446 | num_triton_bundles=codecache_metrics.get(
|
@@ -898,6 +920,7 @@ class CompilationMetrics:
|
898 | 920 | # a compiled frame
|
899 | 921 | has_guarded_code: Optional[bool] = None
|
900 | 922 | remote_cache_time_saved_s: Optional[float] = None
|
| 923 | + remote_cache_version: Optional[int] = None |
901 | 924 | structured_logging_overhead_s: Optional[float] = None
|
902 | 925 | config_suppress_errors: Optional[bool] = None
|
903 | 926 | config_inline_inbuilt_nn_modules: Optional[bool] = None
|
|
0 commit comments