Upload
phamnhu
View
228
Download
0
Embed Size (px)
Citation preview
Experts in numerical algorithms and HPC services
NAG for HPC Finance
John Holden
15th May 2012
Computational Methods and
Technologies for Finance
HPCFinance Conference
Tampere, Finland
2
NAG Introduction
NAG for HPC Finance
Why Quants Love NAG
Accelerators NVIDIA
Intel Xeon-Phi
Algorithmic Differentiation
Summary
Agenda
3
Founded 1970 Not-for-profit organisation
Surpluses fund on-going R&D
Mathematical and Statistical Expertise Numerical Libraries of components
Consulting
HPC Services
Computational Science and Engineering (CSE) support
Procurement advice, market watch, benchmarking
NAG Background
4
HPC Services
Government, Academic and Commercial
Full CSE service
Code porting, tuning, scaling, rewriting…
Training
1-20 FTEs per annum
Procurement advice/benchmarking
5
Financial Services
Many clients in FSI
Most Tier 1 Banks have licences
> 60% have global licences
Typically the NAG Library is embedded in the banks own “quant” libraries (C++, . NET, Java,…)
6
HPCFinance.eu
All HPCFinance fellows can
get access to NAG software for their HPCFinance.eu work
get HPC Services training from NAG (direct, or via HECToR) OpenMP, CUDA, MPI, Algorithmic Differentiation,
Good collaborations on HPC Finance codes with
University of Manchester and SWIP Professor Poon + fellows
Aarhus University PhD / HPCFinance fellow secondment pending
7
NAG Introduction
NAG for HPC Finance
Why Quants Love NAG
Accelerators NVIDIA
Intel Xeon-Phi
Algorithmic Differentiation
Summary
Agenda
8
An example: sample variance
For a collection of observations
the mean is defined as
and the variance as
}...1,{ nixi }...1,{ nixi
2
1
2 )(1
1xx
ns
n
i
i
n
i
ixn
x1
1
}...1,{ nixi
2
1
2 )(1
1xx
ns
n
i
i
n
i
ixn
x1
1
2
1
2 )(1
1xx
ns
n
i
i
n
i
ixn
x1
1
11
What’s gone wrong?
Instead of
Excel uses an (analytically identical) formula
faster to calculate (one pass)
accuracy problems if variance is small compared to x
2
11
22 1
1
1 n
i
i
n
i
i xn
xn
s
2
1
2 )(1
1xx
ns
n
i
i
13
from Finance - k Factor Problem
Nonlinear objective function with convex quadratic
constraints.
NAG function (G02AE) based on spectral projected
gradient method
(Borsdorf, Higham & Raydan, 2010)
Respects constraints, exploits convexity, converges to a
feasible stationary point
Principal Factors method (Andersen et al., 2003)
No convergence theory and can converge to an incorrect
answer
14
Why Quants use NAG Libraries and Toolboxes?
Global reputation for quality – accuracy, reliability and robustness…
Extensively tested, supported and maintained code
Reduces development time
Allows concentration on your key areas
Components
Fit into your environment
Simple interfaces to your favourite packages
Regular performance improvements!
Give “qualified error” messages e.g. tolerances of answers
15
NAG Library and Toolbox Contents
Root Finding
Summation of Series
Quadrature
Ordinary Differential Equations
Partial Differential Equations
Numerical Differentiation
Integral Equations
Mesh Generation
Interpolation
Curve and Surface Fitting
Optimization
Approximations of Special Functions
Dense Linear Algebra
Sparse Linear Algebra
Correlation & Regression Analysis
Multivariate Methods
Analysis of Variance
Random Number Generators
Univariate Estimation
Nonparametric Statistics
Smoothing in Statistics
Contingency Table Analysis
Survival Analysis
Time Series Analysis
Operations Research
16
Use of NAG Software in Finance
Portfolio allocation / Risk management /Stress testing Optimization , interpolation, linear algebra, RNGs, Distributions,
Copulas…
Derivative pricing, Hedging PDEs, RNGs, multivariate normal, curve & surface fitting,
quadrature…
Calibration Optimisation, Interpolation , Root Finders, Splines
Data analysis Time series, GARCH, principal component analysis, data smoothing,
Data Mining…
Monte Carlo simulation RNGs, Brownian Bridge constructor, Linear Algebra
…
17
Why Quantitative Analysts Love NAG?
General Problem
To build asset models and risk engines in a timely manner that are Robust
Stable
Quick
Solution
Use robust, well tested, fast numerical components
This allows the “expensive” experts to concentrate on the modelling and interpretation avoiding distraction with low level numerical components
18
Problem 1: Simulation (Monte Carlo)
Simulation is important for scenario generation
Several different numerical components needed
Random Number Generators
Brownian bridge constructor
Interpolation/Splines
Principal Component Analysis
Cholesky Decomposition
Distributions (uniform, Normal, exponential gamma, Poisson, Student’s t, Weibull,..)
..
19
Problem 1: Simulation (Monte Carlo)
Simulation is important for scenario generation
NAG to the rescue (CPU or GPU)
Several different numerical components needed
Random Number Generators √
Brownian bridge constructor √
Interpolation/Splines √
Principal Component Analysis√
Cholesky Decomposition √
Distributions (uniform, Normal, exponential gamma, Poisson, Student’s t, Weibull,..)√
.. √ √
20
Problem 2: Calibration
Financial institutions all need to calibrate their models
Several different numerical components needed
Optimisation functions (e.g. constrained non-linear optimisers)
Interpolation functions (used intelligently*)
Spline functions
..
*interpolator must be used carefully –must know the properties to pick appropriate method
21
Problem 2: Calibration
Financial institutions all need to calibrate their models
NAG to the rescue
Several different numerical components needed
Optimisation functions (e.g. constrained non-linear
optimisers) √
Interpolation functions (used intelligently*) √
Spline functions √
.. √ √
*interpolator must be used carefully –must know the properties to pick appropriate method
22
NAG fits into your favourite environments
Supporting Wide Range of Operating systems…
Windows, Linux, Solaris, Mac, …
…and a number of interfaces
C, C++,
Fortran,
VB, Excel & VBA,
C#, F#, VB.NET,
CUDA, OpenCL,
Java,
Python
…
Excel,
LabVIEW,
MATLAB,
Maple,
Mathematica
R, S-Plus,
Scilab, Octave
…
23
NAG Introduction
NAG for HPC Finance
Why Quants Love NAG
Accelerators NVIDIA
Intel Xeon-Phi
Algorithmic Differentiation
Summary
Agenda
24
Escalator?: Want more performance? Buy the next processor!
To get performance/efficiency we have to go (massively) parallel
Disruption causing serious look at ‘other’ technologies and algorithms!
Even CPUs with tens of cores per node
Hybrid, shared-memory and distributed-memory parallelism
Painful whichever way we turn!
Where has my Escalator gone?
25
Loose definition: hardware on which to run your software better than on your (general purpose) CPU
Generally NOT an easy win
Significant learning curve and effort
Offload disadvantages
…
Accelerators
26
ClearSpeed
Similar to GPU
Lacked a good software eco-system
IBM Cell
Lacked a good software eco-system
GPGPU
NVIDIA invested in the software eco-system (AMD not!)
Intel Phi
Early days – an encouraging start
Accelerators
27
We provide
A suite of Numerical Routines for Monte Carlo simulation from a collaboration with Professor Mike Giles
also MAGMA based Linear Algebra from Jack Dongarra
on-going work with Professor William Shaw to implement new Inverse CDFs (new distributions and speed up to existing code)
“Bespoke” consultancy codes PDE Solver for Stochastic Local Volatility
FX Basket Option, Local Vol Model
..
Training courses for CUDA and Open CL
NAG and GPGPUs (NVIDIA)
28
NAG GPU Gamma Inverse CDF Benchmarks
What follows are times in milliseconds to compute the gamma inverse CDF for 107 uniform variates GPU = NVIDIA GeForce GTX 480
CPU = Intel Core 2 Duo E7400
OS = Ubuntu Server 11.10
Times in bold are for double-precision; other times are for single-precision
Accuracy: maximum ulp errors are always ≤ 8
29
Shape
parameter
NAG Boost
GPU CPU CPU
1 77.9
154.0
1016.4
1168.0
2693.4
3511.6
2 86.0
162.9
886.9
1229.7
6937.3
8417.9
4 94.4
157.8
834.8
1199.5
7564.4
8621.1
8 94.4
164.7
838.4
1176.9
5361.6
8937.7
16 94.4
164.7
823.2
1169.3
4738.7
8923.2
30
Relatively easy to take existing OpenMP based code and port to Phi
NAG and Intel Xeon-Phi
Tuning for Phi takes some learning and expertise
… but feedback into Xeon code is often very strong
Performance Issues As always, need large enough problems to make the offload
worthwhile
Seem to have some start-up issues
NAG Library Linux implementation release imminent, early access can be arranged.
31
0
50
100
150
200
250
300
350
400
450
0 5000 10000 15000 20000 25000 30000
Tim
e (
s)
Problem Size (n)
Distance Matrix (g03ea)
32 threads original Phi offload original Phi offload opt 32 threads opt
n=30k; m=3k
Xeon 32t: 192s
Xeon 32t*: 75.7s
Phi 240t*: 40.6s
Phi gain ~5x over
original or ~2x over
optimised
32
0.00
0.20
0.40
0.60
0.80
1.00
1.20
1.40
1.60
100 10,000 1,000,000 100,000,000
Tim
e (
s)
Size of problem (n, log scale)
Uniform RNG - Mersenne Twister (g05sa)
8 threads original Native Phi original Native Phi opt 8 threads opt
n=500m
Xeon 8t: 0.25s
Phi 240t:1.50s
Xeon 8t*: 0.22s
Phi gain ~3x
33
To get acceleration look at the algorithms
0
50
100
150
200
250
300
350
50 100 150 200
Runti
me (
s)
Number of inputs (size of Delta)
5000 gradient evaluations of LIBOR Market Model*
using finitedifferences(bumping)
using adjoints
2nd-orderadjoints(projectedHessian)
*M.B. Giles and P.
Glasserman. `Smoking
adjoints: fast Monte Carlo
Greeks', RISK, January
2006
34
To get acceleration look at the algorithms
Adjoint AD reduces Runtime
With Prof. Uwe Naumann & RWTH Aachen University we are delivering Algorithmic Differentiation (AD) tools and services to the finance community for C and C++ codes.
Our example codes include
LIBOR Market Model
PDE based Local Volatility model
35
NAG Introduction
NAG for HPC Finance
Why Quants Love NAG
Accelerators NVIDIA
Intel Xeon-Phi
Algorithmic Differentiation
Summary
Agenda
36
NAG is keen to collaborate in building models and risk engines
Requirements are likely to be varied across FSI
We want to make sure we have what you need
The importance of HPC Finance is growing and will involve a LOT of computation (Basel III, CVA,…)
NAG has significant experience in HPC libraries, services, consulting and training
We know how to do large scale computations efficiently
This is non-trivial! Our expertise has been sought out and exploited by organisations such as (AMD, HECToR, Microsoft, Oracle, major banks, major oil & gas cos,…….)
HPC Finance - Summary