Lightning-AI / Lightning-AI/lightning-thunder
Taking `requires_grad` propagation seriously in Thunder
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🚀 Feature
Add correct `requires_grad` attribute propagation in Thunder with OpInfo-based tests.
Currently, Thunder queries the `requires_grad` attribute only for compiled function inputs (nn.Module parameters, buffers, and args) and uses this attribute to cache compiled artifacts and mask the output of the compiled backward function.
We could also faithfully model the propagation of this attribute, as in PyTorch Eager, or consistently, according to the rules that we need to develop. However, the exact benefits are unclear and need to be collected to consider whether it's worth the effort.
If we decide to do the `requires_grad` propagation we would be able to faithfully mark some outputs of the compiled function with `requires_grad=False` by disconnecting them from the Autograd graph (https://github.com/Lightning-AI/lightning-thunder/issues/1733). The performance benefits of doing so remain to be evaluated.
cc @lantiga @mruberry
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
Start by reviewing the proposed OpInfo-based tests and comparing requires_grad propagation with PyTorch Eager. Collect the benefits and define consistent propagation rules before considering the output disconnection described in issue 1733. Done means the rules are agreed, implemented, and covered by OpInfo-based tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100