ADTypes.jl

Repository for automatic differentiation backend types
Author SciML
Popularity
38 Stars
Updated Last
24 Days Ago
Started In
February 2023

ADTypes.jl: Multi-Valued Logic for Automatic Differentiation Choices

Docs stable Docs dev Build Status Coverage

ADTypes.jl is a multi-valued logic system to choose an automatic differentiation (AD) package and specify its parameters.

Which AD libraries are supported?

See the API reference in the documentation. If a given package is missing, feel free to open an issue or pull request.

Why should AD users adopt this standard?

A natural approach is to use a keyword argument with e.g. Bool or Symbol values. Let's see a few examples to understand why this is not enough:

  • autodiff = true: ambiguous, we don't know which AD package should be used
  • autodiff = :forward: ambiguous, there are several AD packages implementing both forward and reverse mode (and there are other modes beyond that)
  • autodiff = :Enzyme: ambiguous, some AD packages can work both in forward and reverse mode
  • autodiff = (:Enzyme, :forward): not too bad, but many AD packages require additional configuration (number of chunks, tape compilation, etc.)

A more involved struct is thus required, with package-specific parameters. If every AD user develops their own version of said struct, it will ruin interoperability. This is why ADTypes.jl provides a single set of shared types for this task, as an extremely lightweight dependency. They are types and not enums because we need AD choice information statically to use it for dispatch.