MCPcopy Create free account
hub / github.com/auto-differentiation/xad

github.com/auto-differentiation/xad @v2.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1.0 ↗ · + Follow
1,238 symbols 3,168 edges 114 files 45 documented · 4% updated 9d agov2.1.0 · 2026-03-31★ 4243 open issues

Browse by type

Functions 778 Types & classes 460
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

XAD

XAD: Fast, easy automatic differentiation in C++

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 C++ codebases

For Monte Carlo and other repetitive workloads, XAD also provides an abstract JIT backend interface, enabling record-once / replay-many execution for additional performance. A high-performance native code generation backend (xad-codegen) is available under a separate commercial license -- contact us for more information.

<a href="https://github.com/auto-differentiation/xad/releases/latest">
    <img src="https://img.shields.io/github/v/release/auto-differentiation/xad?label=Download&sort=semver" alt="Download" style="max-width: 100%;">
</a>
<a href="https://github.com/auto-differentiation/xad/blob/main/CONTRIBUTING.md">
    <img src="https://img.shields.io/badge/PRs%20-welcome-brightgreen.svg" alt="PRs Welcome" style="max-width: 100%;">
</a>
<a href="https://github.com/auto-differentiation/xad/actions/workflows/ci.yml">
    <img src="https://img.shields.io/github/actions/workflow/status/auto-differentiation/xad/ci.yml?label=Build&logo" alt="Build Status" style="max-width: 100%;">
</a>
<a href="https://coveralls.io/github/auto-differentiation/xad?branch=main">
    <img src="https://coveralls.io/repos/github/auto-differentiation/xad/badge.svg?branch=main" alt="Coverage" style="max-width: 100%;">
</a>
<a href="https://www.codacy.com/gh/auto-differentiation/xad/dashboard">
    <img src="https://img.shields.io/codacy/grade/1826d0a6c8ce4feb81ef3b482d65c7b4?logo=codacy&label=Quality%20%28Codacy%29" alt="Codacy Quality" style="max-width: 100%;">
</a>

Key Features

  • 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. A native code generation backend is available separately under commercial license.

Example

Calculate first-order derivatives of an arbitrary function with two inputs and one output using XAD in adjoint mode.

Adouble x0 = 1.3;              // initialise inputs
Adouble x1 = 5.2;
tape.registerInput(x0);        // register independent variables
tape.registerInput(x1);        // with the tape
tape.newRecording();           // start recording derivatives
Adouble y = func(x0, x1);      // run main function
tape.registerOutput(y);        // register the output variable
derivative(y) = 1.0;           // seed output adjoint to 1.0
tape.computeAdjoints();        // roll back adjoints to inputs
cout << "dy/dx0=" << derivative(x0) << "\n"
     << "dy/dx1=" << derivative(x1) << "\n";

Getting Started

Build XAD from source using CMake:

git clone https://github.com/auto-differentiation/xad.git
cd xad
mkdir build
cd build
cmake ..
make

For more detailed guides, refer to our Installation Guide and explore Tutorials.

Documentation

Full documentation, including API reference and usage examples, is available at: https://auto-differentiation.github.io/

Contributing

Contributions are welcome. Please see the Contributing Guide for details, and feel free to start a discussion in our GitHub Discussions.

Found a Bug?

Please report bugs and issues via the GitHub Issue Tracker.

Related Projects

Core symbols most depended-on inside this repo

Shape

Method 538
Class 455
Function 240
Enum 5

Languages

C++100%

Modules by API surface

src/XAD/JITOpCodeTraits.hpp155 symbols
src/XAD/Complex.hpp115 symbols
src/XAD/Literals.hpp70 symbols
src/XAD/UnaryMathFunctors.hpp58 symbols
src/XAD/BinaryMathFunctors.hpp46 symbols
test/TestHelpers.hpp44 symbols
src/XAD/ChunkContainer.hpp38 symbols
src/XAD/JITCompiler.hpp35 symbols
src/Tape.cpp34 symbols
src/XAD/Tape.hpp32 symbols
test/JITExpressionMath_test.cpp31 symbols
src/XAD/UnaryFunctors.hpp27 symbols

For agents

$ claude mcp add xad \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page