From e5b6ef6f83c0135d8ee587e0f7b8172566f84752 Mon Sep 17 00:00:00 2001 From: Daohang Shi Date: Mon, 29 Apr 2024 14:51:55 -0700 Subject: [PATCH] upload pt2 cprofile stats to manifold Summary: https://fb.workplace.com/groups/257735836456307/permalink/657458576484029/ upload cprofile to manifold D56696397 has a script to convert profiler stats to dot graphs (see its test plan) Differential Revision: D56679561 --- userbenchmark/dynamo/dynamobench/_dynamo/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/userbenchmark/dynamo/dynamobench/_dynamo/utils.py b/userbenchmark/dynamo/dynamobench/_dynamo/utils.py index f4f9bc93bb..e27f20d69e 100644 --- a/userbenchmark/dynamo/dynamobench/_dynamo/utils.py +++ b/userbenchmark/dynamo/dynamobench/_dynamo/utils.py @@ -50,6 +50,8 @@ ValuesView, ) +from torch._utils_internal import maybe_upload_prof_stats_to_manifold + from ..utils.hooks import RemovableHandle try: @@ -144,7 +146,7 @@ def cprofile_wrapper(func): def profile_wrapper(*args, **kwargs): global timer_counter profile_cnt = next(timer_counter) - profile_path = Path(func.__name__ + f"{profile_cnt}.profile") + profile_path = Path("/tmp/" + func.__name__ + f"{profile_cnt}.profile") prof = cProfile.Profile() prof.enable() start_ts = time.time() @@ -182,6 +184,9 @@ def profile_wrapper(*args, **kwargs): ) ps.sort_stats(pstats.SortKey.TIME).print_stats(20) ps.sort_stats(pstats.SortKey.CUMULATIVE).print_stats(20) + + maybe_upload_prof_stats_to_manifold(str(profile_path)) # fb-only + return retval return profile_wrapper