Lightning-AI / Lightning-AI/lightning-thunder
backwards for autograd.Function
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
We currently "fudge" autograd.Function by running through the forward as if it was the function and rely on the differentiation of that to work.
(This is not good when there is `.detach()` or some such in the forward.)
Given that
- we do know the call args (in the sense of "meta") of the backward once we have traced through the forward,
- we do not yet know the return signature (because we might have `None` or a Tensor of the same shape as the matching input for the tensor inputs).
I wonder if we could, after tracing the forward
- make a non-prim symbol with the forward trace as subsymbols,
- inspect the `ctx`,
- trace through the backward at that time, put that in a non-primitive symbol as well and make a gradient rule mapping the two.
This will be a considerable amount of magic, unfortunately, but it might just work.
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 tracing the current autograd.Function handling and how the forward trace is used for differentiation. Examine how ctx, backward tracing, None returns, and same-shape tensor returns would fit the proposed non-primitive symbols and gradient rule. Done means autograd.Function no longer relies on differentiating the forward when cases such as detach are present.
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