XAD Fast, easy automatic differentiation in C++ and Python
XAD is a high-performance C++ automatic differentiation library designed for large-scale, performance-critical systems.
It provides forward and adjoint (reverse) mode automatic differentiation via operator overloading, with a strong focus on:
- Low runtime overhead.
- Minimal memory footprint.
- Straightforward integration into existing codebases.
For Monte Carlo and other repetitive workloads, XAD also offers optional JIT backend support, enabling record-once / replay-many execution for an additional performance boost.
Automatic Differentiation
Automatic differentiation (also called algorithmic differentiation) is a set of techniques for calculating partial derivatives of functions specified as computer programs. Since every program execution is always composed of a sequence of simple operations with known derivatives (arithmetics and mathematical functions like sin, exp, log, etc.), the chain rule can be applied repeatedly to calculate partial derivatives automatically. See automatic differentiation mathematical background for more details.
Key Features
Any Order, Mode, Precision
Calculate derivatives in forward and adjoint modes, for any order – both in single and double precision.Checkpointing
Manage tape memory and achieve higher performance via checkpointing.External Functions
Integrate functions from external libraries into the AD tape or manually optimise parts of the differentiated code.Vector Modes
Compute multiple derivatives at once.Eigen Support
Works with the popular linear algebra library Eigen.JIT Backend Support (Optional)
Infrastructure for pluggable JIT backends, enabling record-once/replay-many workflows — with or without automatic differentiation.Performance
XAD is the fastest open-source C++ AD library on four quant-finance workloads, benchmarked against CppAD, Adept 2, and autodiff. The optional JIT backend (xad-codegen) delivers a further 2x–5x speedup.
GCC 13.3, Intel Xeon Platinum 8488C, Ubuntu 24.04, -O3 -mavx2 -mfma, 10K MC paths.