Repository: pytorch
Issue: Stacktrace getting lost after lowering to Aten/Prim IR in the AOTAutograd pass
Labels: triaged,oncall: pt2

### 🐛 Describe the bug

I don't exactly know whether it is a bug or a decision choice, but still let me go ahead and get it clarified.
For the example program which I show below, the Torch IR is as follows:
```
opcode         name    target                                                     args             kwargs    meta
-------------  ------  ---------------------------------------------------------  ---------------  --------  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
placeholder    l_a_    L_a_                                                       ()               {}        {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'example_value': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_dict': {}, 'grapharg': GraphArg(source=LocalSource(local_name='a', cell_or_freevar=False), _example=<torch.utils.weak.TensorWeakRef object at 0x7f30e5d4d570>, pass_arg_as_tensor=False, fake_tensor=FakeTensor(..., device='cuda:0', size=(10,)), is_tensor=True, example_strong_ref=None)}
placeholder    l_b_    L_b_                                                       ()               {}        {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'example_value': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_dict': {}, 'grapharg': GraphArg(source=LocalSource(local_name='b', cell_or_freevar=False), _example=<torch.utils.weak.TensorWeakRef object at 0x7f30e5d4de40>, pass_arg_as_tensor=False, fake_tensor=FakeTensor(..., device='cuda:0', size=(10,)), is_tensor=True, example_strong_ref=None)}
call_function  randn   <built-in method randn of type object at 0x7f31c164ef20>   (10,)            {}        {'source_fn_stack': [('randn', <built-in method randn of type object at 0x7f31c164ef20>)], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'example_value': FakeTensor(..., size=(10,))}
call_function  sum_1   <built-in method sum of type object at 0x7f31c164ef20>     (randn,)         {}        {'source_fn_stack': [('sum_1', <built-in method sum of type object at 0x7f31c164ef20>)], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'example_value': FakeTensor(..., size=())}
call_method    sum_2   to                                                         (sum_1, 'cuda')  {}        {'source_fn_stack': [('to', 'to')], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'example_value': FakeTensor(..., device='cuda:0', size=())}
call_function  scaler  <built-in method tensor of type object at 0x7f31c164ef20>  (2.0,)           {}        {'source_fn_stack': [('tensor', <built-in method tensor of type object at 0x7f31c164ef20>)], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 15, in toy_example\n    scaler = torch.tensor(scaler)\n', 'example_value': FakeTensor(..., size=())}
call_function  mul     <built-in function mul>                                    (l_a_, l_b_)     {}        {'source_fn_stack': [('mul', <built-in function mul>)], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'example_value': FakeTensor(..., device='cuda:0', size=(10,))}
call_function  mul_1   <built-in function mul>                                    (mul, scaler)    {}        {'source_fn_stack': [('mul_1', <built-in function mul>)], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'example_value': FakeTensor(..., device='cuda:0', size=(10,))}
call_function  mul_2   <built-in function mul>                                    (mul_1, sum_2)   {}        {'source_fn_stack': [('mul_2', <built-in function mul>)], 'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'example_value': FakeTensor(..., device='cuda:0', size=(10,))}
output         output  output                                                     ((mul_2,),)      {}        {'creation_timestamp': 0}
```

After the above Torch IR is lowered to Aten/Prim IR in the AOTAutograd phase:

The forward method:
```
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs] TRACED GRAPH
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]  ===== AFTER POST GRAD =====
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]  /media/abhishek/Abhishek_NVMe/shweta_machine/trace_analysis/pytorch-venv-front-end/lib/python3.10/site-packages/torch/fx/_lazy_graph_module.py class <lambda>(torch.nn.Module):
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]     def forward(self, arg0_1: "f32[10]", arg1_1: "f32[10]"):
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # No stacktrace found for following nodes
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         inductor_seeds_default: "i64[1]" = torch.ops.prims.inductor_seeds.default(1, device(type='cpu'))
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # File: /home/abhishek/test-deliberate-cpu-device-0.py:15 in toy_example, code: scaler = torch.tensor(scaler)
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         _tensor_constant0: "f32[]" = self._tensor_constant0
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # File: /home/abhishek/test-deliberate-cpu-device-0.py:16 in toy_example, code: return a * b * scaler * sum
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         mul: "f32[10]" = torch.ops.aten.mul.Tensor(arg0_1, arg1_1);  arg0_1 = arg1_1 = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # File: /home/abhishek/test-deliberate-cpu-device-0.py:15 in toy_example, code: scaler = torch.tensor(scaler)
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         full_default: "f32[]" = torch.ops.aten.full.default([], 2.0, dtype = torch.float32, layout = torch.strided, device = device(type='cpu'), pin_memory = False)
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # File: /home/abhishek/test-deliberate-cpu-device-0.py:16 in toy_example, code: return a * b * scaler * sum
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         mul_1: "f32[10]" = torch.ops.aten.mul.Tensor(mul, full_default);  mul = full_default = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # No stacktrace found for following nodes
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         inductor_lookup_seed_default: "i64[]" = torch.ops.prims.inductor_lookup_seed.default(inductor_seeds_default, 0);  inductor_seeds_default = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         inductor_random_default: "f32[10]" = torch.ops.prims.inductor_random.default([10], inductor_lookup_seed_default, 'randn');  inductor_lookup_seed_default = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # File: /home/abhishek/test-deliberate-cpu-device-0.py:14 in toy_example, code: sum = torch.sum(torch.randn(10)).to('cuda')
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         sum_1: "f32[]" = torch.ops.aten.sum.default(inductor_random_default);  inductor_random_default = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         device_put: "f32[]" = torch.ops.prims.device_put.default(sum_1, device(type='cuda', index=0));  sum_1 = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         # File: /home/abhishek/test-deliberate-cpu-device-0.py:16 in toy_example, code: return a * b * scaler * sum
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         mul_2: "f32[10]" = torch.ops.aten.mul.Tensor(mul_1, device_put);  mul_1 = device_put = None
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         return (mul_2,)
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]         
V0629 08:52:45.859000 139851705655296 torch/_inductor/compile_fx.py:732] [0/0] [__post_grad_graphs]
```

For the lines:
1. `inductor_seeds_default: "i64[1]" = torch.ops.prims.inductor_seeds.default(1, device(type='cpu'))`
2. `inductor_lookup_seed_default: "i64[]" = torch.ops.prims.inductor_lookup_seed.default(inductor_seeds_default, 0);  inductor_seeds_default = None` and `inductor_random_default: "f32[10]" = torch.ops.prims.inductor_random.default([10], inductor_lookup_seed_default, 'randn');  inductor_lookup_seed_default = None`

Why aren't there any stacktraces?

The corresponding Aten/Prim IR in tabular form:
```
opcode         name                          target                              args                                           kwargs                                                                                                meta
-------------  ----------------------------  ----------------------------------  ---------------------------------------------  ----------------------------------------------------------------------------------------------------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
placeholder    arg0_1                        arg0_1                              ()                                             {}                                                                                                    {'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
placeholder    arg1_1                        arg1_1                              ()                                             {}                                                                                                    {'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 0}
call_function  inductor_seeds_default        prims.inductor_seeds.default        (1, device(type='cpu'))                        {}                                                                                                    {'val': FakeTensor(..., size=(1,), dtype=torch.int64), 'tensor_meta': TensorMetadata(shape=torch.Size([1]), dtype=torch.int64, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 0}
get_attr       _tensor_constant0             _tensor_constant0                   ()                                             {}                                                                                                    {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 15, in toy_example\n    scaler = torch.tensor(scaler)\n', 'source_fn_stack': [('tensor', <built-in method tensor of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.lift_fresh', overload='default')>, 'from_node': [('scaler', <built-in method tensor of type object at 0x7f31c164ef20>)], 'seq_nr': -1, 'val': FakeTensor(..., size=()), 'mutation_region_id': 1}
call_function  mul                           aten.mul.Tensor                     (arg0_1, arg1_1)                               {}                                                                                                    {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'source_fn_stack': [('mul', <built-in function mul>)], 'original_aten': <OpOverload(op='aten.mul', overload='Tensor')>, 'from_node': [('mul', <built-in function mul>)], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  full_default                  aten.full.default                   ([], 2.0)                                      {'dtype': torch.float32, 'layout': torch.strided, 'device': device(type='cpu'), 'pin_memory': False}  {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 15, in toy_example\n    scaler = torch.tensor(scaler)\n', 'source_fn_stack': [('tensor', <built-in method tensor of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.lift_fresh', overload='default')>, 'from_node': [('scaler', <built-in method tensor of type object at 0x7f31c164ef20>)], 'seq_nr': -1, 'val': FakeTensor(..., size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  mul_1                         aten.mul.Tensor                     (mul, full_default)                            {}                                                                                                    {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'source_fn_stack': [('mul_1', <built-in function mul>)], 'original_aten': <OpOverload(op='aten.mul', overload='Tensor')>, 'from_node': [('mul_1', <built-in function mul>)], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  inductor_lookup_seed_default  prims.inductor_lookup_seed.default  (inductor_seeds_default, 0)                    {}                                                                                                    {'val': FakeTensor(..., size=(), dtype=torch.int64), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.int64, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  inductor_random_default       prims.inductor_random.default       ([10], inductor_lookup_seed_default, 'randn')  {}                                                                                                    {'val': FakeTensor(..., size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  sum_1                         aten.sum.default                    (inductor_random_default,)                     {}                                                                                                    {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'source_fn_stack': [('sum_1', <built-in method sum of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.sum', overload='default')>, 'from_node': [('sum_1', <built-in method sum of type object at 0x7f31c164ef20>)], 'seq_nr': -1, 'val': FakeTensor(..., size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  device_put                    prims.device_put.default            (sum_1, device(type='cuda', index=0))          {}                                                                                                    {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'source_fn_stack': [('to', 'to')], 'original_aten': <OpOverload(op='aten._to_copy', overload='default')>, 'from_node': [('sum_2', 'to')], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
call_function  mul_2                         aten.mul.Tensor                     (mul_1, device_put)                            {}                                                                                                    {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'source_fn_stack': [('mul_2', <built-in function mul>)], 'original_aten': <OpOverload(op='aten.mul', overload='Tensor')>, 'from_node': [('mul_2', <built-in function mul>)], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={}), 'mutation_region_id': 1}
output         output                        output                              ((mul_2,),)                                    {}                                                                                                    {'val': (FakeTensor(..., device='cuda:0', size=(10,)),), 'mutation_region_id': 1}
```

The itermediate Aten/Prim IR, just before the final ATen/Prim IR as shown above happens to be the following:
From the fw_compiler_base:
```
opcode         name                  target                              args                                   kwargs                                               meta
-------------  --------------------  ----------------------------------  -------------------------------------  ---------------------------------------------------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
placeholder    arg0_1                arg0_1                              ()                                     {}                                                   {'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
placeholder    arg1_1                arg1_1                              ()                                     {}                                                   {'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  randn                 aten.randn.default                  ([10],)                                {'device': device(type='cpu'), 'pin_memory': False}  {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'source_fn_stack': [('randn', <built-in method randn of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.randn', overload='default')>, 'from_node': [('randn', <built-in method randn of type object at 0x7f31c164ef20>)], 'seq_nr': -1, 'val': FakeTensor(..., size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  sum_1                 aten.sum.default                    (randn,)                               {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'source_fn_stack': [('sum_1', <built-in method sum of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.sum', overload='default')>, 'from_node': [('sum_1', <built-in method sum of type object at 0x7f31c164ef20>)], 'seq_nr': -1, 'val': FakeTensor(..., size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  device_put            prims.device_put.default            (sum_1, device(type='cuda', index=0))  {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'source_fn_stack': [('to', 'to')], 'original_aten': <OpOverload(op='aten._to_copy', overload='default')>, 'from_node': [('sum_2', 'to')], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  convert_element_type  prims.convert_element_type.default  (device_put, torch.float32)            {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 14, in toy_example\n    sum = torch.sum(torch.randn(10)).to(\'cuda\')\n', 'source_fn_stack': [('to', 'to')], 'original_aten': <OpOverload(op='aten._to_copy', overload='default')>, 'from_node': [('sum_2', 'to')], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
get_attr       _tensor_constant0     _tensor_constant0                   ()                                     {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 15, in toy_example\n    scaler = torch.tensor(scaler)\n', 'source_fn_stack': [('tensor', <built-in method tensor of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.lift_fresh', overload='default')>, 'from_node': [('scaler', <built-in method tensor of type object at 0x7f31c164ef20>)], 'seq_nr': -1}
call_function  lift_fresh_copy       aten.lift_fresh_copy.default        (_tensor_constant0,)                   {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 15, in toy_example\n    scaler = torch.tensor(scaler)\n', 'source_fn_stack': [('tensor', <built-in method tensor of type object at 0x7f31c164ef20>)], 'original_aten': <OpOverload(op='aten.lift_fresh', overload='default')>, 'from_node': [('scaler', <built-in method tensor of type object at 0x7f31c164ef20>)], 'seq_nr': -1, 'val': FakeTensor(..., size=()), 'tensor_meta': TensorMetadata(shape=torch.Size([]), dtype=torch.float32, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  mul                   aten.mul.Tensor                     (arg0_1, arg1_1)                       {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'source_fn_stack': [('mul', <built-in function mul>)], 'original_aten': <OpOverload(op='aten.mul', overload='Tensor')>, 'from_node': [('mul', <built-in function mul>)], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  mul_1                 aten.mul.Tensor                     (mul, lift_fresh_copy)                 {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'source_fn_stack': [('mul_1', <built-in function mul>)], 'original_aten': <OpOverload(op='aten.mul', overload='Tensor')>, 'from_node': [('mul_1', <built-in function mul>)], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
call_function  mul_2                 aten.mul.Tensor                     (mul_1, convert_element_type)          {}                                                   {'stack_trace': '  File "/home/abhishek/test-deliberate-cpu-device-0.py", line 16, in toy_example\n    return a * b * scaler * sum\n', 'source_fn_stack': [('mul_2', <built-in function mul>)], 'original_aten': <OpOverload(op='aten.mul', overload='Tensor')>, 'from_node': [('mul_2', <built-in function mul>)], 'seq_nr': -1, 'val': FakeTensor(..., device='cuda:0', size=(10,)), 'tensor_meta': TensorMetadata(shape=torch.Size([10]), dtype=torch.float32, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})}
output         output                output                              ((mul_2,),)                            {}                                                   {}
```
In the above IR the stack trace information is still there corresponding to the `randn` node, but the moment that particular node is further converted to `prims.inductor_seeds`, `prims.inductor_loop_seed` and `prims.inductor_random` that is when the stack trace information goes away.

Is the above expected or deliberate?

### Error logs

_No response_

### Minified repro

I came up with a very simple minimalistic reproduction of the above issue which I am facing:
```python
import torch
import os

@torch.compile(mode="reduce-overhead")
def toy_example(a, b, scaler = 2.0):
    sum = torch.sum(torch.randn(10)).to('cuda')
    scaler = torch.tensor(scaler)
    return a * b * scaler * sum

tensor1 = torch.randn(10, device="cuda")
tensor2 = torch.randn(10, device="cuda")

for _ in range(3):
   x = toy_example(tensor1, tensor2)
   print(x)
```

### Versions

$ python3 collect_env.py 
Collecting environment information...
PyTorch version: 2.4.0.dev20240530+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.26.1
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-100-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.3.107
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2080
Nvidia driver version: 545.23.08
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.5
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             12
On-line CPU(s) list:                0-11
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
CPU family:                         6
Model:                              158
Thread(s) per core:                 2
Core(s) per socket:                 6
Socket(s):                          1
Stepping:                           10
CPU max MHz:                        4600.0000
CPU min MHz:                        800.0000
BogoMIPS:                           6399.96
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          192 KiB (6 instances)
L1i cache:                          192 KiB (6 instances)
L2 cache:                           1.5 MiB (6 instances)
L3 cache:                           12 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-11
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:             Mitigation; PTI
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Mitigation; Microcode
Vulnerability Tsx async abort:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] pytorch-triton==3.0.0+45fff310c8
[pip3] torch==2.4.0.dev20240530+cu121
[pip3] torchaudio==2.2.0.dev20240531+cu121
[pip3] torchvision==0.19.0.dev20240531+cu121
[conda] Could not collect


cc @ezyang @anijain2305 @chauhang @penguinwu