Integrals.jl icon indicating copy to clipboard operation
Integrals.jl copied to clipboard

DifferentiationInterface instead of individual backends?

Open gdalle opened this issue 1 year ago • 4 comments

Following our conversation with @lxvm today, opening this issue to keep track of a potential DI integration here (pun intended). What would be the major hurdles?

gdalle avatar Nov 26 '24 21:11 gdalle

I don't think DI has a rules system that applies rules to all backends?

ChrisRackauckas avatar Nov 26 '24 22:11 ChrisRackauckas

No, for that we would still borrow individual rule systems. But inside of these rules we compute derivatives, and it can be with an arbitrary backend, not only the one we define the rule inside

gdalle avatar Nov 26 '24 22:11 gdalle

As @gdalle said, we would have to implement rules in each rules system, such as ChainRules.jl, but perhaps these could all call a single implementation of the pullback/pushforward. Then I would have to implement the pushback/pullforward using DI with a backend selected with the pre-existing sensealg keyword in the init function. As for hurdles, I think they include implementing the Leibniz integral rule for derivatives w.r.t. parameters and the limits of integration for all the integral function APIs. Few of the algorithms support a discretize then differentiate approach, and the rest only work with differentiate then discretize. Our broken derivative tests are a good place to track progress.

lxvm avatar Nov 26 '24 23:11 lxvm

I see, yes that part makes sense. Yes it doesn't need the SciMLSensitivity complexity because the differentiation here is pretty trivial, it just needs an easy way to pass what AD to use internally.

ChrisRackauckas avatar Dec 01 '24 20:12 ChrisRackauckas