Skip to content
Edit this page View source of this page

Benchmarks

Every number on this page is measured when the documentation is built. The deploy workflow installs this commit of Optora, times every ambiguity set on the CPU of the GitHub-hosted runner, compares six of them with an independent reference solver, and renders the charts below. No number is typed in by hand, and the environment table records the machine and software that produced them.

CPU numbers, by design

The documentation runner has no accelerator, so these are CPU timings with the default PyTorch thread count. They show how the cost scales with the support size and the batch size and where host synchronizations occur, not the peak throughput of a device. To measure your own machine, including a GPU, see Reproducing. The paper reproductions record the run times of complete experiments, two of them on a laptop GPU.

Host synchronizations0per KL, chi-square, TV, CVaR, Wasserstein or Sinkhorn worst case, forward and backward
Fastest worst case0.07 msCVaR, batch 16 x 256 float32
Batched throughput248,304 /sCVaR loss vectors of n = 256 per second at batch 16
Agreement with references9.0e-11largest absolute difference relative to the loss spread, float64
Environment
date 2026-11-30 00:44 UTC
optora 0.4.0 (895b5f4)
python 3.12.16
torch 2.15.0+cpu
platform Linux-7.0.0-1020-azure-x86_64-with-glibc2.43
cpu AMD EPYC 9V45 96-Core Processor (4 logical cores, 2 torch threads)
accelerator none (CPU only)
runner GitHub Actions
Ambiguity set Forward (ms) Forward + backward (ms) Host syncs Reference solver Agreement Speedup
KL 1.01 1.09 0 SciPy brentq on the closed-form tilt 1.3e-16 0.1x
chi-square 0.36 0.45 0 closed form (active set) 0.0e+00 3.3x
total variation 0.07 0.14 0 SciPy linprog (HiGHS) 9.0e-17 65.0x
CVaR 0.07 0.10 0 SciPy linprog (HiGHS) 0.0e+00 33.6x
Wasserstein 37.93 38.75 0 SciPy linprog (HiGHS) 1.8e-16 18.6x
Sinkhorn 42.15 42.65 0 separately minimized dual, not timed
MMD 154.22 167.22 20 Clarabel interior point 9.0e-11 0.7x
general phi 20.66 22.41 4 separately minimized dual, not timed

The largest support in the scaling sweep is n = 4096. The general phi set runs a fixed-step dual solve of 200 iterations and checks convergence every 50 iterations. Each check is one host synchronization.

Latency by ambiguity set

The chart times one call of worst_case_expectation on a batch of float32 loss vectors, the shape one training step produces. It shows the forward pass alone and together with the backward pass, which returns the worst-case distribution. The KL, \(\chi^2\), total variation, CVaR, Wasserstein and Sinkhorn sets run a fixed sequence of kernels. Its length is known before the solve starts, from the dtype, the shape of the problem and the device, as Mathematical formulations explains. MMD runs an interior-point method to a duality gap of \(10^{-10}\), and the general \(\varphi\) set runs an injected fixed-step dual solver for its full iteration budget.

Median wall time of the worst-case expectation per ambiguity set, forward and with backward Median wall time of the worst-case expectation per ambiguity set, forward and with backward
Median over repeated calls after warm-up. The backward pass adds little time because, by Danskin's theorem, the gradient is the maximizer that the forward pass has already found, so autograd does not differentiate through the solve.

Scaling with the support size

This chart times the same sets on a single loss vector as the support grows. KL, \(\chi^2\), total variation and CVaR read each scenario a fixed number of times per solve. Wasserstein and Sinkhorn evaluate an \(n \times n\) cost or kernel matrix at every step. MMD factors an \(n \times n\) matrix at every interior-point iteration, which limits the support sizes it is swept over.

Median wall time against the support size for every ambiguity set Median wall time against the support size for every ambiguity set
Both axes are logarithmic. A flat start means that kernel launches dominate the cost, and the slope on the right reflects the arithmetic cost of the solve.

Batched throughput

worst_case_expectation takes a loss of shape (..., n) and solves every leading element in one joint, vectorized call. The chart counts how many loss vectors per second that call completes as the batch grows. The per-call overhead is paid once per call, so throughput rises until the arithmetic dominates.

Loss vectors solved per second against the batch size Loss vectors solved per second against the batch size
Placing a radius sweep, a set of seeds or a minibatch of problems in the leading dimension amortizes the per-call overhead over the whole batch.

Against independent reference solvers

The test suite checks every ambiguity set against a reference that shares no code with Optora. Total variation, CVaR and Wasserstein are compared with exact linear programs solved by SciPy's HiGHS, KL with SciPy root finding on its closed-form tilt, \(\chi^2\) with an active-set closed form, and MMD with Clarabel's interior-point method on the same cone program. These six references are timed here on one float64 instance, and the difference of each pair of values is reported relative to the loss spread. Sinkhorn and the general \(\varphi\) set are checked in the tests against a separately minimized dual in NumPy and SciPy, which is not timed here.

Wall time of Optora and of the independent reference solver per ambiguity set Wall time of Optora and of the independent reference solver per ambiguity set
On a single small problem a scalar closed form in NumPy can be faster than Optora, whose cost there is dominated by kernel launches. The ratio above each pair is the reference time divided by the Optora time, and the difference below it is limited by float64 rounding or by the tolerance of the reference solver.

Host synchronizations

A device-to-host synchronization happens when a tensor is read back as a Python value. The host then waits until the device has finished all queued work. The table above counts the conversions of a tensor to a Python bool, int or float, which is how such a read happens in a solver loop. The KL, \(\chi^2\), total variation, CVaR, Wasserstein and Sinkhorn sets perform none, forward or backward, because their trip count is fixed by the dtype, the shape and the device rather than by a convergence flag. The MMD interior-point method and the general \(\varphi\) dual check convergence every check_interval iterations, and each check is one synchronization. The test suite asserts these counts as exact budgets on every platform in CI, so a change that adds a synchronization fails the build.

Reproducing

The benchmarks and their charts are produced by one command from a development install.

pip install -e ".[dev,docs,tutorials]"
python -m tools.figures --only benchmarks-data benchmarks-charts

Pass --device cuda to time an accelerator. The raw measurements are written to docs/assets/figures/benchmarks-results.json next to the charts. Separately, the pull-request guard in tests/benchmarks/ compares the timing of each commit against its base with pytest-benchmark, as described in CONTRIBUTING.md.

Raw results of this build (JSON)