diff --git a/torch/_dynamo/convert_frame.py b/torch/_dynamo/convert_frame.py index 38795341be216..c1733280e31f3 100644 --- a/torch/_dynamo/convert_frame.py +++ b/torch/_dynamo/convert_frame.py @@ -773,6 +773,22 @@ def format_guard_failures(): "".join(CapturedTraceback.extract(skip=2 + skip).format()), ) # -4: -2 as above, plus trace_structured frames + # + # NB: the frame looks like this: + # + # # handled by skip argument + # torch/_dynamo/convert_frame.py:1069 in catch_errors + # torch/_dynamo/convert_frame.py:910 in _convert_frame + # torch/_dynamo/convert_frame.py:464 in _convert_frame_assert + # torch/_utils_internal.py:70 in wrapper_function + # + # # 2 current frame and context lib + # env/lib/python3.10/contextlib.py:79 in inner + # torch/_dynamo/convert_frame.py:776 in _compile + # + # # 2 extra here + # torch/_logging/_internal.py:1064 in trace_structured + # torch/_dynamo/convert_frame.py:780 in torch._logging.trace_structured( "dynamo_start", lambda: { diff --git a/torch/_utils_internal.py b/torch/_utils_internal.py index 3da8bc2186f54..a61adb6a826b6 100644 --- a/torch/_utils_internal.py +++ b/torch/_utils_internal.py @@ -63,10 +63,14 @@ def throw_abstract_impl_not_imported_error(opname, module, context): # Meta only, act as nop otherwise. +# +# NB! This treats "skip" kwarg specially!! def compile_time_strobelight_meta(phase_name): def compile_time_strobelight_meta_inner(function): @functools.wraps(function) def wrapper_function(*args, **kwargs): + if "skip" in kwargs: + kwargs["skip"] = kwargs["skip"] + 1 return function(*args, **kwargs) return wrapper_function