Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
c84d01c
forge integration
da-roth Dec 12, 2025
a3605f9
Revert "forge integration"
da-roth Dec 15, 2025
98c276b
forge integration
da-roth Dec 15, 2025
6c331dc
up
da-roth Dec 15, 2025
15e8808
use setBackend
da-roth Dec 19, 2025
b08fd88
updates due to xad-jit
da-roth Dec 19, 2025
33e3d69
updated backend naming
da-roth Dec 19, 2025
8494c87
graph updates with jitnode
da-roth Dec 19, 2025
36eacb8
first refactor
da-roth Dec 22, 2025
311d387
revert changes on fork
da-roth Dec 22, 2025
2591bb5
update path
da-roth Dec 22, 2025
41dc182
update ci
da-roth Dec 22, 2025
a4021b2
remove compatibility layer
da-roth Dec 22, 2025
66b8ea2
updates
da-roth Dec 22, 2025
7771b93
update backend namespaces
da-roth Dec 25, 2025
b68d6f6
update c api workflow
da-roth Dec 25, 2025
7c75cd1
update benchmark yaml
da-roth Dec 25, 2025
8e1ce66
fix benchmark yaml
da-roth Dec 25, 2025
f7202e4
update ci.yaml
da-roth Dec 30, 2025
fbda9f6
updates
da-roth Dec 31, 2025
b8ca808
updated ci.yaml
da-roth Dec 31, 2025
95e634a
update ci.yaml
da-roth Dec 31, 2025
98d8b86
updated win build
da-roth Dec 31, 2025
c17f541
fix benchmark baseline
da-roth Jan 2, 2026
ed68306
updates
da-roth Jan 2, 2026
cf5030b
added benchmark_utils
da-roth Jan 2, 2026
8467808
temporarily use xad-jit
da-roth Jan 5, 2026
58267e1
up
da-roth Jan 5, 2026
3642cfa
up
da-roth Jan 7, 2026
7cda13d
use double forgebackend
da-roth Jan 9, 2026
3b5eb06
remove git ignore
da-roth Jan 10, 2026
ed5f877
update ci to use original xad
da-roth Jan 10, 2026
ad5dead
update reference in benchmark yaml
da-roth Jan 10, 2026
329aa79
new benchmarks.yaml
da-roth Jan 10, 2026
6bdd4d6
updated workflows
da-roth Jan 10, 2026
6275901
updates
da-roth Jan 10, 2026
6b74c54
up
da-roth Jan 10, 2026
608625e
udpated benchmark workflows
da-roth Jan 10, 2026
277b889
upda
da-roth Jan 10, 2026
9216536
udpates on benchmarks
da-roth Jan 10, 2026
814366a
added benchmark
da-roth Jan 10, 2026
c1e7296
added win and renamed a bit
da-roth Jan 10, 2026
ee695f8
up
da-roth Jan 10, 2026
86bfb8f
up
da-roth Jan 10, 2026
aa4a7da
update
da-roth Jan 10, 2026
43dfda7
remove unneeded workflows
da-roth Jan 10, 2026
957b93a
cleaning
da-roth Jan 10, 2026
1c6b0f9
udpates
da-roth Jan 10, 2026
c426d8e
re-route to original
da-roth Jan 10, 2026
9bc49c7
up
da-roth Jan 11, 2026
caae75e
Revert "up"
da-roth Jan 11, 2026
73cc721
remove copying around stuff
da-roth Jan 11, 2026
8e0d3ad
fixed config
da-roth Jan 14, 2026
2bbd67a
fix QL
da-roth Jan 14, 2026
f430020
up
da-roth Jan 14, 2026
cf239ff
up readme
da-roth Jan 16, 2026
1dd8047
Update .github/workflows/ci.yaml
da-roth Jan 20, 2026
469ccc6
Update .github/workflows/ci.yaml
da-roth Jan 20, 2026
4f07a96
Update .github/workflows/ci.yaml
da-roth Jan 20, 2026
ba2dd86
Update .github/workflows/ci.yaml
da-roth Jan 20, 2026
d484cd1
clean away the overhead test
da-roth Jan 20, 2026
619df09
updaed linux job initially
da-roth Jan 20, 2026
705c4d0
draft of new benchmark job structure
da-roth Jan 20, 2026
48e48c0
not trigger old ones
da-roth Jan 20, 2026
7bf0a1e
cleaned unneeded stuff
da-roth Jan 20, 2026
ce2c0d9
fix naming issues
da-roth Jan 20, 2026
2a208d4
up
da-roth Jan 20, 2026
21d241e
up
da-roth Jan 20, 2026
631f63a
new workflow
da-roth Jan 20, 2026
03434c4
up
da-roth Jan 20, 2026
c83be8f
up
da-roth Jan 20, 2026
b62d269
up
da-roth Jan 20, 2026
5732819
up
da-roth Jan 20, 2026
f69137f
up
da-roth Jan 20, 2026
3799ae8
up
da-roth Jan 20, 2026
5ad6ab0
up
da-roth Jan 20, 2026
4cd6880
up
da-roth Jan 20, 2026
046c66d
up
da-roth Jan 20, 2026
a636659
update output
da-roth Jan 21, 2026
cdc3d29
update output
da-roth Jan 21, 2026
c9a3106
remove v1
da-roth Jan 21, 2026
ebed861
clean cmake after rmv v1
da-roth Jan 21, 2026
037bf93
clean cmake for v2 rmv
da-roth Jan 21, 2026
77b6795
updated paths stuff
da-roth Jan 21, 2026
c1f0591
updates
da-roth Jan 21, 2026
7c7ffb6
up
da-roth Jan 21, 2026
e862c1a
udpdate
da-roth Jan 21, 2026
945dda2
updates
da-roth Jan 21, 2026
da7f123
name issue
da-roth Jan 21, 2026
f1311bf
update
da-roth Jan 21, 2026
c4a3e82
more iterations for prod example
da-roth Jan 22, 2026
e9206fe
refactor code
da-roth Jan 22, 2026
f272ecb
update pricing
da-roth Jan 23, 2026
d0e6706
order change
da-roth Jan 23, 2026
8f4f5a6
changed order
da-roth Jan 23, 2026
34a11ab
up
da-roth Jan 23, 2026
c02647b
sanity
da-roth Jan 23, 2026
18f4f15
up
da-roth Jan 23, 2026
897b74a
minor refactor
da-roth Jan 23, 2026
a28bc5e
Merge remote-tracking branch 'upstream/main' into forge
da-roth Jan 23, 2026
580ed86
added xadsplit
da-roth Jan 23, 2026
9d932e9
updated benchmark aad
da-roth Jan 23, 2026
4091fbb
reorder tests
da-roth Jan 23, 2026
5e8e53d
fix xad-split
da-roth Jan 23, 2026
ff880f0
up
da-roth Jan 23, 2026
b1b2789
up
da-roth Jan 23, 2026
e74420c
update
da-roth Jan 25, 2026
2ae3330
up
da-roth Jan 25, 2026
a834d63
script for local
da-roth Jan 25, 2026
be247fb
quicker build
da-roth Jan 25, 2026
971bac6
custom m1 and m2
da-roth Jan 25, 2026
4a25180
fix evolve
da-roth Jan 25, 2026
f14575d
up
da-roth Jan 25, 2026
1dc5410
remove sh
da-roth Jan 25, 2026
ba76944
update ci
da-roth Jan 25, 2026
5775a7e
update to have xad-split in xad
da-roth Jan 26, 2026
32964ff
update benchmarks yaml
da-roth Jan 26, 2026
d01e3c4
updated texts
da-roth Jan 26, 2026
9410273
update benchmark stuff
da-roth Jan 26, 2026
14cabf1
fix upstream
da-roth Jan 26, 2026
5a9cddf
use upstream ci names
da-roth Jan 29, 2026
27aa88f
up
da-roth Feb 2, 2026
3e312b0
up
da-roth Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
904 changes: 604 additions & 300 deletions .github/workflows/ci.yaml

Large diffs are not rendered by default.

922 changes: 922 additions & 0 deletions .github/workflows/ql-benchmarks.yaml

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions .github/workflows/ql-type-overhead.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
##############################################################################
#
# Type Overhead Benchmark: double vs xad::AReal<double>
#
# Measures the passive-mode overhead of xad::AReal<double> vs plain double
# for pricing-only workloads (no derivatives, no tape recording).
#
# Both types use the same templated priceSwaption<T>() code, compiled into
# a single binary for a fair comparison.
#
# Only requires QuantLib + XAD (no Forge).
#
# Copyright (C) 2025 Xcelerit Computing Limited
# SPDX-License-Identifier: AGPL-3.0-or-later
#
##############################################################################

name: Type Overhead Benchmark

on:
push:
branches:
- main
- forge
pull_request:
branches:
- main
- forge
workflow_dispatch:

env:
QL_REPO: lballabio/QuantLib
QL_BRANCH: master
XAD_REPO: auto-differentiation/xad
XAD_BRANCH: main

jobs:
##############################################################################
# Linux
##############################################################################
linux:
name: Linux, double vs AReal
runs-on: ubuntu-latest
container:
image: ghcr.io/lballabio/quantlib-devenv:rolling

steps:
- name: Hardware Info
run: |
echo "===== CPU ====="
lscpu | grep -E "^(Model name|CPU\(s\)|Thread|Core|Socket|CPU max MHz)"
echo "===== Memory ====="
free -h

- name: Checkout QuantLib
uses: actions/checkout@v4
with:
repository: ${{ env.QL_REPO }}
ref: ${{ env.QL_BRANCH }}
path: QuantLib

- name: Checkout XAD
uses: actions/checkout@v4
with:
repository: ${{ env.XAD_REPO }}
ref: ${{ env.XAD_BRANCH }}
path: xad

- name: Checkout QuantLib-Risks-Cpp
uses: actions/checkout@v4
with:
path: QuantLib-Risks-Cpp

- name: Setup
run: |
apt-get update
apt-get install -y ninja-build cmake

- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: linux-type-overhead
max-size: 1G

- name: Configure QuantLib (XAD)
run: |
cd QuantLib
cmake -B build -G Ninja -DBOOST_ROOT=/usr \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DXAD_WARNINGS_PARANOID=OFF \
-DXAD_ENABLE_JIT=OFF \
-DQL_EXTERNAL_SUBDIRECTORIES="$(pwd)/../xad;$(pwd)/../QuantLib-Risks-Cpp" \
-DQL_EXTRA_LINK_LIBRARIES=QuantLib-Risks \
-DQL_NULL_AS_FUNCTIONS=ON \
-DQL_BUILD_TEST_SUITE=OFF \
-DQL_BUILD_EXAMPLES=OFF \
-DQL_BUILD_BENCHMARK=OFF \
-DQLRISKS_DISABLE_AAD=OFF \
-DQLRISKS_BUILD_BENCHMARK_OVERHEAD=ON

- name: Build
run: |
cd QuantLib/build
cmake --build . --target benchmark_overhead

- name: Run Type Overhead Benchmark
run: |
cd QuantLib/build
./QuantLib-Risks-Cpp/test-suite/benchmark-overhead --all 2>&1 | tee overhead_results.txt

- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: linux-overhead-results
path: QuantLib/build/overhead_results.txt

##############################################################################
# Windows
##############################################################################
windows:
name: Windows, double vs AReal
runs-on: windows-2022

env:
VSVARSALL: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat

steps:
- name: Checkout QuantLib
uses: actions/checkout@v4
with:
repository: ${{ env.QL_REPO }}
ref: ${{ env.QL_BRANCH }}
path: QuantLib

- name: Checkout XAD
uses: actions/checkout@v4
with:
repository: ${{ env.XAD_REPO }}
ref: ${{ env.XAD_BRANCH }}
path: xad

- name: Checkout QuantLib-Risks-Cpp
uses: actions/checkout@v4
with:
path: QuantLib-Risks-Cpp

- name: Setup
run: choco install -y ninja

- name: Setup Boost
run: |
$Url = "https://downloads.sourceforge.net/project/boost/boost-binaries/1.86.0/boost_1_86_0-msvc-14.3-64.exe"
(New-Object System.Net.WebClient).DownloadFile($Url, "$RUNNER_TEMP\boost.exe")
Start-Process -Wait -FilePath "$RUNNER_TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=C:\local\boost"
echo "BOOST_ROOT=C:\local\boost" >> $env:GITHUB_ENV

- name: Configure QuantLib (XAD)
shell: cmd
run: |
call "%VSVARSALL%" x64
cd QuantLib
cmake -B build -G Ninja ^
-DCMAKE_CXX_STANDARD=17 ^
-DCMAKE_BUILD_TYPE=Release ^
-DXAD_WARNINGS_PARANOID=OFF ^
-DXAD_ENABLE_JIT=OFF ^
-DXAD_STATIC_MSVC_RUNTIME=ON ^
-DQL_EXTERNAL_SUBDIRECTORIES="%CD%\..\xad;%CD%\..\QuantLib-Risks-Cpp" ^
-DQL_EXTRA_LINK_LIBRARIES=QuantLib-Risks ^
-DQL_NULL_AS_FUNCTIONS=ON ^
-DQL_BUILD_TEST_SUITE=OFF ^
-DQL_BUILD_EXAMPLES=OFF ^
-DQL_BUILD_BENCHMARK=OFF ^
-DQLRISKS_DISABLE_AAD=OFF ^
-DQLRISKS_BUILD_BENCHMARK_OVERHEAD=ON

- name: Build
shell: cmd
run: |
call "%VSVARSALL%" x64
cd QuantLib\build
cmake --build . --target benchmark_overhead

- name: Run Type Overhead Benchmark
shell: cmd
run: |
cd QuantLib\build
QuantLib-Risks-Cpp\test-suite\benchmark-overhead.exe --all > overhead_results.txt 2>&1
type overhead_results.txt

- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: windows-overhead-results
path: QuantLib\build\overhead_results.txt
65 changes: 60 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
#
#
#
# This file is part of QuantLib-Risks, an adaptor module to enable using XAD with
# QuantLib. XAD is a fast and comprehensive C++ library for
Expand All @@ -19,17 +19,72 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################

option(QLRISKS_DISABLE_AAD "Disable using XAD for QuantLib's Real, allowing to run samples with double" OFF)
option(QLRISKS_ENABLE_FORGE "Enable Forge JIT backend via xad-forge" OFF)
option(QLRISKS_USE_FORGE_CAPI "Use Forge C API instead of C++ API for binary compatibility" OFF)

add_subdirectory(ql)
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
add_subdirectory(Examples)
if(NOT QLRISKS_DISABLE_AAD)
# the test suite is not supporting double
add_subdirectory(test-suite)

##############################################################################
# QLRisks-Forge integration via xad-forge
# NOTE: This must be defined BEFORE test-suite so tests can link to it
##############################################################################

if(QLRISKS_ENABLE_FORGE)
message(STATUS "QLRisks-Forge: Looking for xad-forge...")

# Pass through the C API option to xad-forge
set(XAD_FORGE_USE_CAPI ${QLRISKS_USE_FORGE_CAPI} CACHE BOOL "" FORCE)

# Option 1: Check if xad-forge was added as subdirectory
if(TARGET xad-forge)
message(STATUS "QLRisks-Forge: Found xad-forge target (subdirectory mode)")
set(XAD_FORGE_FOUND TRUE)
endif()

# Option 2: Try find_package for pre-built xad-forge
if(NOT XAD_FORGE_FOUND)
find_package(xad-forge CONFIG QUIET)
if(xad-forge_FOUND)
message(STATUS "QLRisks-Forge: Found xad-forge package (pre-built mode)")
set(XAD_FORGE_FOUND TRUE)
endif()
endif()

if(XAD_FORGE_FOUND)
# Create qlrisks-forge as an INTERFACE library wrapping xad-forge
add_library(qlrisks-forge INTERFACE)
add_library(QLRisks::forge ALIAS qlrisks-forge)

target_link_libraries(qlrisks-forge INTERFACE
XADForge::xad-forge
)

target_compile_definitions(qlrisks-forge INTERFACE QLRISKS_HAS_FORGE=1)

message(STATUS "QLRisks-Forge: Configured with xad-forge")
else()
message(STATUS "QLRisks-Forge: xad-forge not found - ForgeBackend will not be available")
message(STATUS "QLRisks-Forge: To enable, either:")
message(STATUS " 1. Add xad-forge as subdirectory")
message(STATUS " 2. Set CMAKE_PREFIX_PATH to xad-forge installation")
endif()
endif()

##############################################################################
# Test suite (after QLRisks::forge is defined)
##############################################################################

# Add test-suite if:
# 1. AAD is enabled (for XAD-based tests and benchmarks), OR
# 2. FD benchmark is requested (works with plain double)
if(NOT QLRISKS_DISABLE_AAD OR QLRISKS_BUILD_BENCHMARK_FD)
add_subdirectory(test-suite)
endif()
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ This repository contains integration headers, examples, and tests required
for this integration.
It is not usable stand-alone.

## JIT Compilation Support

XAD is optimized for computing sensitivities efficiently in a single evaluation pass using adjoint mode. For workflows that require repeated evaluation across many scenarios—such as Monte Carlo simulations, XVA calculations, regulatory stress testing, or scenario-based risk analysis—XAD also supports recording computations into a [`JITGraph`](https://auto-differentiation.github.io/xad/ref/jit/) that can be compiled and re-evaluated efficiently using a JIT backend. The [xad-forge](https://github.com/da-roth/xad-forge) library provides Forge-based backends for this purpose, including vectorized AVX execution. See the [xad-forge README](https://github.com/da-roth/xad-forge#when-to-use-jit) for guidance on when JIT compilation is beneficial.

The repository includes a [swaption benchmark](.github/workflows/ql-benchmarks.yaml) that demonstrates a hybrid workflow: curve bootstrapping with XAD's tape, followed by Monte Carlo pricing with JIT-compiled evaluation, comparing tape-based, JIT, and JIT-AVX performance.

## Getting Started

For detailed build instructions with [XAD](https://auto-differentiation.github.io) and [QuantLib](https://www.quantlib.org), please refer to the [XAD documentation site](https://auto-differentiation.github.io/quantlib-risks/cxx/).
Expand Down
2 changes: 1 addition & 1 deletion ql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ if(NOT QLRISKS_DISABLE_AAD)
else()
target_compile_definitions(QuantLib-Risks INTERFACE QLRISKS_DISABLE_AAD=1)
endif()
target_link_libraries(QuantLib-Risks INTERFACE XAD::xad)
if(MSVC)
target_compile_options(QuantLib-Risks INTERFACE /bigobj)
endif()
target_link_libraries(QuantLib-Risks INTERFACE XAD::xad)
set_target_properties(QuantLib-Risks PROPERTIES
EXPORT_NAME QuantLib-Risks
)
Expand Down
Loading
Loading