Also remove compile_time_strobelight_meta frame when generating stack (#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: https://github.com/pytorch/pytorch/pull/126289
Approved by: https://github.com/yanboliang
This commit is contained in:
Edward Z. Yang 2024-05-15 13:24:24 -04:00 committed by PyTorch MergeBot
parent 9c9d0c2fab
commit b2d9b80fba
2 changed files with 20 additions and 0 deletions

View file

@ -773,6 +773,22 @@ def _compile(
"".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: {

View file

@ -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