Skip to content

Commit

Permalink
cleanup chromium event log on dynamo exit rather than on entry (#143175)
Browse files Browse the repository at this point in the history
Summary:
clearing at dynamo start is an issue because it throws away events from compiled autograd

X-link: pytorch/pytorch#143175
Approved by: https://github.com/Skylion007, https://github.com/jamesjwu
ghstack dependencies: #141907

Reviewed By: huydhn

Differential Revision: D67551020

Pulled By: xmfan

fbshipit-source-id: b92b48e39adc81433934b07ca13e330479233836
  • Loading branch information
xmfan authored and facebook-github-bot committed Dec 21, 2024
1 parent 10b95f4 commit 2bd7552
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ def log_event_start(
:param str event_name Name of event to appear in trace
:param time_ns Timestamp in nanoseconds
:param metadata: Any extra metadata associated with this event
:param log_pt_compile_event: If True, log to pt2_compile_events
:param log_pt2_compile_event: If True, log to pt2_compile_events
:param compile_id: Explicit compile_id (rather than using the current context)
"""
compile_id = compile_id or torch._guards.CompileContext.current_compile_id()
Expand Down Expand Up @@ -1440,7 +1440,7 @@ def get_chromium_event_logger() -> ChromiumEventLogger:
@contextmanager
def chromium_event_timed(
event_name: str,
reset_event_log: bool = False,
reset_event_log_on_exit: bool = False,
log_pt2_compile_event: bool = False,
) -> Generator[Any, None, None]:
"""
Expand All @@ -1449,8 +1449,6 @@ def chromium_event_timed(
instead. Use this context manager only if you want to avoid dynamo_timed.
"""
chromium_event_log = get_chromium_event_logger()
if reset_event_log:
chromium_event_log.reset()
chromium_start_time = time.time_ns()
chromium_event_log.log_event_start(
event_name,
Expand All @@ -1468,6 +1466,8 @@ def chromium_event_timed(
chromium_start_time,
log_pt2_compile_event,
)
if reset_event_log_on_exit:
chromium_event_log.reset()


@dataclasses.dataclass
Expand Down

0 comments on commit 2bd7552

Please sign in to comment.