gdalle / DifferentiationInterface.jl

An interface to various automatic differentiation backends in Julia.
https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface
MIT License
159 stars 12 forks source link

Support `f!(y, x)` for Zygote with `Zygote.Buffer` #348

Open gdalle opened 1 month ago

gdalle commented 1 month ago

See https://fluxml.ai/Zygote.jl/stable/utils/#Zygote.Buffer

Ping @Vaibhavdixit02

gdalle commented 1 month ago

PR #360 fails because

Buffer is not an AbstractArray and can't be used for linear algebra operations like matrix multiplication. This prevents it from being captured by pullbacks.

and some functions are typed f!(y::AbstractArray, x::AbstractArray). I think in general this fix would only cover a very limited subset of possible mutating operations, so I'm not sure it's worth it

Vaibhavdixit02 commented 3 weeks ago

Wait, I think the main thing it does, and what I had in mind asking for it was supporting in-place functions that's it. It has been quite robust in my experience and by documenting that the extent of mutation here is just in-place function calls why is this not worth it? Doesn't that mean that you'd be able to mark off the Two-argument column for Zygote here https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface/dev/backends/#Features?

gdalle commented 3 weeks ago

Gonna give it another try. Hopefully all it takes is to remove a few type annotations for my test suite to pass