Lightning-AI / Lightning-AI/lightning-thunder
value_and_grad returns None gradients with thunder.jit
@kshitij12345 is already working on this.
Since Apr 24, 2024.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
Note that it works with the deprecated `thunder.compile`.
```python
import torch
from thunder.core.transforms import value_and_grad
import thunder
def model(x, w1):
return x + w1
inp = torch.randn(1, 1) # doesn't matter if requires_grad is True/False
w1 = torch.randn(1, 1) # doesn't matter if requires_grad is True/False
print(thunder.compile(value_and_grad(model), disable_preprocessing=True)(inp, w1))
print(thunder.jit(value_and_grad(model))(inp, w1))
```
Output:
```
(tensor([[0.4349]]), (tensor([[1.]]), tensor([[1.]])))
(tensor([[0.4349]]), (None, None))
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.