JuliaFirstOrder / ProximalAlgorithms.jl

Proximal algorithms for nonsmooth optimization in Julia
Other
130 stars 21 forks source link

Autodiff backends #71

Closed lostella closed 7 months ago

lostella commented 2 years ago

Right now the package falls back to Zygote for computing gradients using automatic differentiation. It would be nice to add support for multiple AD backends (ReverseDiff, Enzyme, Yota, Nabla, Diffractor… anything that works) so that one can chose what should be used.

This would require a mechanism for “optional dependencies”, so that a certain backend can be used only if the required dependency is installed.

Two ways I see for selecting what backend to use:

  1. Some global variable
  2. Wrapping functions in a specific type that enforces using this or that AD backend, eg, ZygoteFunction(f), ReverseDiffFunction(f), …
nantonel commented 2 years ago

isn't ChainRulesCore the AD core package?

lostella commented 2 years ago

The way I understand the current AD ecosystem (without looking much into the packages though):

If someone from the Julia AD community happens to read this, feel free to confirm or correct me :D

Am 26.02.2022 um 01:08 schrieb Niccolò Antonello @.***>:

 isn't ChainRulesCore the AD core package?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

mohamed82008 commented 2 years ago

Check https://github.com/JuliaDiff/AbstractDifferentiation.jl and the associated paper https://arxiv.org/abs/2109.12449.

lostella commented 2 years ago

@mohamed82008 thanks, it seemed to much of a general issue not to have a solution already :-) now I’m curious, I’ll look into that

mohamed82008 commented 2 years ago

Feel free to ping me if you have any questions :) I always wanted to add nonconvex optimisation support to ProximalAlgorithms but didn't get a chance to. If I understand correctly, nonconvex functions and constraints are now supported via AD?

lostella commented 2 years ago

@mohamed82008 ProximalAlgorithms supports nonconvex problems, in the sense that some of the implemented algorithms don’t need convexity assumptions on the objective terms in order to converge.

AD (Zygote right now) is used by default to compute gradients when they are needed. Constraints are handled via their projection mapping, and more generally non-differentiable terms are handled via proximal mappings (projections are a special case of this).

Here is a little bit of documentation on the primitives which are used, and that one can implement on custom types.

mohamed82008 commented 2 years ago

Fantastic! Exactly what I was hoping for. Thanks!