Benchmarks

What the numbers say

Measurements behind the claims of this site: how fast the solver is, how many evaluations the gradient method saves, how much faster the packages became since the first release, when to hand over from SMO to Newton's method, and what shrinking and the stopping criterion do inside the solver. The holdout and training subset study compares tuning time and test quality.

All numbers come from the scripts in the repositories and were measured on a shared 12-core Linux machine (single process unless stated). Treat the absolute times as indicative; the ratios are what matters. The data sets are synthetic or small public ones, so the results say nothing about every problem.

Solver

On par with LIBSVM

smo-solver solves the same problems as LIBSVM (scikit-learn's SVC andSVR, same tolerance) and agrees with it to about 10⁻³ in the decision values. The numbers below each pair of bars are the time ratio smo-solver / LIBSVM.

10 features, RBF kernel, γ = 0.1, C = 100 (narrow screens: C = classification, R = regression). Classification needs the same number of steps as LIBSVM; for ε-regression with n = 5000 the solver runs 387,707 steps against 304,960 and is 18 % slower. The extra steps are not wasted: at equal duality gap the two working-set rules need the same number of steps, the default rule just stops later.

Solver internals

Shrinking

Shrinking removes variables that sit at a bound from the active set, so every step touches fewer entries; before the solver stops, the full problem is restored and checked again, so the result does not depend on the heuristic (Sec. 7.10 of the thesis). The thesis leaves its parameters open; this study sets them.

Classification
ε-regression (n counts samples; 2n variables)

Time without divided by time with shrinking, current defaults. The gain grows with the problem size and with the requested accuracy (tolerance 10⁻⁵ at n = 10 000: 2.5×), as in the thesis (Fig. 10.2.11). The results are identical; the solver restored the full problem once (twice for a few regression runs) before terminating.

Classification, n = 5000, tolerance 10⁻⁵
ε-regression, n = 2000, tolerance 10⁻³

Relative time over the exponent η and the factor c of the threshold c · rη (1.0 = fastest cell; r is the violation measure). Neither value is critical as long as c is not far below 1: with c = 0.1 variables are removed too early and have to return (twice the steps), with a large c shrinking comes too late.

Over 24 settings (classification n = 5000, ε-regression n = 2000, three kernel widths, two λ, two tolerances). The exponent η = 1 (threshold = the violation itself, as in LIBSVM) is faster than the thesis' η < 1, mainly for regression. The remaining slow cases had a narrow kernel: nearly every sample is a support vector, nothing can be shrunk, and the restoration of the full problem cost up to 60 % extra. Skipping attempts that remove at most 10 % of the active set fixes that.

Solver internals

What the tolerance means

The solver stops when the violation r (the largest gradient difference of a violating pair, scaled like in LIBSVM) drops below the tolerance. Is that a good measure? Every point is one iterate of one of 12 runs; the vertical axis is the largest deviation of the decision function from the exactly solved problem.

The dashed line is y = x. The violation tracks the error of the predictions almost one-to-one — a tolerance of 10⁻³ means decision values accurate to about 10⁻³ — and the bound-aware measure of the thesis (Def. 7.21) gives the same picture: the two agree to about 10 %. The duality gap grows with the number of samples and is a much looser guide (the spread is 2.7 decades against 0.6): a gap threshold that guarantees an accuracy of 10⁻³ is 2·10⁻⁵. The dual objective converges quadratically and says even less about the predictions. Raw data and the script: benchmarks/stopping_study.py in smo-solver.

Solver internals

Working set selection

A classical SMO step picks two variables. Five pair-selection rules were compared on the checkerboard problem (n = 1000, hinge loss, Gaussian kernel): the maximal violating pair (MVP, Def. 7.6), its bound-aware variant (baMVP, Def. 7.21), the second-order rules that keep the first index of the MVP and choose the partner with the largest predicted decrease, ignoring the bounds (MuDP, Def. 7.27, as in LIBSVM) or respecting them (MDP, Def. 7.28), and the pair of largest decrease over all pairs (tMDP, Def. 7.29, O(n²) per step). The curves show the best value reached so far; the base setting is λ = 10⁻³, γ = 30 (Sec. 10.2.1–10.2.3).

Violation r (the stopping measure)
Duality gap

SMO steps until r ≤ 10⁻⁸ (large) and r ≤ 10⁻⁵ (small); fewest steps of the four complete runs in bold. The tMDP runs stopped at r ≤ 10⁻⁶ or after 20 000 steps (dash: not reached). The second-order rules MuDP and MDP need 6–16× (MuDP) and 6–15× (MDP) fewer steps than MVP for r ≤ 10⁻⁸ and 5–15× / 5–14× for r ≤ 10⁻⁵, at a few microseconds per step (2.3 µs for MVP, 2.8 µs for MDP in the base setting; indicative, the machine was loaded). That is why md is the solver's default. MDP and MuDP are practically equal: the step counts differ by at most 12 %, and neither is consistently ahead (5 of 8 comparisons favour MuDP), unlike the single example in the thesis.

tMDP saves only 1.2–1.5× steps compared with MDP, but a step costs 291 times as much in the NumPy reference, so it is unusable. baMVP behaves like MVP in the gap and in r◇/λ (the same step counts to within about 13 % at r ≤ 10⁻⁸), but the plain r stays large for a long time: r ≤ 10⁻³ takes 178,676 steps against 60,716 for MVP in the base setting. For MVP, MuDP and MDP the two measures coincide: r◇/λ = r (median ratio 1.00). baMVP and tMDP ran in a NumPy reference SMO, which reproduces the Rust iterates to better than 10⁻¹⁰ (identical MVP path for 2,000 steps; MuDP/MDP until ties of about 10⁻¹³ in the gradient pick another pair). Times are not compared: step counts do not depend on the machine. The gap here uses the midpoint bias of the thesis (Obs. 7.4). Raw data: benchmarks/working_set_study.py in smo-solver.

Beyond pairs

Joint working sets: fewer steps can cost more

The solver in smo-solver 0.2.0 can jointly optimize up to 64 dual variables withworking_set_size. Each block solves a local quadratic problem with the box, sum and optional 1-norm constraints together. It can move both regression sign groups at once, instead of alternating small pair steps. The default stays at two variables.

Minimum of three sequential release-build runs on one shared machine, with one Rayon thread. † The four-variable moderate ν-SVR value is one additional run with a 20 s limit: the three 10 s runs stopped just short of the target. The saved case drops from1,744,616 pair steps to 33 four-variable updates. Size 16 covers all ten dual variables there, so its one-step result is a full local solve. On the moderate ν-SVR, sizes 8 and 16 are 2.1× and 2.8× faster. On ordinary SVC/SVR, the dense block overhead outweighs the reduced step count.

There is a harder case too: ν-SVR with n = 1000 and λ = 10⁻⁴ stopped at the 10 s limit forevery tested size. Size 16 left a smaller gap, but none reached the target; these censored runs are not counted as successful speed-ups. This is an optional tool for difficult problems, rather than a generally faster replacement for pairs.

Does the gain survive hyperparameter optimization?

Complete fits include three-fold CV, the normal rough SMO stage, Newton refinement, exact hypergradients and the final full-data fit. With n = 180, the active-bound ν-SVR also benefits; ordinary classification is about unchanged. Each optimum was verified with fresh cold CV folds.

All optimizations converged and the CV errors agree across block sizes to roundoff. This comparison exposed and corrected an existing SMO–Newton transition bug: a projected warm start could incorrectly mark the norm constraint inactive. Post-Newton activity checks now keep the fold solutions feasible. The pre-fix HPO records are excluded from this table.

solve_regression(x, y, lam=0.01, working_set_size=8)
OptimizedSVR(smo_options={"working_set_size": 8})

Values 2–64, including odd sizes, are supported; a small problem may use fewer variables. The pair-selection rule still chooses the seed pair. Steps, callback periods and iteration budgets count outer block updates, so compare wall time and final accuracy, not step counts alone. Kernel products, KKT violations, gaps and held-out predictions were recomputed outside timing. Reproduce from benchmarks/block_working_sets.py and benchmarks/block_hpo.py in smo-solver; copied raw records and build provenance are in this site's data/benchmarks/block*. The page summary is generated by scripts/make_block_benchmark_data.py. Joint blocks are available in smo-solver 0.2.0; the HPO option requires optimized-svm 0.6.0.

Solver internals

How SMO converges

Along one MDP run on the base problem (no shrinking), the violation r is compared with four other measures (Sec. 10.2.4, Fig. 10.2.6). The gap, the step length τ̃ and the distance Dk to the solution are proportional to r; the decrease Δψ of the dual objective is proportional to r². Each point is one iterate.

Hinge loss, λ = 10⁻³, γ = 30
Smoothed hinge, δ = 1/4, λ = 10⁻³

Dotted: c·rp with c the geometric mean of v / rp for 10⁻⁹ ≤ r ≤ 10⁻³; the slope in the legend is the fitted local exponent. For the smoothed hinge (Fig. 10.2.8) the gap becomes quadratic in r (slope 2.00), while τ̃ and Dk stay linear (slopes 1.00 and 1.00); the same holds for λ = 10⁻² and 10⁻¹.

The factor c(λ) in v ≈ c(λ)·rp (p = 1 for gap, τ̃ and r̃, p = 2 for Δψ) for nine values of λ (Fig. 10.2.7). Fitted here: gap ≈ 4.39 λ^0.006·r, τ̃ ≈ 1.14 λ^0.936·r, Δψ ≈ 0.379 λ^0.968·r², r̃ ≈ 0.666 λ^0.032·r. The thesis found gap ≈ 5.770 λ−0.04 r, τ̃ ≈ 1.648 λ0.958 r, Δψ ≈ 0.427 λ0.989 r², r̃ ≈ 0.707 λ0.014 r. The exponents agree: the gap and r̃ hardly depend on λ, τ̃ and Δψ are proportional to λ. The prefactors differ somewhat; r ≈ 0.24·gap here against 0.173 in the thesis (here the gap is minimised over the bias, in the working-set study above it uses the midpoint bias, so the constants differ slightly between the two sections).
Hinge loss
Smoothed hinge, δ = 1/4

Support vectors and free variables (strictly between the bounds) at the solution, n = 1000 (Fig. 10.2.9). The number of support vectors grows with λ. For the hinge loss the free variables stay almost constant (45–57 for λ ≤ 0.3, the rest sits at the upper bound); for the smoothed hinge they grow (50 at λ = 10⁻⁵ to 217 at λ = 1).

Steps to r ≤ 10⁻⁸
Time with shrinking (minimum of 3 runs)

Size dependence for n = 1000 … 50 000 (Fig. 10.2.12), tolerance 10⁻⁸, default shrinking; the exponent of a fitted power law ne is in the legend. Time grows like n0.9–1.4 (thesis: n1.6), the number of steps like n0.5–1.4 (thesis: n0.6), and the number of free variables hardly at all (n0.1). There is one problem per n, so the step counts are noisy and not monotone. Even 50,000 samples take at most 4.2 s. Times come from a loaded machine and are indicative only. Raw data and script: benchmarks/convergence_study.py in smo-solver.

Solver internals

First-order methods for the primal problem

Chapter 8 starts with gradient descent (Alg. 8.2.1) and preconditioned gradient descent (Alg. 8.3.1) on the primal problem in z = (α, b). Sec. 10.3.1 shows how slowly they converge. The study was repeated on the checkerboard problem (n = 1000, γ = 30, λ = 10⁻³) with the smoothed hinge loss δ = 1/4, the line search of the thesis (η₀ = λ, η = 1/10, σ = 1/10) and z⁰ = 0. The preconditioner is W = diag(I, λ⁻²), the second variant uses W = I. These methods exist only in the benchmark script; the library does not contain them. The reference solution z* comes from a Newton run, SMO is the dual solver at tolerances from 1 down to 10⁻⁸.

Distance ‖z − z*‖ over the iterations (SMO: over its steps, one marker per tolerance)

The first steps are alike, then preconditioning wins by orders of magnitude. Plain gradient descent hardly moves in 1,000,000 steps: the distance stays at 4.4 (start 4.4) and the bias does not move at all (0.232 → 0.231), because the step size (median 1 × 10⁻⁹) is set by the stiff α block. The preconditioned method stops after 366,263 steps at distance 2.4 × 10⁻⁴, when no numerical descent is possible any more (the thesis stopped for the same reason after 282 527 steps). With W = I the bias scaling is missing and the method stays at distance 0.23 after 1,000,000 steps. SMO reaches distance 10⁻³ after 12,850 steps in 0.02 s, the preconditioned method after 312,000 steps in 650 s. These wall times come from a loaded machine; a step costs 0.26 ms when measured alone, which still gives about 80 s, so the ratio is indicative only. SMO continues to 1.6 × 10⁻⁸ in 31,618 steps (0.03 s); none of the primal methods gets there.

Preconditioned GD: measures against ‖F(z)‖
Error of α and of b, with and without the scaling λ⁻²

Error bound (Sec. 10.3.2, Fig. 10.3.2), measured where ‖F‖ < 10⁻² and ψ − ψ* > 10⁻¹¹ (146 records of the preconditioned run). The residual F of the optimality system (6.5.1) bounds the error: ‖F(z)‖ ≈ 0.976·‖z − z*‖ (between 0.975 and 0.977), and ψ − ψ* grows like ‖F‖2.06. The gradient norm is a poor indicator: it fluctuates between 6.6 and 58 times the distance. With the scaling the errors of α and of b decrease together (|b − b*| / ‖α − α*‖ between 0.15 and 0.18); with W = I the bias stays near its start (0.231 against 0.232) and dominates the error (0.231 against 0.0029 for α), which supports the λ⁻² scaling. Counts of steps and the distance are independent of the machine. Raw data and script:benchmarks/primal_first_order.py in optimized-svm.

Solver internals

Newton's method versus SMO

Newton's method for the primal problem (Sec. 8.4) was started from zero on the same checkerboard problem for n = 100 … 40 000, with the smoothed hinge loss δ = 1/4, γ = 30 and four values of λ (Sec. 10.3.3, Fig. 10.3.3, 10.3.4). It is compared with SMO until r ≤ 10⁻⁸ and with the default two-stage train (rough SMO, then Newton from that start). Newton and the two-stage method use a precomputed kernel matrix, which is not included in their times; its cost is the dotted line. SMO computes kernel rows on demand. Every time is the minimum of 3 runs.

Newton iterations from zero over the number of samples

The number of iterations does not depend on n: 13–24 for λ = 10⁻¹ up to 32–88 for λ = 10⁻⁴. Newton's method never failed to converge from zero.

λ = 10⁻¹
λ = 10⁻²
λ = 10⁻³
λ = 10⁻⁴

Time for n = 40,000, fastest in bold (the kernel matrix, not included, takes 24.5 s). Newton's time grows like n1.9–2.2 (fit for n ≥ 1000), quadratic as in the thesis. SMO grows like n1.2–1.4 and is faster than Newton from zero at every size and λ measured here: 1.3–4.1 s against 144–544 s for n = 40,000. This differs from the thesis, where Newton's method was faster for medium sizes; the SMO of the thesis was a Nim prototype, the one here is the Rust solver with shrinking. From n = 20,000 to 40,000 Newton's time grows by a factor 7–16, more than the factor 4 that n² would give. The default two-stage training takes at most 7.2 s for n = 40,000 (20–216× faster than Newton from zero) and ends with the exact Newton solution, whereas SMO stops at r ≤ 10⁻⁸. Compared with SMO alone it is faster in 13 of the 36 cases and at most 4.5 times slower, so the extra accuracy costs little. Single machine under other load (about 8 of 12 cores busy), so times are indicative. The isolated peak at λ = 10⁻², n = 20,000 (SMO 3.2 s, two-stage 7.8 s) is load noise. Raw data and script: benchmarks/newton_vs_smo.py in optimized-svm.

Hyperparameter search

Fixed holdout and short cross-validation

A fixed holdout replaces five inner training and hypergradient solves per evaluation with one. This study compares that shortcut with a short five-fold search and with tuning on fewer training rows before a short five-fold search.

On Breast Cancer Wisconsin, holdout gave a median paired speedup of 4.76×with a median test accuracy difference of −0.88 percentage points. On Diabetes, the corresponding values were 4.24× and +0.724 test RMSE. Full CV and holdout converged on every split. Most short searches reached their iteration budget.

Each dataset uses five paired 80/20 development/test splits and one thread. The fixed holdout reuses the first of the five development folds throughout the search. The outer test set is reserved for scoring the final model. Features of the real datasets are standardized on the full development set before the inner split. All protocols use that same transformation.

Breast Cancer Wisconsin (Diagnostic)

Real data · 569 observations · classification · Dataset source

Median paired differences and ranges relative to full CV
Search protocolSpeedupAccuracy Δ (pp)
Full 5-fold CV5/5 converged1.00×0.357 s0.0098.25% accuracy
Fixed holdout5/5 converged4.76×1.83× to 7.71×−0.88−1.75 to 0.00
Short 5-fold CV0/5 converged · 5 capped1.82×1.39× to 3.42×0.000.00 to +0.88
Subset + short CV (scaled λ)0/5 converged · 5 capped1.41×1.27× to 2.32×0.00−0.88 to 0.00
Subset + short CV (direct λ)0/5 converged · 5 capped1.62×1.04× to 2.27×0.00−0.88 to 0.00

Diabetes

Real data · 442 observations · regression · Dataset source

Median paired differences and ranges relative to full CV
Search protocolSpeedupRMSE Δ
Full 5-fold CV5/5 converged1.00×0.956 s0.00058.159 RMSE
Fixed holdout5/5 converged4.24×1.73× to 7.11×+0.724−3.054 to +1.482
Short 5-fold CV0/5 converged · 5 capped2.64×1.70× to 2.96×+0.029−3.246 to +0.823
Subset + short CV (scaled λ)1/5 converged · 4 capped2.15×1.04× to 3.08×−0.131−3.103 to +0.513
Subset + short CV (direct λ)1/5 converged · 4 capped2.32×1.77× to 3.30×+0.025−0.460 to +0.510

Noisy two moons

Synthetic data · 800 observations · classification

Median paired differences and ranges relative to full CV
Search protocolSpeedupAccuracy Δ (pp)
Full 5-fold CV5/5 converged1.00×0.582 s0.0093.75% accuracy
Fixed holdout5/5 converged3.78×1.34× to 6.04×0.00−1.25 to 0.00
Short 5-fold CV0/5 converged · 5 capped2.04×0.99× to 3.55×0.00−0.62 to 0.00
Subset + short CV (scaled λ)1/5 converged · 4 capped1.61×0.44× to 4.91×0.00−1.25 to +0.63
Subset + short CV (direct λ)1/5 converged · 4 capped0.97×0.35× to 4.32×0.00−0.62 to 0.00

Friedman #1

Synthetic data · 800 observations · regression

Median paired differences and ranges relative to full CV
Search protocolSpeedupRMSE Δ
Full 5-fold CV5/5 converged1.00×4.26 s0.0000.819 RMSE
Fixed holdout5/5 converged3.35×1.34× to 7.07×+0.001−0.011 to +0.029
Short 5-fold CV0/5 converged · 5 capped2.62×1.88× to 5.54×+0.072+0.018 to +0.090
Subset + short CV (scaled λ)1/5 converged · 4 capped1.94×0.85× to 3.33×+0.016−0.001 to +0.053
Subset + short CV (direct λ)0/5 converged · 5 capped1.89×0.87× to 3.48×+0.012−0.002 to +0.034

Reference times and test scores in the full CV rows are medians. Other rows show the median and range of per-split speedups and test score differences against the reference on the same split. Positive accuracy differences are better and negative RMSE differences are better. RMSE is in the original target units. A capped run exhausted its iteration budget in the final tuning stage.

Full CV and fixed holdout allow up to forty L-BFGS-B iterations. Short CV allows five. The subset protocols sample half of the first fold's training rows once, keep its validation rows and tune for up to ten iterations. They pass the selected hyperparameters to a fresh search capped at five iterations on all five folds. The scaled protocol adjusts λ by the training-size ratio and reverses that adjustment before full CV. The direct protocol transfers λ unchanged. Timings include every refit, including the extra refit at the end of subset tuning.

Per-split results (CSV) ·Run log and reproduction command ·Benchmark script

Releases

Faster since the first release

The time of a complete optimization, optimized-svm 0.1.0 with smo-solver 0.1.0 against 0.2.1 with smo-solver 0.1.2, with the same code and data, one BLAS thread. The optimized cross-validation errors are the same.

Abbreviations on narrow screens: cls = classification, SVR = ε-SVR, ARD = one scaling per feature, ν = ε-SVR with ν-bound; the number is n. What changed: kernel columns reused between validation and adjoint system, block gradients without distance matrices, the Cholesky factor of the last Newton step reused, a bug that made warm starts counterproductive for classification fixed, AVX2 loops in the solver, and a new switching rule from SMO to Newton (next section) — which is the main reason for the ν-bound case, where SMO converges very slowly.
The same with the default number of BLAS threads. Matrix factorizations of the size that occurs here ran several times slower with many threads on a busy machine; the new release limits them to one thread.

SMO and Newton

When to hand over

Training runs SMO to a rough tolerance and then refines with Newton's method. Too early and Newton starts from a poor point; too late and SMO wastes steps. The heat maps show the total time relative to the best tolerance of each row (1.0 = best, outlined) for 1000 samples.

Classification
ε-regression

Without SMO (right column) Newton starts at zero and needs many steps. Small λ prefers an earlier hand-over. Over 40 problems (size, λ, kernel width, loss, smoothing, active ν-bound) a tolerance of 0.3 was best on average, and a budget of five outer updates per loss term removes the worst cases. See the study andbenchmarks/smo_newton_switch.py.

Reproduce

Run it yourself

# smo-solver
python benchmarks/bench_vs_libsvm.py --sizes 1000 2000 5000
python benchmarks/working_set_study.py run             # Sec. 10.2.1-10.2.3
python benchmarks/convergence_study.py relations | gzip > convergence_relations.csv.gz   # also: factor, smooth; lambda, size as .csv

# optimized-svm
python benchmarks/hpo_vs_search.py --seeds 3 > hpo_vs_search.json
python benchmarks/hpo_timing.py > timing.json          # once per release, once per BLAS setting
python benchmarks/smo_newton_switch.py --out switch.csv
python benchmarks/primal_first_order.py run --aux --methods ""   # then --methods gd / pgd / pgd_w1 (about 20 min each)
python benchmarks/newton_vs_smo.py run --reps 3 > benchmarks/results/newton_vs_smo.csv

# this site (raw files in data/benchmarks/; the large smo-solver results are thinned first)
python scripts/make_benchmark_data.py --thin ../smo-solver/benchmarks/results ../optimized-svm/benchmarks/results
python scripts/make_benchmark_data.py