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.
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.
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.
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.
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).
| rule | λ = 10⁻³, γ = 30 | λ = 10⁻² | λ = 10⁻⁴ | γ = 10 |
|---|---|---|---|---|
| MVP | 259,999r ≤ 10⁻⁵: 137,225 | 317,644r ≤ 10⁻⁵: 152,738 | 144,190r ≤ 10⁻⁵: 107,087 | 338,779r ≤ 10⁻⁵: 185,893 |
| baMVP | 284,564r ≤ 10⁻⁵: 178,691 | 283,637r ≤ 10⁻⁵: 163,901 | 146,523r ≤ 10⁻⁵: 111,721 | 381,371r ≤ 10⁻⁵: 243,478 |
| MuDP | 46,324r ≤ 10⁻⁵: 27,519 | 19,689r ≤ 10⁻⁵: 10,081 | 15,333r ≤ 10⁻⁵: 9,557 | 57,317r ≤ 10⁻⁵: 36,496 |
| MDP | 46,567r ≤ 10⁻⁵: 27,667 | 21,316r ≤ 10⁻⁵: 11,241 | 15,058r ≤ 10⁻⁵: 10,005 | 57,198r ≤ 10⁻⁵: 36,413 |
| tMDP | –r ≤ 10⁻⁵: – | –r ≤ 10⁻⁵: 9,000 | –r ≤ 10⁻⁵: 7,987 | –r ≤ 10⁻⁵: – |
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.
| Problem | 2 variables | 4 variables | 8 variables | 16 variables |
|---|---|---|---|---|
| Saved difficult ν-SVRFive samples; ten dual variables | 0.386 s | 174 µs | 200 µs | 26 µs |
| ν-SVR, n = 1000λ = 0.01; active norm bound | 9.33 s | 10.83 s† | 4.36 s | 3.38 s |
| Ordinary SVC, n = 1000λ = 0.01 | 0.031 s | 0.102 s | 0.114 s | 0.189 s |
| Smoothed SVR, n = 1000λ = 0.01 | 0.448 s | 1.99 s | 2.10 s | 2.93 s |
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.
| Problem | 2 variables | 4 variables | 8 variables | CV error |
|---|---|---|---|---|
| SVC | 0.226 s | 0.228 s | 0.233 s | 0.308786124 |
| ν-SVR, active norm bound | 0.450 s | 0.306 s | 0.270 s | 0.129487840 |
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.
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⁻¹.
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).
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⁻⁸.
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.
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.
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.
| λ | Newton from 0: iterations | Newton from 0 | SMO to 10⁻⁸ | SMO + Newton |
|---|---|---|---|---|
| 10⁻¹ | 24 | 144 s | 1.9 s | 7.2 s1.2 s SMO + 6.0 s Newton |
| 10⁻² | 24 | 449 s | 1.3 s | 4.3 s0.86 s SMO + 3.5 s Newton |
| 10⁻³ | 42 | 544 s | 1.7 s | 3.1 s1.1 s SMO + 2.0 s Newton |
| 10⁻⁴ | 73 | 463 s | 4.1 s | 2.1 s0.87 s SMO + 1.3 s Newton |
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
Fewer evaluations, same accuracy
The gradient method (OptimizedSVC/OptimizedSVR) is compared with grid search (13 × 11), random search (30 draws) and successive halving on scikit-learn's LIBSVM models. Every point is the mean of 3 random splits; down and left is better.
| data set | gradient method | gradient method, ARD | grid search (13 x 11) | random search (30) | successive halving |
|---|---|---|---|---|---|
| checkerboard (n=800, 2 features) | 11.5 %0.5 s · 18 ev. | – | 11.5 %7.9 s · 143 ev. | 13.3 %1.6 s · 30 ev. | 25.6 %0.5 s · 35 ev. |
| noisy classification (n=1500, 10 features) | 11.4 %2.9 s · 19 ev. | 10.3 %9.4 s · 48 ev. | 12.2 %21.0 s · 143 ev. | 12.2 %4.1 s · 30 ev. | 13.3 %1.0 s · 67 ev. |
| Friedman #1 (n=1000, 10 features) | 0.0814.6 s · 15 ev. | 0.04520.6 s · 55 ev. | 0.08481.9 s · 143 ev. | 0.09714.1 s · 30 ev. | 0.2041.1 s · 90 ev. |
| diabetes (n=442, 10 features) | 0.5030.6 s · 23 ev. | 0.5732.0 s · 68 ev. | 0.50211.7 s · 143 ev. | 0.4892.1 s · 30 ev. | 0.5450.4 s · 38 ev. |
Test error rate (classification) or mean squared error of standardized targets (regression), search time in seconds and number of evaluated hyperparameter settings; best accuracy per row in bold. A setting means one 5-fold cross-validation. On the two-dimensional checkerboard problem the gradient method needs 0.5 s against 7.9 s for the grid. The gradient method pays off most where the grid is expensive; with many hyperparameters (ARD: one kernel width per feature) a grid is out of the question, and the exact gradient costs the same as for two. ARD is no free lunch: with ten hyperparameters it halves the error on Friedman #1 and helps on the noisy classification problem, but on the small diabetes data (265 training points) it overfits the cross-validation error and is worse than the plain method. Random search wins there.
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)
| Search protocol | Speedup | Accuracy Δ (pp) |
|---|---|---|
| Full 5-fold CV5/5 converged | 1.00×0.357 s | 0.0098.25% accuracy |
| Fixed holdout5/5 converged | 4.76×1.83× to 7.71× | −0.88−1.75 to 0.00 |
| Short 5-fold CV0/5 converged · 5 capped | 1.82×1.39× to 3.42× | 0.000.00 to +0.88 |
| Subset + short CV (scaled λ)0/5 converged · 5 capped | 1.41×1.27× to 2.32× | 0.00−0.88 to 0.00 |
| Subset + short CV (direct λ)0/5 converged · 5 capped | 1.62×1.04× to 2.27× | 0.00−0.88 to 0.00 |
Diabetes
| Search protocol | Speedup | RMSE Δ |
|---|---|---|
| Full 5-fold CV5/5 converged | 1.00×0.956 s | 0.00058.159 RMSE |
| Fixed holdout5/5 converged | 4.24×1.73× to 7.11× | +0.724−3.054 to +1.482 |
| Short 5-fold CV0/5 converged · 5 capped | 2.64×1.70× to 2.96× | +0.029−3.246 to +0.823 |
| Subset + short CV (scaled λ)1/5 converged · 4 capped | 2.15×1.04× to 3.08× | −0.131−3.103 to +0.513 |
| Subset + short CV (direct λ)1/5 converged · 4 capped | 2.32×1.77× to 3.30× | +0.025−0.460 to +0.510 |
Noisy two moons
| Search protocol | Speedup | Accuracy Δ (pp) |
|---|---|---|
| Full 5-fold CV5/5 converged | 1.00×0.582 s | 0.0093.75% accuracy |
| Fixed holdout5/5 converged | 3.78×1.34× to 6.04× | 0.00−1.25 to 0.00 |
| Short 5-fold CV0/5 converged · 5 capped | 2.04×0.99× to 3.55× | 0.00−0.62 to 0.00 |
| Subset + short CV (scaled λ)1/5 converged · 4 capped | 1.61×0.44× to 4.91× | 0.00−1.25 to +0.63 |
| Subset + short CV (direct λ)1/5 converged · 4 capped | 0.97×0.35× to 4.32× | 0.00−0.62 to 0.00 |
Friedman #1
| Search protocol | Speedup | RMSE Δ |
|---|---|---|
| Full 5-fold CV5/5 converged | 1.00×4.26 s | 0.0000.819 RMSE |
| Fixed holdout5/5 converged | 3.35×1.34× to 7.07× | +0.001−0.011 to +0.029 |
| Short 5-fold CV0/5 converged · 5 capped | 2.62×1.88× to 5.54× | +0.072+0.018 to +0.090 |
| Subset + short CV (scaled λ)1/5 converged · 4 capped | 1.94×0.85× to 3.33× | +0.016−0.001 to +0.053 |
| Subset + short CV (direct λ)0/5 converged · 5 capped | 1.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.
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.
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