JuliaDiff/DifferentiationInterface.jl

An interface to various automatic differentiation backends in Julia.

What it solves

It eliminates the need to write backend-specific code when using automatic differentiation (AD) in Julia. Instead of learning and implementing different APIs for every AD library, developers can use a single, unified syntax to compute derivatives across various backends.

How it works

It acts as an abstraction layer (interface) that maps a common set of commands to the specific APIs of supported AD backends. It supports first- and second-order operators (like gradients, Jacobians, and Hessians), handles both in-place and out-of-place differentiation, and includes mechanisms for preparing caches or recording tapes to optimize performance. It also integrates sparsity handling and provides validation tools to ensure consistent outputs across different backends.

Who it’s for

Researchers and developers in the Julia ecosystem who need to perform automatic differentiation and want the flexibility to switch between different AD backends (e.g., Zygote, ForwardDiff, Enzyme) without rewriting their core logic.

Highlights

  • Unified Syntax: One API for multiple AD backends including Zygote, ForwardDiff, and Enzyme.
  • Comprehensive Operators: Supports gradients, Jacobians, and Hessians.
  • Performance Optimization: Includes a preparation mechanism for pre-allocating caches or recording tapes.
  • Sparsity Support: Built-in handling for sparse differentiation.
  • Validation Tools: Includes testing and benchmarking utilities via DifferentiationInterfaceTest.

Related

  • Project
  • Project
  • Project
  • Project
  • Project