ADTypes.jl: Multi-Valued Logic for Automatic Differentiation Choices
ADTypes.jl is a common system for implementing multi-valued logic for choosing which automatic differentiation library to use.
Why Should Packages Adopt This?
The current standard is to have a keyword argument with
autodiff = true or
autodiff = false.
However, boolean logic is not sufficient to be able to do all of the choices that are
required. For example for forward-mode AD there is ForwardDiff vs Enzyme, and thus
is ambgiuous. As libraries begin to support more and more of these autodiff mechanisms
for their trade-offs, every library will have their own version of
etc. which would be a mess. Hence ADTypes.jl giving a single set of shared types for this.
ADTypes.AutoForwardDiff() is the way to do it.
Why are they types instead of enums? Or EnumX?
If they were enums then they would not be dispatch type-level information. This is needed
for the internals of many of the packages to be type-stable because the choice of
type is different per package, i.e. what needs to be cached in order to use everything in
a non-allocating manner.
My AD Package is Missing?
Sure, give a PR to add it.