Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Nested AD #913

Closed
avik-pal opened this issue Mar 16, 2024 · 2 comments · Fixed by #924
Closed

Improve Nested AD #913

avik-pal opened this issue Mar 16, 2024 · 2 comments · Fixed by #924
Labels
good first issue Good for newcomers

Comments

@avik-pal
Copy link
Member

avik-pal commented Mar 16, 2024

The Nested AD used in DiffEqFlux is not ideal because it calls ForwardDiff.gradient/jacobian and Zygote overrides them to compute the Hessian before doing the HVP.

BatchedRoutines.jl has routines to do this efficiently, we should start migrating the code to use that.

Note that this cannot be upstreamed to Zygote, because it requires capturing a different gradient / jacobian call to compute $\frac{\partial}{\partial p}\left(\frac{\partial f}{\partial u}\right)^T v$. Capturing the ForwardDiff calls only allows us to override $\frac{\partial}{\partial u}\left(\frac{\partial f}{\partial u}\right)^T v$.

(I will probably do the migration myself over the summer if no one else picks it up.)

@avik-pal avik-pal added the good first issue Good for newcomers label Mar 16, 2024
@ChrisRackauckas
Copy link
Member

This seems like a good GSoC project.

@avik-pal
Copy link
Member Author

Update on this. LuxDL/Lux.jl#598 will handle everything automatically, so relying on another package is unnecessary. We just need to change the Zygote.gradient(f, x, ps) calls to Zygote.gradient(::StatefulLuxLayer, x)

@avik-pal avik-pal linked a pull request May 18, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants