Lightning-AI / Lightning-AI/lightning-thunder

value_and_grad returns None gradients with thunder.jit

Open
#211 3 comments 1 reaction 1 assignee View on GitHub

@kshitij12345 is already working on this.

Since Apr 24, 2024.

bug jit transforms
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

  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.