Exact derivatives of your existing C++ code, in forward, adjoint and higher-order mode,
with low runtime overhead and a small memory footprint. Python bindings: pip install xad.
For Monte Carlo and other repetitive workloads, XAD also provides a JIT backend interface for record-once / replay-many execution.
Documentation · Install · Samples · Benchmarks · Python · Discussions
Important
Using XAD in your organization? XAD is open source under the AGPL, to try it, for research and for open-source projects. The AGPL is not suitable for enterprise settings: for use in your organization you need a separate commercial license from Xcelerit, by annual XAD subscription. See XAD licensing for the terms, a quote within one business day, or a free, confidential license check.
Every derivative of a function in one adjoint sweep:
#include <XAD/XAD.hpp>
#include <iostream>
using mode = xad::adj<double>; // adjoint (reverse) mode
using AD = mode::active_type;
template <class T>
T f(T x, T y) { return x * sin(y) + exp(x * y); } // your code, unchanged
int main() {
mode::tape_type tape;
AD x = 1.3, y = 5.2;
tape.registerInput(x);
tape.registerInput(y);
tape.newRecording();
AD z = f(x, y);
tape.registerOutput(z);
derivative(z) = 1.0;
tape.computeAdjoints(); // every input derivative in one sweep
std::cout << "dz/dx = " << derivative(x) << ", dz/dy = " << derivative(y) << "\n";
}With vcpkg:
vcpkg install xadfind_package(XAD CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE XAD::xad)With CMake, straight from GitHub:
include(FetchContent)
FetchContent_Declare(XAD GIT_REPOSITORY https://github.com/auto-differentiation/xad.git GIT_TAG v2.2.0)
FetchContent_MakeAvailable(XAD)
target_link_libraries(my_app PRIVATE XAD::xad)Or build from source:
git clone https://github.com/auto-differentiation/xad.git
cmake -S xad -B xad/build
cmake --build xad/buildThe defaults suit any code; Build Options lists the options that make XAD faster for some kinds of code.
Python: pip install xad. More in the Installation Guide
and the Tutorials.
Compared against CppAD, Adept 2 and autodiff on four quant-finance workloads (LMM, Heston, CVA, SABR), with every gradient checked. XAD computes all sensitivities 6.5x to 83x faster than bump-and-reval and is the fastest of the open-source libraries on all four.
XAD v2.2.0, AMD EPYC (Zen 5), one core, GCC 15.2, run 10 November 2026; ad-benchmarks v1.0.0. Full methodology, source code and results: auto-differentiation/ad-benchmarks
GradBench is an independent suite of 11 general AD problems run in the same harness for every tool.
With code generation (xad-codegen, commercial), XAD is the fastest of the C and C++ AD tools on all 11 GradBench problems, and on average 2.4x faster than the next-fastest tool (geometric mean of the ratios to the fastest other AD tool, open-source XAD excluded). On seven of the nine problems with hand-written derivatives, the generated code beats them. Without code generation, open-source XAD is the fastest tape-based AD tool on 7 of the 11 and second on the other four. Measured by Xcelerit with GradBench's harness and tool images, 16 Nov 2026: GradBench results.
- Forward & Reverse (Adjoint) Mode: Supports any order using operator overloading.
- Vector mode: Compute multiple derivatives at once.
- Checkpointing Support: Efficient tape memory management for large-scale applications.
- External Function Interface: Seamlessly connect with external libraries.
- 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. See samples/jit_tutorial.
| Repository | Description |
|---|---|
| xad-py | Python bindings for XAD |
| QuantLibAAD | Full QuantLib integration — compute all Greeks at once, up to 3 orders of magnitude faster than bump-and-reval |
| QuantLibAAD-Py | QuantLibAAD from Python |
| xad-codegen | Native code generation backend — maximum throughput (commercial) |
| AAD Training | Hands-on AAD training for quants and quant developers - delivered to dozens of tier 1 banks and financial services firms |
Full documentation, including API reference and usage examples, is available at: https://www.xcelerit.com/xad/docs/
Contributions are welcome. Please see the Contributing Guide for details, and feel free to start a discussion in our GitHub Discussions.
If XAD is useful to you, a star on GitHub helps others find it.
New here? Pick a good first issue. Each one is small, self-contained and comes with a clear task.
Thanks to everyone who has contributed:
Please report bugs and issues via the GitHub Issue Tracker.
XAD is open source under the AGPL-3.0, to try it, for research and for open-source projects. For use in your organization you need a separate commercial license from Xcelerit: see XAD licensing.