Retrofitting AAD to Your Existing C++ Library: A Step by Step Guide with TapeScript and QuantLibAdjoint*

Alexander Sokol (CEO and Head of Quant Research, CompatibL)

Presentation: Global Derivatives Conference, Amsterdam, 2015

* While workshop participants will benefit from the knowledge of C++ and quant library design, it is the presenter's intention to make the material accessible and engaging to non-programmers who are interested in learning about AAD.

TapeScript and QuantLibAdjoint are OSI certified open source and will always remain free for commercial use. Download from github.com/compatibl and quantlib.org.

Complete source code to workshop examples will be made available to workshop participants.

Introduction to AAD

  • Forward and reverse mode
  • Tapeless scalar, tapeless vector, or tape AAD
  • Operator overloading, source transformation, or hand-coding
  • Overview of leading C++ libraries for AAD
  • Simple examples
  • Where and how to use AAD in quant finance

Replacement of double by AD double

  • The challenge of designing drop-in replacement for double in C++98 and C++11
  • Typical errors arising when trying to replace double by a class with overloaded arithmetic operators
  • Non-technical summary of C++ strategies for overcoming these challenges
  • TapeScript as inline wrapper to AD double designed for easier drop-in replacement of double
  • Implementing or finding AD versions of special functions
  • Dealing with complex AD numbers in C++
  • Testing strategy for the correctness of double replacement

Tape cutting and tape compression

  • The tape size problem in AAD and key ways of solving it
  • Lossless and lossy tape compression
  • AD double array as the second fundamental unit of computing to AD double

When operator overloading is not enough

  • The if operator and the need to represent delta function
  • Implementing AAD for Monte Carlo and American Monte Carlo
  • Implementing AAD for lattices

QuantLib + CppAD + TapeScript = QuantLibAdjoint

  • From observer pattern to immutable objects in QuantLib
  • Compiling QuantLib with and without adjoint capability
  • Porting special functions used in QuantLib
  • Porting complex number arithmetics in QuantLib

QuantLibAdjoint performance gain examples

  • Linear instrument sensitivities
  • Analytical option sensitivities
  • Curve builders
  • Vol surfaces
  • Pricing large portfolios
  • Monte Carlo risk
  • Real-time pricing