Skip to content

Benchmarks

This page compares fortvine, used from Fortran, Python and R, with three other vine-copula packages on identical data:

  • fortvine three ways: the native Fortran library, the Python package and the R package. Both packages call the same compiled library, so their columns show what a user of each language actually gets;
  • pyvinecopulib 1.0.1 and rvinecopulib 0.7.2.1.0: the Python and R bindings of vinecopulib (C++), the reference implementation that fortvine's conventions follow;
  • torchvine 0.2.2: a pure-PyTorch reimplementation of the pyvinecopulib API (CPU build of PyTorch 2.15).

All numbers on this page come from bench/run_bench.py (with bench/bench_r.R for the R packages); the raw results are in bench/results/results.json. You can reproduce them on your own machine (see the end of the page).

Set-up

machine Intel Core (Raptor Lake, 32 logical CPUs), Windows 11
fortvine (Fortran) gfortran 16.1 (WinLibs), -O3 -march=native -funroll-loops -fopenmp
Python side Python 3.14.0, NumPy 2.5.5; fortvine built by pip install ./python (gfortran 16.1, -O3 -funroll-loops); pyvinecopulib 1.0.1 (PyPI wheel); torch 2.15.0+cpu, torchvine 0.2.2
R side R 4.3.2; fortvine built by R CMD INSTALL with Rtools43 (gfortran 12.3, R's default flags); rvinecopulib 0.7.2.1.0 (CRAN binary)
family set the 12 families all libraries share: independence, Gaussian, Student t, Clayton, Gumbel, Frank, Joe, BB1, BB6, BB7, BB8, Tawn (torchvine has no Tawn) — with rotations
criterion BIC everywhere
threads "one thread" runs pin every library to one thread (FORTVINE_THREADS=1, num_threads=1, cores = 1, torch.set_num_threads(1))

Data. Pair-copula data are simulated with pyvinecopulib from each family at Kendall's \(\tau \approx 0.5\) (\(n = 5000\)). Vine data come from a heavy-tailed, skewed two-factor model turned into pseudo-observations (\(n = 2000\), \(d = 5, 10, 20\)), so that no library's own model class generated them. The R packages read the same files.

Timing. Wall-clock means after a warm-up call (a call longer than 2 s is timed once). The Python and R timings include the call overhead of the bindings. Every timed process is exempted from Windows 11's power throttling: Windows moves a process without a window to the efficiency cores after about two seconds of work, which slowed long calls by a factor of about 1.6 in a first run and would have favoured whichever library finishes quickly.

Results

Vine selection time against dimension, one and eight threads

Pair-copula fit and selection times per family

Colour marks the library (blue fortvine, green vinecopulib, gold torchvine) and the marker the language (circle Fortran, square Python, triangle R). Both time axes are logarithmic; the fortvine Fortran and Python markers mostly lie on top of each other.

Time of every library relative to native fortvine for seven tasks

Time relative to fortvine called from Fortran, one thread: geometric mean over the 11 families (pair tasks) or the three dimensions (vine tasks). The dashed line is native fortvine; points to the right are slower.

The full tables follow.

Table 1. Evaluation of the density \(c(u,v)\): time per point [ns], one thread, \(n = 10^6\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
Gaussian 21 20 66 85 155 35
Student \(t\) 301 323 670 187 310 145
Clayton 43 39 160 66 110 39
Gumbel 60 57 200 114 275 162
Frank 29 26 143 55 180 17
Joe 51 50 195 90 280 127
BB1 105 103 340 156 340 189
BB6 122 116 430 274 970 234
BB7 104 103 390 156 350 233
BB8 87 85 360 123 127 195
Tawn 154 152 390 201 420 —

Table 2. Evaluation of the \(h\)-function \(h_1(v\mid u)\): time per point [ns], one thread, \(n = 10^6\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
Gaussian 61 62 127 72 165 29
Student \(t\) 441 479 940 251 400 690
Clayton 53 50 225 104 100 55
Gumbel 79 78 265 111 165 64
Frank 30 27 140 93 305 13
Joe 71 69 320 161 470 88
BB1 119 113 420 245 560 125
BB6 129 127 500 319 810 135
BB7 114 114 470 246 710 116
BB8 94 93 400 189 230 80
Tawn 156 154 430 154 265 —

Table 3. Evaluation of the inverse \(h_1^{-1}(w\mid u)\): time per point [ns], one thread, \(n = 10^6\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
Gaussian 30 31 60 68 140 28
Student \(t\) 352 376 770 463 710 701
Clayton 41 39 190 71 133 48
Gumbel 160 158 380 209 240 725
Frank 22 21 100 2917 10490 15
Joe 336 350 1040 281 600 1263
BB1 752 756 2700 8282 19080 1691
BB6 862 869 3250 11101 27650 2000
BB7 767 784 3030 8461 24360 1613
BB8 582 592 2520 6188 8050 1364
Tawn 1010 1011 2590 5070 9190 —

Table 4. Maximum-likelihood fit of the true family: time [ms], one thread, \(n = 5000\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
Gaussian 1.08 0.82 1.77 4.06 8.33 0.23
Student \(t\) 21.12 22.78 48.00 154.94 309.00 19.03
Clayton 1.45 1.22 4.76 3.34 11.03 0.21
Gumbel 1.59 1.38 3.41 5.29 19.38 0.22
Frank 1.30 1.11 3.06 2.79 8.38 0.36
Joe 1.23 1.06 2.83 4.44 14.76 0.22
BB1 4.49 4.63 11.85 32.75 84.00 33.56
BB6 9.47 8.93 23.08 64.28 263.00 47.91
BB7 5.00 5.19 14.55 29.68 127.00 36.07
BB8 18.84 19.18 53.00 38.12 143.00 39.23
Tawn 8.14 8.73 20.00 38.56 333.00 —

Table 5. Maximised log-likelihood \(\hat\ell\) of the fit in Table 4, and the difference \(\Delta\ell = \hat\ell_{\mathrm{lib}} - \hat\ell_{\mathrm{fortvine}}\).

\(\hat\ell\) fortvine \(\Delta\ell\) fortvine (Python) \(\Delta\ell\) fortvine (R) \(\Delta\ell\) pyvinecopulib \(\Delta\ell\) rvinecopulib \(\Delta\ell\) torchvine
Gaussian 1683.53 0.00 0.00 0.00 0.00 -0.01
Student \(t\) 1806.78 0.00 0.00 0.00 0.00 -0.11
Clayton 2112.84 0.00 0.00 0.00 0.00 -8.51
Gumbel 1835.76 0.00 0.00 0.00 0.00 -0.51
Frank 1539.56 0.00 0.00 0.00 0.00 -23.71
Joe 2202.32 0.00 0.00 0.00 0.00 -12.77
BB1 1554.86 0.00 0.00 0.00 0.00 0.00
BB6 2048.42 0.00 0.00 0.00 0.00 0.00
BB7 1928.69 0.00 0.00 0.00 0.00 0.00
BB8 1347.72 0.00 0.00 0.00 0.00 0.00
Tawn 1571.08 0.00 0.00 0.00 0.00 —

Table 6. Selection among the 12 common families and their rotations (BIC): time [ms], one thread, \(n = 5000\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
Gaussian 53.1 50.4 136.7 1006.1 2910.0 419.0
Student \(t\) 78.6 75.6 200.0 827.3 2690.0 420.6
Clayton 75.6 73.8 195.0 978.1 2140.0 530.2
Gumbel 83.6 84.7 230.0 805.5 2270.0 419.6
Frank 51.0 48.8 136.7 892.7 3110.0 408.3
Joe 76.4 75.9 195.0 987.8 2270.0 811.9
BB1 77.5 79.1 220.0 908.7 2230.0 388.2
BB6 86.4 88.5 225.0 829.4 2190.0 474.8
BB7 78.8 81.5 220.0 821.3 1940.0 407.8
BB8 88.5 88.3 235.0 945.7 2400.0 415.5
Tawn 99.6 99.9 265.0 676.4 2250.0 424.0

Table 7. Family chosen by BIC in Table 6 (true family in the first column).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
Gaussian Gaussian Gaussian Gaussian Gaussian Gaussian Gaussian
Student \(t\) Student \(t\) Student \(t\) Student \(t\) Student \(t\) Student \(t\) Student \(t\)
Clayton Clayton Clayton Clayton Clayton Clayton BB7
Gumbel Gumbel Gumbel Gumbel Gumbel Gumbel Gumbel
Frank Frank Frank Frank Frank Frank Frank
Joe Joe Joe Joe Joe Joe BB6
BB1 BB1 BB1 BB1 BB1 BB1 BB1
BB6 BB6 BB6 BB6 BB6 BB6 BB6
BB7 BB7 BB7 BB7 BB7 BB7 BB7
BB8 BB8 BB8 BB8 BB8 BB8 BB8
Tawn Tawn Tawn Tawn Tawn Tawn BB6

Table 8. Regular-vine selection (Dissmann, BIC): time [s], \(n = 2000\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
\(d = 5\), 1 thread 0.477 0.482 1.280 3.553 8.780 1.643
\(d = 5\), 8 threads 0.117 0.082 0.235 0.666 1.990 —
\(d = 10\), 1 thread 2.100 2.124 5.760 18.316 40.630 5.916
\(d = 10\), 8 threads 0.344 0.326 0.910 3.607 8.210 —
\(d = 20\), 1 thread 8.754 8.946 24.190 84.577 174.080 —
\(d = 20\), 8 threads 1.228 1.229 3.330 14.916 29.840 —

Table 9. Log-likelihood \(\hat\ell\) of the selected vine, \(n = 2000\).

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
\(d = 5\), 1 thread 2213.9 2213.9 2213.9 2213.9 2213.9 2184.6
\(d = 5\), 8 threads 2213.9 2213.9 2213.9 2213.9 2213.9 —
\(d = 10\), 1 thread 4675.3 4675.3 4675.3 4675.3 4675.3 4622.4
\(d = 10\), 8 threads 4675.3 4675.3 4675.3 4675.3 4675.3 —
\(d = 20\), 1 thread 11702.1 11702.1 11702.1 11702.1 11702.1 —
\(d = 20\), 8 threads 11702.1 11702.1 11702.1 11702.1 11702.1 —

Table 10. Vine density on the \(n = 2000\) sample: time [ms].

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
\(d = 5\), 1 thread 1.54 1.57 5.77 4.40 15.50 3.36
\(d = 5\), 8 threads 0.46 0.37 1.10 1.97 2.77 —
\(d = 10\), 1 thread 5.57 5.75 20.67 21.47 56.67 20.40
\(d = 10\), 8 threads 0.97 0.91 3.26 5.74 9.68 —
\(d = 20\), 1 thread 17.38 17.40 66.00 64.56 195.00 —
\(d = 20\), 8 threads 2.86 2.52 9.38 13.20 32.00 —

Table 11. Simulation of \(n = 2000\) draws from the selected vine: time [ms].

fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib torchvine
\(d = 5\), 1 thread 7.15 7.28 25.38 56.46 195.00 14.03
\(d = 5\), 8 threads 1.18 1.07 3.83 10.36 28.18 —
\(d = 10\), 1 thread 14.69 14.86 51.43 236.93 810.00 38.47
\(d = 10\), 8 threads 2.13 2.14 8.11 38.98 116.67 —
\(d = 20\), 1 thread 38.67 39.22 130.00 633.95 2170.00 —
\(d = 20\), 8 threads 5.86 5.39 19.38 102.25 330.00 —

What the numbers say

Same answers. Where the libraries fit the same model, fortvine (from any language), pyvinecopulib and rvinecopulib reach the same maximum: the log-likelihoods of every pair fit and every selected vine agree to the digits shown, and all five select the true family for every simulated pair. This is by design — fortvine reproduces vinecopulib's rotations, structure arrays, candidate pre-selection and Dissmann algorithm — and it makes the speed comparison a like-for-like one. torchvine estimates one-parameter families by inverting Kendall's \(\tau\), which is why its fits are the fastest in Table 4 and its maxima lower (by 0.01 to 24 log-likelihood units); its selection picks a different family for the Clayton, Joe and Tawn samples (it has no Tawn family) and its vines have lower likelihoods.

From Python, fortvine is as fast as from Fortran. The Python package passes NumPy arrays to the library without copies, and its timings agree with the native ones within the run-to-run noise in every table (geometric mean 1.0 in the figure above): the Python user gets the library's full speed.

From R, the toolchain costs a factor of about 2.7. The R package itself adds almost nothing: the native benchmark program compiled with R's compiler (Rtools43, gfortran 12.3) selects the \(d = 5\) vine in 1.31 s, the same as the R package, against 0.48 s with gfortran 16.1, and -O3 -march=native do not change it. The difference is the older compiler and its MinGW runtime on Windows; R on Linux and macOS uses other toolchains. Even so, fortvine from R selects vines 7–9× faster than rvinecopulib, selects pair copulas 8–23× faster and fits them 2–17× faster.

Pair-copula evaluation. The density is 1.3–4× faster than pyvinecopulib's for every family except Student t, where pyvinecopulib is faster (187 against 301 ns per point; fortvine evaluates the Student t density through the regularised incomplete beta function). The largest gaps are in the inverse h-function: fortvine inverts h with closed forms where they exist and with a safeguarded Newton step that uses the density as the exact derivative elsewhere, so the BB1, BB6, BB7, BB8 and Tawn inversions run in 0.6–1.0 µs per point against 5–11 µs, and the Frank inversion (closed form) in 22 ns against 2.9 µs; Joe's inversion is the exception (336 against 281 ns). torchvine, vectorised by PyTorch, is the fastest for a few simple families (Frank, Gaussian, Student t density).

Fitting. A maximum-likelihood fit of a known family is 2–7× faster than pyvinecopulib's (1–21 ms against 3–155 ms at \(n = 5000\)). Exact parameter scores from dual numbers let Newton/BFGS converge in a few steps, and large samples are fitted in two stages (a subsample first, then a short polish on all data).

Selection. Choosing among the 12 families and their rotations takes 50–100 ms in fortvine and 0.7–1.0 s in pyvinecopulib — 7–19× faster. Candidate pre-selection, racing (a cheap bound decides whether a candidate can still win before it is polished) and the shared closed-form kernels account for this.

Vines. Selecting a regular vine is 7–10× faster than pyvinecopulib on one thread and 6–12× faster on eight, with identical log-likelihoods. Density evaluation is 3–6× faster and simulation 8–18× faster. On eight threads a 20-dimensional vine is selected in 1.2 s.

d threads fortvine (Fortran) fortvine (Python) fortvine (R) pyvinecopulib rvinecopulib
5 1 0.48 s 0.48 s 1.28 s 3.55 s 8.78 s
10 1 2.10 s 2.12 s 5.76 s 18.3 s 40.6 s
20 1 8.75 s 8.95 s 24.2 s 84.6 s 174.1 s
5 8 0.12 s 0.08 s 0.24 s 0.67 s 1.99 s
10 8 0.34 s 0.33 s 0.91 s 3.61 s 8.21 s
20 8 1.23 s 1.23 s 3.33 s 14.9 s 29.8 s

Read these numbers with care

Benchmarks measure one machine, one operating system and one set of data. pyvinecopulib and rvinecopulib were run from their PyPI wheel and CRAN binary on Windows; native Linux builds may be faster, and so may the fortvine R package on Linux or macOS. torchvine is designed for GPUs and autograd, and its CPU timings do not show what it is built for. The scripts are in the repository so you can check the comparison on your own hardware.

Beyond speed

fortvine vinecopulib (py / r) torchvine
language Fortran 2008 + OpenMP; Python and R packages C++17 (Python and R bindings) Python / PyTorch
dependencies compiler only Eigen, Boost (header-only), pybind/nanobind or Rcpp PyTorch
parametric families 108 11 10
asymmetric families 32 (Tawn, asymmetric EV, Archimax, Khoudraji) 1 (Tawn) 0
nonparametric families TLL, Bernstein TLL TLL
family rotations yes yes yes
exact parameter gradients dual numbers, every family analytic (1.0) autograd
discrete / mixed margins yes yes yes
observation weights yes yes yes
truncation / threshold by mBICv yes yes yes
non-simplified (covariate-dependent) edges yes (relax) — —
GPU no no yes
C ABI yes C++ API —

Every feature in the fortvine column is available from Fortran, C, Python and R.

Reproducing

bash build.sh bench                       # builds build/fv_bench
python -m venv .venv && . .venv/bin/activate
pip install numpy pyvinecopulib torch torchvine pytorch-minimize ./python
R CMD INSTALL r                           # the R part (optional):
Rscript -e 'install.packages(c("rvinecopulib", "jsonlite"))'
python bench/run_bench.py --rscript Rscript   # about an hour; --quick for a short run

The script writes bench/results/results.json and bench/results/tables.md (included above); python tools/figures.py bench redraws the three figures.