Skip to content

Commit ee4aa8b

Browse files
masnesralfacebook-github-bot
authored andcommitted
Set compile_id in the CachingAutotuner during compilation so we have it for dynamo_timed logging (#148693)
Summary: This is a simpler alternative to pytorch/pytorch#146455, where we can stick the compileId (and forward/backward bool) in the CachingAutotuner so that we have it for logging `benchmark_all_configs`. Recall that the first attempt put the compileId in the inductor_meta and that interfered with caching. X-link: pytorch/pytorch#148693 Approved by: https://github.com/eellison Reviewed By: ZainRizvi Differential Revision: D71120413 fbshipit-source-id: 3911a70773a4c12fc71c2871f372118749d7f0dd
1 parent c271568 commit ee4aa8b

File tree

1 file changed

+6
-5
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+6
-5
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def dynamo_timed(
596596
dynamo_compile_column_us: Optional[str] = None,
597597
dynamo_compile_runtime_column_us: Optional[str] = None,
598598
compile_id: Optional[CompileId] = None,
599-
is_forward: Optional[bool] = None,
599+
is_backward: Optional[bool] = None,
600600
log_waitcounter: bool = False,
601601
) -> Generator[Any, None, None]:
602602
"""
@@ -638,7 +638,8 @@ def _foo(...):
638638
- compile_id: In the typical case, this parameter should not be needed. Use to
639639
supply the compile_id for those cases where we want to log a compile_id where
640640
it's not naturally available, e.g., for runtime autotuning.
641-
- is_forward: Optionally set an is_forward field for those logging destinations
641+
- is_backward: Specify forward/backward directly when not available in a
642+
CompileContext, e.g., during runtime autotuning.
642643
that support it.
643644
- log_waitcounter: If set, we'll log a waitcounter of the form "pytorch.dynamo_timed.{key}"
644645
"""
@@ -664,8 +665,8 @@ def _foo(...):
664665
event_metadata.update(metadata)
665666
if fn_name:
666667
event_metadata.update({"fn_name": fn_name})
667-
if is_forward is not None:
668-
event_metadata.update({"is_backward": not is_forward})
668+
if is_backward is not None:
669+
event_metadata.update({"is_backward": is_backward})
669670

670671
chromium_log: ChromiumEventLogger = get_chromium_event_logger()
671672
start_ns = time.time_ns()
@@ -707,7 +708,7 @@ def _foo(...):
707708
extra={
708709
"compile_id": compile_id,
709710
"is_runtime": True,
710-
"is_forward": is_forward,
711+
"is_forward": not is_backward,
711712
},
712713
)
713714
cumulative_time_spent_ns[event_name] += time_spent_ns

0 commit comments

Comments
 (0)