Skip to content

Commit 69dd7f9

Browse files
Merge pull request #3339 from annietllnd/review
Technical review of QuantLib LP
2 parents 32713be + 25924d6 commit 69dd7f9

6 files changed

Lines changed: 155 additions & 144 deletions

File tree

content/learning-paths/servers-and-cloud-computing/quantlib/1-overview.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ layout: learningpathall
1010

1111
QuantLib is an open-source C++ library for quantitative finance. It provides tools for pricing, modeling, trading, and risk management, and is widely used as both a development library and a representative financial computing workload.
1212

13-
Because QuantLib is a substantial C++ codebase with realistic compute behavior, it is also useful as a benchmark when evaluating cloud systems and processor architectures.
14-
15-
In this Learning Path, you will build QuantLib from source and run its benchmark executable on an Arm-based Azure Cobalt virtual machine.
13+
Because QuantLib is a substantial C++ codebase with realistic compute behavior, it is also useful as a benchmark when evaluating cloud systems and processor architectures. In this Learning Path, you will build QuantLib from source and run its benchmark executable on an Arm-based Azure Cobalt virtual machine.
1614

1715
## Why use Azure Cobalt?
1816

1917
Azure Cobalt provides Arm64 virtual machines for cloud-native development and performance evaluation. Running QuantLib on Azure Cobalt gives you a practical way to measure how a real C++ finance workload behaves on Arm-based cloud infrastructure.
2018

21-
The workflow in this Learning Path uses:
19+
The workflow uses:
2220

23-
- Ubuntu Server 22.04 LTS
21+
- Ubuntu Server 22.04 LTS (also tested on 24.04 LTS)
2422
- an Arm64 Azure Cobalt virtual machine
2523
- a source build of QuantLib
2624
- QuantLib's benchmark executable for repeatable performance testing
2725

28-
## What you'll do
26+
## Benchmark workflow
2927

30-
This Learning Path follows a simple workflow:
28+
The steps follow a practical benchmark flow:
3129

3230
1. Create and connect to an Arm64 Azure Cobalt virtual machine
3331
2. Install the tools needed to build QuantLib
@@ -39,6 +37,22 @@ This Learning Path follows a simple workflow:
3937
This Learning Path focuses on building and benchmarking QuantLib on Azure Cobalt. It is not a general introduction to quantitative finance or QuantLib development.
4038
{{% /notice %}}
4139

40+
## What the benchmark tests
41+
42+
The benchmark executable runs approximately 85 tests drawn directly from QuantLib's own test suite, covering five domains:
43+
44+
- **Equity and FX**: American and European option pricing, Heston and Bates model calibration, convertible bonds, Andreasen-Huge volatility interpolation
45+
- **Interest rates**: Short rate models, Bermudan swaptions, Libor market model, piecewise yield curves, overnight indexed swaps, Markov functional models, SABR and ZABR volatility
46+
- **Credit derivatives**: Nth-to-default pricing and credit default swap calibration
47+
- **Energy**: Swing options and virtual power plant pricing
48+
- **Math**: Gaussian quadratures, low-discrepancy sequences, statistics, and special functions
49+
50+
Each test has a fixed iteration count built in. Some run once per task, others run hundreds or thousands of times to produce a measurable signal. The `--size` argument multiplies the entire set: `--size=2` runs each test twice, `--size=5` runs it five times, and so on. Doubling `--size` doubles runtime while leaving throughput unchanged — this is the expected weak scaling behavior of the benchmark.
51+
52+
The `--nProc` argument controls the number of worker processes. Because QuantLib is not thread-safe, the benchmark uses separate processes rather than threads, coordinated through Boost IPC. Before timing begins, the benchmark runs every test once through the Boost unit test framework to verify correctness — this is what produces the `*** No errors detected` line in the output.
53+
54+
**System Throughput** is calculated as `(size × number_of_tests) / total_runtime`. It is the primary metric for comparing runs across thread counts and system configurations.
55+
4256
## Benchmarking goals
4357

4458
When benchmarking a workload such as QuantLib, the goal is not just to obtain one runtime number. You want a repeatable process that lets you compare runs across system sizes, thread counts, software versions, and compiler settings.
@@ -48,4 +62,4 @@ For that reason, this Learning Path emphasizes:
4862
- using a known VM configuration
4963
- keeping the software environment consistent
5064
- changing one benchmark variable at a time
51-
- recording commands and results so runs can be reproduced later
65+
- recording commands and results so runs can be reproduced later

content/learning-paths/servers-and-cloud-computing/quantlib/2-setup-environment.md

Lines changed: 70 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,47 @@ weight: 3
66
layout: learningpathall
77
---
88

9-
## Create an Arm64 Azure Cobalt virtual machine
9+
## Create and connect to an Arm64 Azure Cobalt virtual machine
1010

1111
To run QuantLib on Azure Cobalt, first create an Arm64 Ubuntu virtual machine in the Azure portal.
1212

1313
Use the following settings:
1414

15-
- **Virtual machine name:** `quantlib-cobalt-vm`
16-
- **Region:** a Cobalt-supported region such as **West US 2**
17-
- **Availability options:** **No infrastructure redundancy required**
18-
- **Security type:** **Standard**
19-
- **Image:** **Ubuntu Server 22.04 LTS**
20-
- **VM architecture:** **Arm64**
21-
- **Size:** **Standard_D4ps_v5**
22-
- **Authentication type:** **SSH public key**
23-
- **Username:** `azureuser`
15+
| Setting | Value |
16+
|---|---|
17+
| Virtual machine name | `quantlib-cobalt-vm` |
18+
| Region | a Cobalt-supported region such as **West US 2** |
19+
| Availability options | No infrastructure redundancy required |
20+
| Security type | Standard |
21+
| Image | Ubuntu Server 22.04 LTS |
22+
| VM architecture | Arm64 |
23+
| Size | Standard_D4ps_v5 |
24+
| Authentication type | SSH public key |
25+
| SSH public key name | `quantlib-cobalt-vm_key` |
26+
| Username | `azureuser` |
2427

2528
For storage, a `64 GB` OS disk is sufficient for this workflow.
2629

2730
For networking, allow inbound SSH on port `22`. Restricting the source to **My IP** is recommended.
2831

2932
After creating the VM, download the generated private key in `.pem` format if Azure provides one during setup.
3033

31-
## Connect to the virtual machine
32-
33-
On your local machine, update the permissions on the private key:
34+
Before connecting, update the permissions on the private key from your local machine. SSH refuses to use keys that are readable by other users:
3435

3536
```bash
3637
chmod 600 ~/Downloads/quantlib-cobalt-vm_key.pem
3738
```
3839

39-
Then connect using SSH:
40+
Connect to the VM using the key and the public IP address shown in the Azure portal:
4041

4142
```bash
4243
ssh -i ~/Downloads/quantlib-cobalt-vm_key.pem azureuser@<VM_PUBLIC_IP>
4344
```
4445

45-
Replace <VM_PUBLIC_IP> with the public IP address of your VM.
46-
47-
### (Optional) Reconnect to cobalt frequently
48-
49-
If you’ll reconnect often, add a shortcut entry to your SSH config:
46+
Replace `<VM_PUBLIC_IP>` with the public IP address of your VM.
5047

51-
```bash
52-
nano ~/.ssh/config
53-
```
5448

55-
Add:
56-
57-
```bash
58-
Host quantlib-cobalt
59-
HostName <VM_PUBLIC_IP>
60-
User azureuser
61-
IdentityFile ~/Downloads/quantlib-cobalt-vm_key.pem
62-
```
63-
64-
Then connect with:
65-
66-
```bash
67-
ssh quantlib-cobalt
68-
```
69-
70-
## Confirm that the system is Arm64
71-
72-
After logging in, verify the architecture:
49+
After logging in, verify the architecture before installing packages. The rest of this Learning Path assumes you are on an Arm64 system:
7350

7451
```bash
7552
uname -m
@@ -83,9 +60,9 @@ aarch64
8360

8461
If you do not see aarch64, check that you created the VM with Arm64 architecture and selected an Azure Cobalt-compatible instance type.
8562

86-
## Install build dependencies
63+
## Install dependencies and download QuantLib
8764

88-
Update the package index and install required packages:
65+
Update the package index and install the required packages:
8966

9067
```bash
9168
sudo apt update
@@ -94,29 +71,16 @@ sudo apt install -y build-essential cmake curl libboost-all-dev
9471

9572
These packages provide the compiler toolchain, build system support, download tools, and Boost libraries needed to build QuantLib.
9673

97-
## Optional: use tmux for remote builds
98-
99-
If you want the build to continue even if your SSH session disconnects, install tmux:
100-
101-
```bash
102-
sudo apt update
103-
sudo apt install -y tmux
104-
tmux
105-
```
106-
107-
## Download QuantLib
108-
109-
Set the version and download the release archive:
74+
Set the QuantLib version as an environment variable, then download the release archive. Keeping the version in `QL_VER` makes later commands easier to repeat or adapt for a newer release:
11075

11176
```bash
11277
export QL_VER=1.41
113-
11478
cd ~
11579
curl -L -o QuantLib-$QL_VER.tar.gz \
11680
https://github.com/lballabio/QuantLib/releases/download/v$QL_VER/QuantLib-$QL_VER.tar.gz
11781
```
11882

119-
Check that the file exists. Run:
83+
Check that the file exists and has a non-zero size:
12084

12185
```bash
12286
ls -lh QuantLib-$QL_VER.tar.gz
@@ -130,61 +94,85 @@ You should see output showing the file name and size, for example:
13094

13195
If the file is missing or has size 0, re-run the curl command.
13296

133-
## Verify the file type
97+
## Verify and extract the source archive
98+
99+
Use the `file` command to confirm that the archive is a gzip-compressed tar file:
134100

135-
Use the file command to confirm that the archive is a valid gzip-compressed tar file:
136101
```bash
137102
file QuantLib-$QL_VER.tar.gz
138103
```
139104

140-
Expected output is simlar to:
105+
Expected output is similar to:
106+
141107
```bash
142108
QuantLib-1.41.tar.gz: gzip compressed data, max compression, from Unix, original size modulo 2^32 42721280
143109
```
144110

145-
### (Optional) Test archive integrity
111+
Once confirmed, extract it and move into the extracted directory:
146112

147-
To check that the archive is not corrupted, run:
148113
```bash
149-
tar -tzf QuantLib-$QL_VER.tar.gz > /dev/null
114+
tar -xzf QuantLib-$QL_VER.tar.gz
115+
cd QuantLib-$QL_VER
150116
```
151117

152-
If the command completes without errors, the archive is valid.
153118

154-
If you see errors such as:
119+
120+
List the contents to confirm that the source code is ready to configure and build:
121+
122+
```bash
123+
ls
124+
```
125+
126+
You should see files and directories such as:
155127

156128
```bash
157-
gzip: stdin: unexpected end of file
158-
tar: Unexpected EOF in archive
129+
configure
130+
Makefile.am
131+
ql/
132+
test-suite/
159133
```
160134

161-
the download is incomplete or corrupted.l Delete the file and download it again.
135+
This confirms that the source code has been unpacked correctly and is ready to configure and build.
162136

163-
## Extract the archive
137+
{{% notice Optional Setup %}}
138+
## Reconnect to Cobalt frequently
139+
140+
If you'll reconnect often, add a shortcut entry to your SSH config:
164141

165-
Once the archive is verified, extract it:
166142
```bash
167-
tar -xzf QuantLib-$QL_VER.tar.gz
143+
nano ~/.ssh/config
168144
```
169145

170-
Then move into the extracted directory:
146+
Add:
147+
171148
```bash
172-
cd QuantLib-$QL_VER
149+
Host quantlib-cobalt
150+
HostName <VM_PUBLIC_IP>
151+
User azureuser
152+
IdentityFile ~/Downloads/quantlib-cobalt-vm_key.pem
173153
```
174154

175-
## Confirm the extracted contents
155+
Then connect with:
176156

177-
List the contents:
178157
```bash
179-
ls
158+
ssh quantlib-cobalt
180159
```
181160

182-
You should see files and directories such as:
161+
## Use tmux for remote builds
162+
163+
If your SSH session disconnects during the build, the compile job will be killed. To prevent this, install tmux and start a session before running `make`:
164+
183165
```bash
184-
configure
185-
Makefile.am
186-
ql/
187-
test-suite/
166+
sudo apt update
167+
sudo apt install -y tmux
168+
tmux
188169
```
189170

190-
This confirms that the source code has been unpacked correctly and is ready to configure and build.
171+
Run the build commands from inside the tmux session. If your connection drops, reconnect to the VM and re-attach with:
172+
173+
```bash
174+
tmux attach
175+
```
176+
{{% /notice %}}
177+
178+
With your environment set up, move on to the next section to build QuantLib.

content/learning-paths/servers-and-cloud-computing/quantlib/3-build-quantlib.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ weight: 4
66
layout: learningpathall
77
---
88

9-
## Configure the QuantLib build
9+
## Configure the build
1010

11-
From the QuantLib source directory:
11+
Return to the QuantLib source directory. This uses the `QL_VER` variable you exported when downloading the source archive:
1212

1313
```bash
1414
cd ~/QuantLib-$QL_VER
1515
```
1616

17-
Run the configure script:
17+
Run the configure script with benchmark support enabled:
1818
```bash
1919
./configure \
2020
--prefix=/usr/local \
@@ -32,35 +32,30 @@ This configuration:
3232
- applies CPU-specific optimization flags
3333

3434

35-
## Build QuantLib
35+
## Install QuantLib
3636

37-
Compile using all available cores:
37+
Compile using all available cores. The `nproc` command returns the number of processing units visible to the VM, so `make -j$(nproc)` keeps the build command portable across VM sizes:
3838

3939
```bash
4040
make -j$(nproc)
4141
```
4242

4343
{{% notice Note %}}
44-
The build may take 30–45 minutes on smaller instances. Use tmux to avoid losing progress if your SSH session disconnects.
44+
The build may take 30–45 minutes on the Standard_D4ps_v5. If your SSH session might disconnect, set up tmux before running `make` — see the optional setup steps in the previous section.
4545
{{% /notice %}}
4646

47-
## Install QuantLib
48-
49-
After the build completes:
47+
After the build completes, install QuantLib into `/usr/local` and refresh the dynamic linker cache:
5048

5149
```bash
5250
sudo make install
5351
sudo ldconfig
5452
```
5553

56-
## Verify the build
54+
Move to the test suite and check that the benchmark executable was created:
5755

58-
Move to the test suite:
5956
```bash
6057
cd ~/QuantLib-$QL_VER/test-suite
61-
```
62-
63-
Check that the benchmark executable exists:
64-
```bash
6558
ls quantlib-benchmark
6659
```
60+
61+
You should see `quantlib-benchmark` in the output. You will use this executable in the next section.

0 commit comments

Comments
 (0)