Lightning-AI / lightning-thunder

Make PyTorch models up to 40% faster! Thunder is a source to source compiler for PyTorch. It enables using different hardware executors at once; across one or thousands of GPUs.
Apache License 2.0
1.2k stars 80 forks source link

backwards for autograd.Function #1017

Open t-vi opened 2 months ago

t-vi commented 2 months ago

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

I wonder if we could, after tracing the forward

This will be a considerable amount of magic, unfortunately, but it might just work.

IvanYashchuk commented 2 months ago

Duplicate of https://github.com/Lightning-AI/lightning-thunder/issues/666? Which of the two should we keep open?