mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[TORCH_TRACE] Record stack when no compile context is available (#122644)
This will help me track down those annoying unknown compile products. Signed-off-by: Edward Z. Yang <ezyang@meta.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/122644 Approved by: https://github.com/jamesjwu
This commit is contained in:
parent
f631586084
commit
852111e1c2
|
|
@ -72,6 +72,8 @@ class StructuredTraceTestingFormatter(logging.Formatter):
|
|||
metadata["dynamo_start"]["stack"] = "STACK"
|
||||
if "inductor_output_code" in metadata:
|
||||
metadata["inductor_output_code"]["filename"] = "FILENAME"
|
||||
if "stack" in metadata:
|
||||
metadata["stack"] = "STACK"
|
||||
if "compilation_metrics" in metadata:
|
||||
metadata["compilation_metrics"] = "METRICS"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ from importlib import __import__
|
|||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
|
||||
from weakref import WeakSet
|
||||
|
||||
import torch._logging.structured
|
||||
from torch.utils._traceback import CapturedTraceback
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# This is a synthetic logger which doesn't correspond to an actual logger,
|
||||
|
|
@ -1063,6 +1066,12 @@ def trace_structured(
|
|||
record["frame_id"] = trace_id.compile_id.frame_id
|
||||
record["frame_compile_id"] = trace_id.compile_id.frame_compile_id
|
||||
record["attempt"] = trace_id.attempt
|
||||
else:
|
||||
# Record the stack of the log call to better diagnose why we
|
||||
# don't have a frame id for it
|
||||
record["stack"] = torch._logging.structured.from_traceback(
|
||||
CapturedTraceback.extract(skip=1).summary()
|
||||
)
|
||||
payload = payload_fn()
|
||||
if payload is not None:
|
||||
if not isinstance(payload, str):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user