Skip to content

Commit ecbeb1f

Browse files
authored
Merge pull request #13 from NVIDIA-AI-Blueprints/release-25.12
Release 25.12
2 parents 421fdbb + 16f539c commit ecbeb1f

11 files changed

Lines changed: 1505 additions & 2082 deletions

.github/workflows/release-2512.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Portfolio Optimization Notebook Runner
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-25.12
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
run-notebooks:
16+
runs-on: arc-runner-set-oke-org-nv-ai-bp
17+
env:
18+
PYTHON_VERSION: 3.12
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Install Git LFS
24+
run: |
25+
echo "===================== Install Git LFS ====================="
26+
sudo apt-get update
27+
sudo apt-get install -y git-lfs
28+
git lfs install
29+
30+
- name: Pull Git LFS files
31+
run: |
32+
echo "===================== Pull LFS files ====================="
33+
git lfs pull
34+
35+
- name: Check System Info
36+
run: |
37+
echo "===================== System Info ====================="
38+
more /etc/os-release
39+
uname -a
40+
nvidia-smi
41+
docker version
42+
43+
- name: Run container and execute notebooks
44+
run: |
45+
docker run --gpus all --rm \
46+
-v "$(pwd):/workspace" \
47+
-w /workspace \
48+
nvcr.io/nvidia/pytorch:25.08-py3 \
49+
bash -c '
50+
echo "===================== Python and GPU Info ====================="
51+
python --version
52+
nvidia-smi
53+
54+
echo "===================== Create Virtual Environment ====================="
55+
python -m venv .venv
56+
source .venv/bin/activate
57+
58+
echo "===================== Install Dependencies ====================="
59+
python -m pip install --upgrade pip
60+
pip install .
61+
62+
echo "===================== Install Development Tools ====================="
63+
pip install ".[dev]"
64+
65+
echo "===================== Install Jupyter ====================="
66+
pip install jupyter jupyterlab ipykernel papermill nbconvert
67+
68+
echo "===================== Create Jupyter Kernel ====================="
69+
python -m ipykernel install --user --name=portfolio-opt --display-name "Portfolio Optimization"
70+
71+
echo "===================== List Jupyter Kernel ====================="
72+
jupyter kernelspec list
73+
74+
echo "===================== Change to notebooks directory ====================="
75+
cd notebooks
76+
77+
echo "===================== Run cvar_basic notebook ====================="
78+
papermill cvar_basic.ipynb cvar_basic_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
79+
80+
echo "===================== Run efficient_frontier notebook ====================="
81+
papermill efficient_frontier.ipynb efficient_frontier_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
82+
83+
echo "===================== Run rebalancing_strategies notebook ====================="
84+
papermill rebalancing_strategies.ipynb rebalancing_strategies_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
85+
86+
echo "===================== Convert notebooks to HTML ====================="
87+
jupyter nbconvert --to html cvar_basic_result.ipynb
88+
jupyter nbconvert --to html efficient_frontier_result.ipynb
89+
jupyter nbconvert --to html rebalancing_strategies_result.ipynb
90+
'
91+
92+
- name: Verify results
93+
if: always()
94+
env:
95+
TEST_DOCKER_PULL_KEY: ${{ secrets.TEST_DOCKER_PULL_KEY }}
96+
run: |
97+
echo "Checking for generated files...."
98+
ls -lh notebooks/*result*
99+
cd notebooks
100+
echo "$TEST_DOCKER_PULL_KEY" |docker login nvcr.io --username '$oauthtoken' --password-stdin
101+
docker run --rm \
102+
-v ./cvar_basic_result.html:/app/input/quantitative_portfolio_optimization/cvar_basic.html \
103+
-v ./efficient_frontier_result.html:/app/input/quantitative_portfolio_optimization/efficient_frontier.html \
104+
-v ./rebalancing_strategies_result.html:/app/input/quantitative_portfolio_optimization/rebalancing_strategies.html \
105+
-v "$(pwd):/workspace" \
106+
nvcr.io/rw983xdqtcdp/auto_test_team/blueprint-github-test-image:latest \
107+
pytest -m quantitative_portfolio_optimization --disable-warnings --html=/workspace/quantitative_portfolio_optimization.html --self-contained-html
108+
109+
110+
- name: Upload notebook results as artifacts
111+
if: always()
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: notebook-results
115+
path: |
116+
notebooks/cvar_basic_result.html
117+
notebooks/efficient_frontier_result.html
118+
notebooks/rebalancing_strategies_result.html
119+
notebooks/quantitative_portfolio_optimization.html
120+
retention-days: 30

README.md

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,23 @@
22

33
## Overview
44

5-
This project provides GPU-accelerated solutions for portfolio optimization, a computationally intensive task central to portfolio management. It leverages NVIDIA technologies including **cuOpt**, **RAPIDS**, and the **HPC SDK** to deliver substantial performance improvements over traditional CPU-based approaches.
5+
The Quantitative Portfolio Optimization developer example is a GPU-accelerated solution designed to enable fast, scalable, and real-time portfolio optimization for financial institutions. Leveraging NVIDIA® cuOpt™ and RAPIDS, this developer example delivers near-real-time solutions for large-scale Mean-CVaR portfolio optimization problems, allowing enterprises to model advanced risk measures and optimize complex portfolios in accelerated time.
66

77
Portfolio Optimization (PO) involves solving high-dimensional, non-linear numerical optimization problems that balance risk and return to meet investment goals. By introducing GPU-accelerated building blocks, this project significantly reduces computation times while improving solution quality, making sophisticated portfolio optimization accessible and practical for large-scale applications.
88

9-
### Key Features
10-
11-
- **GPU-Accelerated Optimization**: Leverages NVIDIA cuOpt LP/MILP solvers for dramatic speedups
12-
- **Advanced Risk Measure**: Supports Conditional Value-at-Risk (CVaR) optimization
13-
- **Real-World Constraints**: Implements concentration limits, leverage constraints, turnover limits, and cardinality constraints
14-
- **Scenario Generation**: Uses GPU-accelerated KDE (Kernel Density Estimation) for return distribution modeling
15-
- **Backtesting Framework**: Comprehensive tools for evaluating portfolio performance
16-
- **Dynamic Re-Balancing** Backtesting tools for testing re-balancing strategies
17-
18-
### Why Portfolio Optimization Matters
19-
20-
Portfolio Management (PM) is crucial for all investment-focused institutions, including buy-side and sell-side operations across asset classes. As financial markets grow in complexity and diversity, the demand for sophisticated PM techniques increases. Currently, most institutions rely on CPUs and third-party solvers, which can be slow and costly. GPU acceleration offers a path to faster, more efficient, and more scalable portfolio optimization solutions.
21-
22-
### Optimization Methods
23-
24-
**CVaR Optimization**: Conditional Value-at-Risk offers a more nuanced assessment of risk by focusing on the tail end of the loss distribution. Unlike Value-at-Risk (VaR), CVaR accounts for the average of losses that exceed a threshold, providing a more comprehensive measure of extreme risks. This approach is particularly valuable for portfolios with asymmetric return distributions.
25-
26-
### Portfolio Optimization Workflow
27-
![Portfolio Optimization workflow](./images/po_workflow.png)
28-
29-
### NVIDIA Technology Stack
309
<p align="center">
31-
<img src="./images/nvidia_po_stack.png" alt="NVIDIA stack for PO" width="750"/>
10+
<img src="./docs/arch_diagram.png" alt="architecture diagram for PO" width="750"/>
3211
</p>
3312

13+
### Key Features
14+
15+
- **End-to-End GPU Workflow**: Accelerates the portfolio allocation problem using NVIDIA® cuOpt™, delivering near-real-time optimization.
16+
- **Flexible Financial Model Building**: Fully customizable constraints, including CVaR, leverage, budgets, turnover, and cardinality limits.
17+
- **Data-driven Risk Modeling**: Utilizes CVaR as a risk measure that is scenario-based and requires no assumptions about the asset return distribution.
18+
- **Full Pipeline Support**: Provides tools for performance evaluation, strategy backtesting, benchmarking, and visualization.
19+
- **Easy Benchmarking**: Streamlines the process of benchmarking against CP-based libraries and solvers.
20+
- **Scalable & Efficient**: Excels at solving large LP and MILP problems, leveraging NVIDIA libraries for pre- and post-optimization acceleration.
21+
3422
## Get Started
3523

3624
### System Requirements

docs/arch_diagram.png

136 KB
Loading

0 commit comments

Comments
 (0)