Skip to content

Introduce DifferentiationInterface.jl for Jacobian computation #2134

@SouthEndMusic

Description

@SouthEndMusic

Quite a while back we put a lot of effort in getting ForwardDiff.jl to work as an automatic differentiation (AD) method for computing Jacobians for implicit solvers (see e.g. #550). Then after a while we decided to make finite difference the standard differentiation method again (see #1832).

This is a pity, because AD should in general be more accurate and AD is very well supported in the SciML ecosystem. The newest efforts there are for supporting DifferentiationInterface.jl, which should make it as easy to switch between different AD backends as it is now already to switch between different solver algorithms.

One of the things that makes AD support complex is (pre)allocating the right caches for intermediate results. DifferentiationInterface.jl attempts to automate this but that is not always possible when computations are in-place (as ours are). We currently use PreallocationTools for this, which is somewhat intrusive in our codebase, quite magical to the uninitiated and is quite fiddly to get to work well together with continuous control types, i.e. ContinuousControl and PidControl. Therefore it would be nice of we could use an AD backend that does not require this 'manual' caching, for which Enzyme.jl is a promising candidate that is gaining popularity in the SciML community.

One potential hurdle with Enzyme.jl is that it might make our current executable significantly bigger, but that is all the more reason to work towards static compilation 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreIssues related to the computational core in Julia

    Type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions