Repository: pytorch
Issue: [dynamo, logging] Log full stack trace in graph_breaks logging artifact
Labels: module: logging,triaged,oncall: pt2,module: dynamo

This came up during debugging - if I only turn on the `graph_breaks` logging artifact to debug a graph break, I don't get full stack traces.

Repro:
```python
import torch

def f(x):
    x = x + 1
    x = g(x)
    x = x + 1
    return x

@torch._dynamo.disable(recursive=False)
def g(x):
    x = x + 1
    x = h(x)
    x = x + 1
    return x

def h(x):
    x = x + 1
    torch._dynamo.graph_break()
    x = x + 1
    return x

opt_f = torch.compile(f, backend="eager")
opt_f(torch.randn(3, 3))
```

Log:
```
$ TORCH_LOGS="graph_breaks" python playground4.py
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks] Graph break: from user code at:
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/playground4.py", line 5, in f
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     x = g(x)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks] Traceback (most recent call last):
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 494, in wrapper
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     return inner_fn(self, inst)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]            ^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 1854, in CALL
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     self.call_function(fn, args, kwargs)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 738, in call_function
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     self.push(fn.call_function(self, args, kwargs))
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/variables/functions.py", line 293, in call_function
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     return super().call_function(tx, args, kwargs)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/variables/functions.py", line 90, in call_function
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 744, in inline_user_function_return
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 2456, in inline_call
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     return cls.inline_call_(parent, func, args, kwargs)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 2500, in inline_call_
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     result = InliningInstructionTranslator.check_inlineable(func)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 2484, in check_inlineable
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     unimplemented(
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/exc.py", line 216, in unimplemented
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks]     raise Unsupported(msg)
V0520 14:53:14.120000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [0/0] [__graph_breaks] torch._dynamo.exc.Unsupported: call torch._dynamo.disable() wrapped function <function g at 0x7f38811485e0>
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks] Graph break: from user code at:
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/playground4.py", line 18, in h
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]     torch._dynamo.graph_break()
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks] Traceback (most recent call last):
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 494, in wrapper
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]     return inner_fn(self, inst)
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]            ^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 1854, in CALL
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]     self.call_function(fn, args, kwargs)
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/symbolic_convert.py", line 738, in call_function
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]     self.push(fn.call_function(self, args, kwargs))
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/variables/functions.py", line 641, in call_function
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]     unimplemented(msg)
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]   File "/data/users/williamwen/pytorch3/torch/_dynamo/exc.py", line 216, in unimplemented
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks]     raise Unsupported(msg)
V0520 14:53:14.136000 139884917106496 torch/_dynamo/symbolic_convert.py:530] [1/0] [__graph_breaks] torch._dynamo.exc.Unsupported: 'skip function graph_break in file /data/users/williamwen/pytorch3/torch/_dynamo/decorators.py'
```
In particular, we can't tell that we called `h` through `g`.

If we turn all dynamo logs on (i.e. `+dynamo`) , we get a full stack trace within the logs (logged from convert_frame.py):
```
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:1055] skipping: graph_break (reason: in skipfiles, file: /data/users/williamwen/pytorch3/torch/_dynamo/decorators.py)
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0] torchdynamo start compiling torch_dynamo_resume_in_h_at_18 /data/users/williamwen/pytorch3/playground4.py:18, stack (elided 6 frames):
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]   File "/data/users/williamwen/pytorch3/playground4.py", line 23, in <module>
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]     opt_f(torch.randn(3, 3))
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]   File "/data/users/williamwen/pytorch3/torch/_dynamo/eval_frame.py", line 414, in _fn
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]     return fn(*args, **kwargs)
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]   File "/data/users/williamwen/pytorch3/playground4.py", line 3, in f
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]     def f(x):
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]   File "/data/users/williamwen/pytorch3/playground4.py", line 12, in g
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]     x = h(x)
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]   File "/data/users/williamwen/pytorch3/playground4.py", line 16, in h
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0]     def h(x):
V0520 14:56:18.810000 140633923422016 torch/_dynamo/convert_frame.py:766] [2/0] 
```

cc @ezyang @msaroufim @bdhirsh @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng