From 46188bf450c3decc5cf031ad6c7a193d05e630da Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang (Meta Employee)" Date: Wed, 7 Feb 2024 08:39:52 -0800 Subject: [PATCH] Make start compiling stack trace omit framework frames (#119251) Summary: Fixes https://github.com/pytorch/pytorch/issues/119238 Here's what it looks like now: ``` $ TORCH_LOGS=+torch._dynamo.convert_frame python a.py [2024-02-05 18:52:07,248] [0/0] torch._dynamo.convert_frame: [DEBUG] torchdynamo start compiling f /data/users/ezyang/b/pytorch/a.py:3, stack (elided 5 frames): [2024-02-05 18:52:07,248] [0/0] torch._dynamo.convert_frame: [DEBUG] File "/data/users/ezyang/b/pytorch/a.py", line 7, in [2024-02-05 18:52:07,248] [0/0] torch._dynamo.convert_frame: [DEBUG] f(torch.randn(2)) [2024-02-05 18:52:07,248] [0/0] torch._dynamo.convert_frame: [DEBUG] File "/data/users/ezyang/b/pytorch/torch/_dynamo/eval_frame.py", line 453, in _fn [2024-02-05 18:52:07,248] [0/0] torch._dynamo.convert_frame: [DEBUG] return fn(*args, **kwargs) [2024-02-05 18:52:07,248] [0/0] torch._dynamo.convert_frame: [DEBUG] $ cat a.py import torch torch.compile def f(x): return x * 2 f(torch.randn(2)) ``` The eval_frame frame is intentionally present, since what happens is you run the torch.compile wrapper, and then you actually hit the user frame to be compiled. Signed-off-by: Edward Z. Yang X-link: https://github.com/pytorch/pytorch/pull/119251 Approved by: https://github.com/yanboliang, https://github.com/mlazos Reviewed By: atalman Differential Revision: D53498616 Pulled By: ezyang fbshipit-source-id: b859ce4cd32970a5c60094b90ece9946130a3c6f --- userbenchmark/dynamo/dynamobench/_dynamo/testing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/userbenchmark/dynamo/dynamobench/_dynamo/testing.py b/userbenchmark/dynamo/dynamobench/_dynamo/testing.py index 199cc08cf2..f58703bde3 100644 --- a/userbenchmark/dynamo/dynamobench/_dynamo/testing.py +++ b/userbenchmark/dynamo/dynamobench/_dynamo/testing.py @@ -155,7 +155,9 @@ def debug_dump(name, code: types.CodeType, extra="") -> None: ) -def debug_insert_nops(frame, cache_size, hooks, _) -> Optional[GuardedCode]: +def debug_insert_nops( + frame, cache_size, hooks, _, *, skip: int = 0 +) -> Optional[GuardedCode]: """used to debug jump updates""" def insert_nops(instructions, code_options):