MatLogica | MatLogica Technology: How AADC Works

MatLogica Technology: How AADC Works

How Our Products Work: JIT Compilation + AAD

Learn how MatLogica AADC transforms object-oriented code into data-oriented performance, achieving 6-100x speed-ups for quantitative analytics and computing sensitivities using ultra-fast automatic adjoint differentiation with runtime code generation

MatLogica AADC Technology Architecture

MatLogica AADC represents a fundamental innovation in automatic adjoint differentiation through runtime machine code generation rather than traditional tape-based approaches. The technology enables 6-100x performance improvements while requiring only weeks for integration compared to months or years for competitors. Core innovation: AADC is a JIT (Just-In-Time) compiler that converts user code (C++, C#, or Python, including mixed C++ and Python) into vectorized, multi-thread enabled, NUMA-aware machine code ('kernel') with the minimal number of operations theoretically necessary to complete the task. By generating kernels at runtime, AADC takes advantage of information available during program execution to build in additional optimizations. Key differentiator vs traditional AAD: Traditional AAD tools use tape to record and replay calculations. MatLogica AADC generates actual machine code executable on CPU at runtime, far exceeding performance of tape-based tools. The reverse accumulation equations are computed directly in the machine code rather than through tape replay, resulting in dramatically better performance. Performance sources: State-of-the-art code compression mechanism allows compression of optimized machine code, leading to better cache utilization. Fewer operations are loaded onto the CPU, extracting maximal speed-up that other libraries fail to achieve. Tests show AADC calculates both original function and derivatives faster than original code calculates the function alone, often by factor of 6-100x. Integration approach: Unorthodox method delivers results in weeks while competitors take months/years. Required code changes are minimal and can be performed by experienced quant or developer with little to no additional training. Three-step process: (1) Drop-in AADC library and migrate double to active double, (2) Identify and mark inputs/outputs for target function and start recording, (3) Record single sample to generate binary kernel, then call kernel for subsequent samples. Architecture note: Although called JIT-compiler, AADC doesn't have access to source code. It only accesses information about overloaded variables and operations performed on them. It is a graph-compiler operating on the computation graph, not a compiler of your C++/Python source. Debug tools assist troubleshooting. Educational licenses available along with various commercial license types.

Traditional Methods to Achieve Performance in Quantitative Finance

Developing accurate repetitive calculations such as Monte Carlo simulations for derivatives pricing using traditional Object-Oriented languages (C++, C#, Python) requires use of multithreading and/or vectorization. These are tricky to implement correctly and can lead to intermittent issues, race conditions, and hard-to-maintain code.

Automatic Adjoint Differentiation (AAD) produces accurate sensitivities (Greeks) for derivatives but is perceived as hard to implement and cannot be used to accelerate scenario analysis or pricing calculations.

Traditional AAD tools use tape to record and replay calculations, introducing overhead. MatLogica's AADC generates actual machine code (executable on CPU) at runtime, and far exceeds performance of tape-based AAD tools by 10x or more.

Traditional vs MatLogica AADC approach comparison diagram

How is MatLogica AADC Unique?

MatLogica's easy-to-integrate JIT (Just-In-Time) compiler converts user code (C#, C++, or Python, including a mix of C++ and Python) into vectorized (AVX2/AVX512) and multi-thread enabled, NUMA-aware machine code ('kernel') with the minimal number of operations theoretically necessary to complete the derivatives pricing or Monte Carlo task.

By generating the kernel at runtime rather than compile-time, we can take advantage of the information available during program execution (trade parameters, market data, portfolio composition) and build in additional optimizations that static compilers cannot achieve.

Our state-of-the-art code compression mechanism allows compression of the optimized machine code, leading to better CPU cache utilization—critical for performance in quantitative finance applications with large portfolios.

Accordingly, far fewer operations are loaded onto the CPU for each pricing or risk calculation, extracting the maximal speed-up that other AAD libraries fail to achieve due to tape overhead and lack of runtime optimization.

MatLogica's AADC library additionally computes the reverse accumulation equations (for automatic differentiation) directly in the machine code rather than using tape replay like other libraries, resulting in far better performance than alternative tape-based approaches.

Our tests show that AADC calculates both the original function (pricing) and derivatives (Greeks) faster than the original code calculates the function alone, often by a factor of 6-100x for Monte Carlo simulations and XVA calculations. This is achieved with minimal changes to the original code since Matlogica's compiler does virtually all the optimization work automatically.

Our Integration Approach: Weeks Not Years

MatLogica uses an unorthodox integration approach that delivers results in a few weeks while our competitors can take months or even years for full deployment. The required code changes are minimal and can be performed by an experienced quant or developer with little to no additional training in AAD theory or implementation.

As the first integration step, you simply need to drop-in the MatLogica AADC library into your quantitative project and migrate the 'double' type into our 'active double' (idouble) type throughout your pricing code.

Then, you will identify and mark the Inputs (market data, trade parameters) and Outputs (NPV, cashflows) for the target pricing function and instruct our library to start recording the computation graph. You only need to record a single sample (one trade, one path) to generate a binary kernel optimized for that calculation.

For subsequent samples (additional trades, Monte Carlo paths, portfolio valuations), you will simply call our generated kernel instead of the original function, achieving 6-100x performance improvements with automatic AAD capabilities.

MatLogica AADC 3-step integration process: drop-in library, record function, execute kernel
Three-step AADC integration process diagram

Although we call our product a JIT-compiler, it doesn't have access to your source code files. It can only access the information about overloaded variables (active doubles) and operations performed on them during execution. In fact, it is a graph-compiler that optimizes the computation graph, not a compiler of your C++ or Python source code.

Along with straightforward integration requiring minimal code changes, we offer comprehensive debug tools that assist troubleshooting numerical differences, branch handling, and performance optimization during the integration process.