Lightning-AI / Lightning-AI/lightning-thunder

Make trace `names` field directly linked to the names present in the trace

Open
#1,274 1 comment 0 reactions 1 assignee View on GitHub

@riccardofelluga is already working on this.

Since Oct 8, 2024.

Dominant language
Python
Stars
1.5k
Forks
121
PR merge metrics
No merged PRs in 30d

Description

## 🐛 Bug

As of now, if you run something like this:

```python
import thunder

import torch
import torch.nn as nn

class MyModel(nn.Module):
def __init__(self) -> None:
super().__init__()
self.layers = nn.Sequential(
nn.Linear(10, 10),
nn.ReLU(),
nn.Linear(10, 10)
)

def forward(self, x):
return self.layers(x)

a = torch.randn((10, 10), requires_grad=True, device="cuda")
m = MyModel().to("cuda")

jm = thunder.jit(m)
jm(a)

print(thunder.last_traces(jm)[-1].names)
print(thunder.last_traces(jm)[-1].bound_symbols)
```

the list of names does not correspond with the names present in the trace.

### Expected behavior

What should be is that the names are only the ones present in the trace and nothing more. This has effect on registering new symbols in the trace where names conflicts can happen even tho there are no bound symbols with the same name in the trace due to the check here:

https://github.com/Lightning-AI/lightning-thunder/blob/fceb64efc93a80a27d38b8e84f0e2b5f132f3d2f/thunder/core/trace.py#L170-L175

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.