Closed
Description
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)