Skip to content

Commit

Permalink
Also remove compile_time_strobelight_meta frame when generating stack (
Browse files Browse the repository at this point in the history
…#126289)

I think I also need to fix this in fbcode, leaving that for future work.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: #126289
Approved by: https://github.com/yanboliang
  • Loading branch information
ezyang authored and ZelboK committed May 19, 2024
1 parent 3fe0c6d commit 421b23d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions torch/_dynamo/convert_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <lambda>
torch._logging.trace_structured(
"dynamo_start",
lambda: {
Expand Down
4 changes: 4 additions & 0 deletions torch/_utils_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 421b23d

Please sign in to comment.