Lightning-AI / Lightning-AI/lightning-thunder
`disable_torch_autograd_support` should consider `no_grad` and `inference_mode`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🚀 Feature
Per title
### Motivation
I'm running a benchmark of my own with `@torch.inference_mode()` (I also tried `@torch.no_grad`)
`thunder.compile` is failing with `NotImplementedError: VJP for PrimIDs.RECIPROCAL is not implemented` even though the benchmark doesn't run `backward`
### Pitch
```python
model = thunder.jit(model, disable_torch_autograd=True)
# is equivalent to
with torch.inference_mode():
model = thunder.jit(model)
# and
with torch.no_grad():
model = thunder.jit(model)
```
With careful consideration if the user also passes a conflicting `disable_torch_autograd=...`
cc @carmocca @borda
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.
Research direction
No file or test is named; begin at the thunder.jit entry point and trace how disable_torch_autograd relates to torch.no_grad and torch.inference_mode. Done means those contexts provide equivalent behavior, while an explicitly conflicting disable_torch_autograd value is handled deliberately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers, machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100