Back to Benchmarks

Monte Carlo GBM Risk Simulation

11/25/2025
5 min read
By RunMat Team

Geometric Brownian Motion (GBM) is a staple in intraday risk and options pricing. At realistic scales (millions of paths, hundreds of steps), throughput wins matter. This benchmark compares RunMat against NumPy, and PyTorch for a batched GBM simulation with a simple call option payoff.

We simulate M paths over T steps:

S ← S .* exp((μ − ½σ²)Δt + σ√Δt · Z),    Z ~ N(0, 1)
payoff = max(S − K, 0)
price  = mean(payoff) · exp(−μ T Δt)

Results

RunMat is up to 131x faster than NumPy

Monte Carlo Perf Sweep

Paths (simulations)RunMat (ms)PyTorch (ms)NumPy (ms)NumPy ÷ RunMatPyTorch ÷ RunMat
250k108.58824.424,065.8737.44×7.59×
500k136.10900.118,206.5660.30×6.61×
1M188.00894.3216,092.4985.60×4.76×
2M297.651,108.8032,304.64108.53×3.73×
5M607.361,697.5979,894.98131.55×2.80×

250k = 250,000 paths, 1M = 1,000,000 paths, etc.


Core implementation in RunMat (MATLAB-syntax)

rng(0);
M = 10_000_000; T = 256;
S0 = single(100); mu = single(0.05); sigma = single(0.20);
dt = single(1.0/252.0); K = single(100.0);

S = ones(M, 1, 'single') * S0;
sqrt_dt = sqrt(dt);
drift = (mu - 0.5 * sigma^2) * dt;
scale = sigma * sqrt_dt;

for t = 1:T
  Z = randn(M, 1, 'single');
  S = S .* exp(drift + scale .* Z);
end

payoff = max(S - K, 0);
price  = mean(payoff) * exp(-mu * T * dt);
fprintf('RESULT_ok PRICE=%.6f\n', double(price));

Full sources:


Why RunMat is fast (accelerate + fusion)

RunMat fuses elementwise stages and keeps tensors resident on device between steps, while random number generation and updates execute in large, coalesced kernels—a strong fit for GPUs. For the big picture on fusion and residency, see the Introduction to RunMat on the GPU document.


Reproduce the benchmarks

See the benchmarks directory in the RunMat repo on GitHub for the full source code and instructions to reproduce the benchmarks: runmat-org/runmat/benchmarks.

Enjoyed this benchmark? Join the newsletter

Monthly updates on RunMat, Rust internals, and performance tips.

Ready to try RunMat?

Get started with the modern MATLAB runtime today.