Introduction
There are two distinct approaches to genuinely achieve "Live-Risk" (discussed in detail in the video) :
- "On-demand scaling": but spawning new instances takes huge amounts of time, and introduces latency in turbulent times; also, banks will compete for resources during market turbulence, leading to higher prices and/or shortage of resources;
- "Always-on": pre-loaded portfolio, analytics, and scenarios -> no time wasted for provisioning. But this is costly; effectively throwing money at the problem!
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 explains how risks can be computed faster and cheaper, enabling guilt-free Live Risk.
What is AADC?
Achieving this with an always-on “Lift & Shift" approach would be very expensive. It would also bring the additional risks of exposing proprietary models and trade data.
MatLogica AADC uses a different approach. During a single execution of the original analytics, AADC generates binary kernels representing the optimised and compressed raw elementary operations of the original program. Optionally, an extra kernel can also be generated, which computes the backward pass of automatic differentiation to calculate all risks. These kernels typically perform 20x-50x faster than the original analytics, and compute all risks in constant time - due to run-time optimisations and efficient use of native CPU vectorisation (AVX2/AVX512). The kernels are multi-thread safe by design, enabling extra scalability that is not available in the original analytics.
Remarkably , these kernels are almost Enigma-secure. AADC receives a sequence of elementary operations from the original analytics, with all the loops unrolled, and just hard-coded values that represent strike, expiry date, or valuation date. With no visibility of the original models, AADC generates optimised and compressed kernels, where all business-critical information is hidden between the ones and zeros. Accordingly, even the same portfolio of trades will have a different binary representation from one trading day to another.
Importantly for cloud execution, AADC kernels are generated for specific hardware, meaning that steps such as creating docker containers are not required and the kernel can be serialised immediately and sent for execution on the cloud at the start of a trading day.
Target Architecture for Cloud-based Live Risk
In the example below, we present a simplified diagram of a generalised solution architecture. In this instance, MatLogica AADC is part of the Quant Library (which is in reality made up of multiple components, APIs, and services) and is used to price all products. When a request to price a trade (or a portfolio) comes in, the Quant Library checks if the recording (kernel) for that configuration exists. If it does not exist, the library will instruct AADC to generate such a kernel and send it to the cloud. If it already exists, the library will call upon the kernel and aggregate the results as necessary. This might sound a bit like the “always-on” approach, but thanks to AADC, the computational resources required by the MatLogica kernels are far less than in a normal “lift-and-shift” “always-on” approach. Therefore, expensive cloud resources are not wasted.
As presented in the figure above, when pricing a new configuration of a trade, the kernel generation time is part of the overall execution time. To reduce this overhead, MatLogica has developed a specialised graph compiler that generates machine code directly during the program execution, without relying on an external compiler.
However, even with this innovation, the need for kernel generation needs to be thoroughly thought through for optimal performance, as it can take seconds and even minutes for more complex structures. We suggest the following two approaches to remove the problem:
- Large but static valuation - e.g. an extensive calculation that remains predominantly static during the trading day, such as portfolio pricing and risk. The composition of the trades, models, and trade parameters does not need to change much during the day. It should be sufficient to make such a recording at the beginning of the day and reuse it throughout the trading day. But there is in fact no limitation on the frequency of re-recordings, and they can also be triggered by events, including significant changes to portfolio composition. It is important to note that for larger functions the kernel generation time will be longer, and the need for regeneration should be evaluated accordingly.
- Smaller ad-hoc valuations, such as intraday activities: for any new trades, or for pre-trade analysis, additional kernels can be generated on the fly and sent to the cloud for execution. The position and risks can then be aggregated in the Quant Library as required.
Another design decision is around market data calibration. This can be done within the pricing/risk kernel, or segregated into a separate recording to ensure all trades are priced and risked on the same market data/models to guarantee consistency between otherwise independent calculations and deliver the capability to easily reproduce calculations.
The AADC Kernel Lifecycle
Again, this is a high-level diagram, and in practice an organisation will have numerous portfolios aligned to their organisational structure, asset classes, books, desks, etc. The “Quant Library” will need to ensure that any expired kernels are removed to avoid wasting resources.
Summary
MatLogica’s AADC solution enables:
- Fast results; semi-automated integration approach, in combination with the Automated IFT allows fully automatic differentiation of exact-fit calibration routines providing an approximate solution to nearly-exact calibration problems;
- Portfolio risk in ms, with cost reductions of ~100x;
- Re-use of the same approach for scenario analysis;
- Re-use of the existing grid task distribution layer;
- Water-tight security as the binary kernels only contain a sequence of elementary operations that are required to compute the prices and risk, while proprietary analytics and trade data remain on premises.
Please contact dmitri@matlogica.com if you require more information.