/XAD

A fast and comprehensive C++ library for automatic differentiation

Primary LanguageC++GNU Affero General Public License v3.0AGPL-3.0

XAD

XAD is a comprehensive library for automatic differentiation, available for both Python and C++. It targets production-quality code at any scale, striving for both ease of use and high performance.

Download License DOI PRs Welcome
GitHub Workflow Status Tests Badge Coverage GitHub CodeQL Status Tests Badge

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. XAD implements this using operator-overloading in C++ and exposes bindings for Python, allowing to compute derivatives with minimal changes to the program. See automatic differentiation mathematical background for more details.

Application areas:

  • Machine Learning and Deep Learning: Training neural networks or other machine learning models.
  • Optimisation: Solving optimisation problems in engineering and finance.
  • Numerical Analysis: Enhancing numerical solution methods for differential equations.
  • Scientific Computing: Simulating physical systems and processes.
  • Risk Management and Quantitative Finance: Assessing and hedging risk in financial models.
  • Computer Graphics: Optimising rendering algorithms.
  • Robotics: Improving control and simulation of robotic systems.
  • Meteorology: Enhancing weather prediction models.
  • Biotechnology: Modeling biological processes and systems.

Key features:

  • Forward and adjoint mode for any order, using operator-overloading
  • Checkpointing support (for tape memory management)
  • External functions interface (to integrate external libraries)
  • Thread-safe tape
  • Formal exception-safety guarantees
  • High performance
  • Battle-tested in large production code bases

Getting Started

XAD in C++ builds with modern CMake and has no external dependencies. For instructions how to build and integrate it into your projects, please refer to the Installation Guide.

The documentation site also contains tutorials, examples, and information about integrating XAD into QuantLib.

The sources for the reference section of the site are located in the docs directory in this repository.

Getting Help

If you have found an issue, want to report a bug, or have a feature request, please raise a GitHub issue.

For general questions about XAD, sharing ideas, engaging with community members, etc, please use GitHub Discussions.

Related Projects

  • XAD Comprehensive automatic differentiation in Python and C++
  • QuantLib-Risks: Fast risk evaluations in Python and C++

Planned Features

Please see the issues list for planned/open features. You are very welcome to contribute towards these (or other) features - please contact the project maintainers before to discuss you proposal. If you have new feature requests, please submit a new issue with a detailed description.

Contributing

Please read CONTRIBUTING for the process of contributing to this project. Please also obey our Code of Conduct in all communication.

Versioning

We use SemVer for versioning, making a new release available as soon as sufficient new features have been merged into main. The final decision about a release and which features are included is with the project maintainers. For the versions available, see the releases in GitHub.

Every new version is also added to the Changelog, which needs to be maintained throughout the development. That is, every pull request should also update the Changelog accordingly.

Authors

  • Various contributors from Xcelerit
  • See also the list of contributors who participated in the project.

License

This project is licensed under the GNU Affero General Public License - see the LICENSE.md file for details.