8000 [dynamo] Improve final traceback frame format · Issue #152867 · pytorch/pytorch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[dynamo] Improve final traceback frame format #152867
Closed
@williamwen42

Description

@williamwen42

For this sample program:

import torch


@torch.compile(backend="eager", fullgraph=True)
def fn(x):
    x = x + 1
    torch._dynamo.graph_break()
    return x + 1


fn(torch.ones(3))

The error message looks like

Traceback (most recent call last):
  File "/data/users/williamwen/pytorch/playground2.py", line 11, in <module>
    fn(torch.ones(3))
  File "/data/users/williamwen/pytorch/torch/_dynamo/eval_frame.py", line 671, in _fn
    raise e.with_traceback(None) from e.__cause__
torch._dynamo.exc.Unsupported: Call to `torch._dynamo.graph_break()`
  Explanation: User-inserted graph break. Message: None
  Hint: Remove the `torch._dynamo.graph_break()` call.

  Developer debug context: Called `torch._dynamo.graph_break()` with args `[]`, kwargs `{}`


from user code:
   File "/data/users/williamwen/pytorch/playground2.py", line 7, in fn
    torch._dynamo.graph_break()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"

The final traceback frame

  File "/data/users/williamwen/pytorch/torch/_dynamo/eval_frame.py", line 671, in _fn
    raise e.with_traceback(None) from e.__cause__

is not very elegant here (What is eval_frame.py? What is _fn?). We should make it more clear in the traceback that torch.compile attempted to trace this function.

Ideally, the final traceback frame should be something like:

  File "/data/users/williamwen/pytorch/torch/_dynamo/wrapper.py", line 671, in compile_wrapper
    return _compile(fn, args, kwargs)

cc @chauhang @penguinwu

Metadata

Metadata

Labels

dynamo-triage-jan2025module: compile uxUX issues related to torch.compileoncall: pt2triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0