Skip to content

Commit 282e638

Browse files
jamesjwupytorchmergebot
authored andcommitted
Add inductor cache metrics (pytorch#138603)
Each inductor event should have exactly one hit, miss, bypass etc. Add it to the inductor compile event. Add triton_compile as a compiler phase with `dynamo_timed`. This way, we get PT2 Compile Event Logs for triton as well. Here's what triton events look like: {F1941513932} And this on a cache hit(since we still redo this work): {F1941514350} Inductor cache info: {F1941528530} Differential Revision: [D64703392](https://our.internmc.facebook.com/intern/diff/D64703392/) @diff-train-skip-merge Pull Request resolved: pytorch#138603 Approved by: https://github.com/oulgen
1 parent e78a3e2 commit 282e638

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

torch/_inductor/codecache.py

+12
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,18 @@ def load( # type: ignore[no-untyped-def]
15121512
cache_info["cache_event_time"],
15131513
metadata=cache_info,
15141514
)
1515+
# Add event data about cache hits/miss
1516+
# TODO: add remote cache get/put timings here too
1517+
chromium_log.add_event_data(
1518+
"inductor_compile",
1519+
cache_state=cache_state,
1520+
cache_event_time=cache_info["cache_event_time"],
1521+
key=cache_info.get("key"),
1522+
components=cache_info.get("components"),
1523+
cache_bypass_reason=cache_info.get("cache_bypass_reason"),
1524+
remote_cache_enabled=remote,
1525+
local_cache_enabled=local,
1526+
)
15151527
torch._logging.trace_structured(
15161528
"artifact",
15171529
metadata_fn=lambda: {

0 commit comments

Comments
 (0)