Code Generation AAD

Code Generation AAD Solution - AADC

Automatic Adjoint Differentiation is a functionality much desired by practitioners in finance and beyond. Code Generation AAD is the only approach that delivers quick integration, fast computation of sensitivities, and acceleration of the original model.

Code Generation AAD approach uses Code Transformation and Operator Overloading to efficiently compute the gradients of mathematical models by generating optimized machine code at runtime. This results in faster computing of the model and its first and higher order derivatives. The approach is particularly useful for models with many parameters that require frequent gradient updates during training.

Please read our detailed overview of the AAD approaches available here.

MatLogica's Code Generation AAD - AADC

AADC Library

MatLogica has developed a specialised run-time compiler, AADC (AAD Compiler) that generates efficient binary kernels for execution of the original and adjoint functions on the fly. Due to native CPU vectorisation and safe multithreading, AADC can speed up the AAD method itself, and deliver pricing and scenario analysis simply and effectively, in a way that is unattainable with competing products.

MatLogica's approach enables efficient AAD calculations in the legacy code, without major refactoring, introduction of templates, or constraining the control flow.

Code Generation AAD approach explained

A Code Generation approach to algorithmic differentiation delivers ease of use by using Operator Overloading and fast performance due to on-the-fly generation of the original and the adjoint versions of the program.

In essence, a Code Generation approach involves generating the code of the original model and its adjoint at the first execution of the function. This new code is subsequently used in all following loops, delivering speed-ups.

For any new task, or task configuration change (such as if pricing a new trade, a change in trading date, or amending the portfolio), the Code Generation tool will need to recompile the original and the adjoint model.

Therefore, the compilation time with a Code Genereation AAD tool becomes part of the execution flow. Using a standard off-the-shelf compiler, such as LLVM or C++, simply cannot deliver the performance in practice.

To address this, we have designed a specialsed Just-in-time compiler for Code Generation and AAD.

Code Generation AAD approach - theory

Theory: Code Generation AAD approach

Benefits of MatLogica AADC Code Generation

For a practical Code Generation approach, not limited to synthetic benchmark, a specialised Just-In-Time Compiler is needed.
MatLogica AADC does not introduce limits on functionality such as branching, instead enabling smooth integration without the loss of numerical precision or trade-offs in functionality or usability.
AADC Just-In-Time Compilation

Practice - AADC Just-In-Time Compilation

Second-order greeks

Second-order greeks can be computed using bump-and-revalue of the first-order AAD greeks, fast.

Adjoint factor less than 1

Using AADC, the original function and all its derivatives can be calculated faster than the original function.

Faster simulations

Any types of simulations (what if, stress test, backtesting, VaR) can be supercharged seamlessly

Debugging & checkpointing

Our debugging and checkpointing toolkit makes integration and troubleshooting simpler.

Code Simplifaction

MatLogica AADC acts as an abstraction layer between your business logic and your hardware.