MatLogica | Blog Post

Blog Post

Cloud-Based Live Risk with Code Generation AAD

Achieve cost-efficient, secure cloud Live Risk using Code Generation AAD™ for fast sensitivity computation. Deploy encrypted binary kernels without exposing proprietary models or trade data.

The Cloud Live Risk Challenge

Costs, flexibility, and scalability drive banks to transition risk systems to the cloud. The ultimate goal is "Live Risk" - real-time portfolio risk that updates with every market tick. However, achieving this cost-effectively remains elusive with traditional "lift-and-shift" cloud migration approaches.

Two Standard Approaches and Their Limitations

There are two distinct approaches to cloud Live Risk (discussed in detail in the video):

1. On-Demand Scaling

  • Problem: Spawning new instances takes significant time
  • Problem: Introduces latency precisely when you need speed - during market turbulence
  • Problem: Banks compete for resources during volatility, leading to higher prices and/or resource shortages
  • Verdict: Fails when you need it most

2. Always-On

  • Benefit: Pre-loaded portfolio, analytics, and scenarios - no provisioning time
  • Problem: Extremely costly - running full infrastructure 24/7
  • Problem: Effectively throwing money at the problem
  • Verdict: Works but economically unsustainable

The Code Generation AAD Solution

A cost-efficient and future-proof alternative: Use modern Code Generation AAD to generate efficient binary kernels representing curve-building, portfolio pricing, and risk calculations. These kernels can be securely deployed on cloud at the start of the trading day for continuous tick-level risk throughout the day.

Key advantages:

  • 20-50x faster than original analytics
  • ~100x cost reduction vs always-on approach
  • Millisecond portfolio risk computation
  • Secure deployment - models and data stay on premises
  • No latency - kernels ready at market open

MatLogica's Automatic Adjoint Differentiation Compiler (AADC) delivers precisely this.

In this article, we present a target architecture for cloud-based Live Risk that uses MatLogica's AADC and explain how risks can be computed faster and cheaper, enabling guilt-free Live Risk.

What is AADC? Understanding Binary Kernels

Consider a large portfolio including various trades with models of varying complexity, plus curve-building functionality. The objective is tick-level pricing and risk for this complex model.

Achieving this with an always-on "lift & shift" approach would be prohibitively expensive and expose proprietary models and trade data to cloud environments.

How AADC Works

During a single execution of the original analytics, AADC generates binary kernels representing the optimized and compressed elementary operations of the original program. Optionally, an extra kernel computes the backward pass of automatic differentiation to calculate all risks.

Performance Characteristics:

  • 20-50x faster than original analytics
  • Constant time risk computation (all Greeks simultaneously)
  • AVX2/AVX512 vectorization - native CPU optimization
  • Multi-thread safe by design - extra scalability unavailable in original analytics
  • Hardware-specific - no Docker containers needed, immediate serialization

Security: Almost Enigma-Secure

Remarkably, these kernels are almost Enigma-secure. AADC receives a sequence of elementary operations from the original analytics with all loops unrolled and only hard-coded values representing strikes, expiry dates, or valuation dates.

With no visibility of the original models, AADC generates optimized and compressed kernels where all business-critical information is hidden between the ones and zeros. Even the same portfolio generates different binary representations from one trading day to another.

For cloud execution, AADC kernels are generated for specific hardware, meaning the kernel can be serialized immediately and sent for execution on the cloud at the start of a trading day. Proprietary models and trade data remain on premises.

Semi-Automated Integration and Automated IFT

MatLogica has developed a standardized, semi-automated approach to library instrumentation which generates first results much faster and in a more controlled fashion than traditional AAD packages.

Using MatLogica's breakthrough work on automating the Implicit Function Theorem (IFT) enables fully automated differentiation of exact-fit calibration routines and provides approximate solutions to nearly-exact calibration problems (read more on application of Automated IFT for Live Risk).

Target Architecture for Cloud-Based Live Risk

Several architectural options are available depending on trading business nature, existing infrastructure, and processes. You can implement AADC for all trades or retain valuation of certain instruments in original analytics while aggregating with AADC-computed measures.

Below is a simplified diagram of a generalized solution architecture. MatLogica AADC is part of the Quant Library (comprising multiple components, APIs, and services) and prices all products.

How It Works:

  1. When a pricing request comes in, the Quant Library checks if a kernel exists for that configuration
  2. If not, AADC generates the kernel and sends it to the cloud
  3. If yes, the library calls the kernel and aggregates results

This might sound like "always-on," but thanks to AADC, computational resources required are far less than normal "lift-and-shift" always-on approaches. Expensive cloud resources are not wasted.

Cloud Live Risk Architecture with AADC Kernels

Quant Library Extensions Required:

  • Identify objects that benefit from AADC
  • Manage kernel lifecycle
  • Distribute market data
  • Aggregate results
  • Handle kernel expiration

Kernel Generation Optimization

When pricing a new configuration, kernel generation time is part of overall execution. To reduce this overhead, MatLogica has developed a specialized graph compiler that generates machine code directly during program execution without relying on external compilers.

However, kernel generation can take seconds to minutes for complex structures. We suggest two approaches to optimize performance:

1. Large Static Valuations

Use case: Portfolio pricing and risk that remains predominantly static during the trading day.

Approach: Generate kernel at beginning of day, reuse throughout. Regenerate on events (significant portfolio changes).

Note: For larger functions, kernel generation takes longer - evaluate regeneration frequency accordingly.

2. Smaller Ad-Hoc Valuations

Use case: New trades, pre-trade analysis, intraday activities.

Approach: Generate kernels on-the-fly and send to cloud for execution. Aggregate with existing position and risks.

In practice, solution architects should segregate recordings according to business nature, portfolio structure, instruments, update frequency, business requirements, and existing technology stack to deliver optimal performance.

Market Data Calibration Design

Two options for market data calibration:

  • Within pricing/risk kernel: Integrated calibration
  • Separate recording: Ensures all trades priced on same market data/models, guaranteeing consistency between independent calculations and easy reproducibility

The AADC Kernel Lifecycle

Kernel creation is triggered by the Quant Library on events that change portfolio state:

  • Automatic: Based on business logic (book reconciliation, trading day start)
  • Manual: Trader pricing a new trade

Once generated, the kernel ships to cloud (grid), ready to receive market data updates, process them (including curve building, solvers/minimizers), and return risk/pricing information for aggregation and display to traders.

AADC Kernel Lifecycle Flowchart

This architecture also processes stress tests: kernels can be reused to process arbitrary inputs efficiently.

In practice, organizations have numerous portfolios aligned to organizational structure, asset classes, books, and desks. The "Quant Library" must ensure expired kernels are removed to avoid wasting resources.

Summary: Benefits of AADC Cloud Live Risk

This document presents a high-level solution architecture using MatLogica AADC for cloud execution without exposing any proprietary data or models.

MatLogica AADC Enables:

Performance

  • 20-50x faster than original analytics
  • Portfolio risk in milliseconds
  • ~100x cost reduction
  • Reuse for scenario analysis

Security & Integration

  • Water-tight security - binary kernels only
  • Proprietary analytics stay on premises
  • Semi-automated integration
  • Automated IFT for calibration
  • Reuse existing grid infrastructure

See the 'Live Risk' demo at MatLogica.com!

Ready to Implement Cloud Live Risk?

Contact us to discuss your cloud migration strategy and Live Risk requirements

dmitri@matlogica.com

Schedule Consultation

Related topics: cloud Live Risk architecture, AAD cloud deployment, binary kernel security, real-time portfolio risk cloud, code generation AAD vs tape-based, bank cloud migration risk, secure cloud Greeks calculation, millisecond portfolio risk, on-demand scaling vs always-on, cloud cost reduction AAD, Implicit Function Theorem AAD, tick-level risk cloud, encrypted binary kernels finance