smo-solver
Fast Sequential Minimal Optimization (SMO) for smoothed, weighted and ν-constrained support vector machines — written in Rust, usable from Python.
smo-solver solves the dual training problem of kernel support vector machines for a whole
family of loss functions: the classical hinge and ε-insensitive losses, their quadratically
smoothed versions, the squared loss (LS-SVM), arbitrary sample weights and an optional bound on
the 1-norm of the dual variables (a generalised ν-SVM). It implements the methods analysed in
N. Strasdat, Duality, Derivative-Based Training Methods and Hyperparameter Optimization for Support Vector Machines, Dissertation, Technische Universität Dresden, 2023. urn:nbn🇩🇪bsz:14-qucosa2-874731
and is the training backend of optimized-svm,
which tunes SVM hyperparameters with exact gradients.
Features
- one solver for a general separable quadratic dual (hinge, ε-insensitive, smoothed variants,
least squares, custom problems via
solve_dual) - working set selection: maximal violating pair, second-order (maximal unbounded decrease) and bound-aware maximal decrease (default)
- shrinking with the fixed-variable detection rule of the thesis, LRU kernel row cache
- warm starts, time limits, progress callbacks,
Ctrl-Csupport - Python: zero-copy NumPy input, GIL released while solving, scikit-learn compatible
estimators
SmoSVC(binary and one-vs-rest),SmoSVR,SmoLSSVR - every solution reports its duality gap, so optimality can be checked independently
Installation
pip install smo-solver # solver only (NumPy)
pip install "smo-solver[sklearn]" # + scikit-learn estimators
Building from source requires a Rust toolchain (≥ 1.75):
git clone https://github.com/wotzlaff/smo-solver && cd smo-solver
uv venv && uv pip install maturin && uv run maturin develop --release
Quick start (Python)
import numpy as np
from smo_solver import SmoSVC, solve_classification
rng = np.random.default_rng(0)
x = rng.normal(size=(500, 2))
y = np.where(x[:, 0] * x[:, 1] > 0, 1.0, -1.0)
# scikit-learn estimator (lam = 1 / C)
clf = SmoSVC(lam=0.01, gamma=1.0, smoothing=0.1).fit(x, y)
print(clf.score(x, y), clf.n_support_)
# low-level solver: full access to the dual solution
res = solve_classification(x, y, lam=0.01, gamma=1.0, smoothing=0.1, tol=1e-6)
print(res) # SmoResult(status="converged", steps=..., gap=...)
res.alpha, res.b # dual variables and bias
res.beta / res.lam # kernel expansion coefficients per sample
Quick start (Rust)
use smo_solver::{solve, DualProblem, FeatureKernel, KernelFunction, Model, SmoOptions};
let x = [0.0, 0.0, 0.2, 0.1, 1.0, 1.0, 0.9, 1.2]; // 4 samples, row-major
let y = [-1.0, -1.0, 1.0, 1.0];
let f = KernelFunction::Rbf { gamma: 1.0 };
let kernel = FeatureKernel::new(&x, 2, f);
let problem = DualProblem::classification(&y, 0.1, None, 1.0, 0.0, None)?;
let result = solve(&kernel, &problem, &SmoOptions::default())?;
let model = Model::new(f, &x, 2, &problem, &result);
assert!(model.decision(&[1.0, 1.1]) > 0.0);
The problem class
For a kernel matrix K, regularization λ > 0 and per-variable data q_i ≥ 0, p_i,
lo_i ≤ 0 ≤ hi_i, the solver computes
min_α 1/(2λ) αᵀKα + Σ_i (½ q_i α_i² + p_i α_i)
s.t. Σ_i α_i = 0, lo_i ≤ α_i ≤ hi_i, [ Σ_i s_i α_i ≤ A ]
which is the dual of min_{w,b} λ/2 ‖w‖² + Σ_i ℓ_i(⟨w, φ(x_i)⟩ + b) whenever the conjugate of the
loss is quadratic on an interval. The decision function is f(x) = 1/λ Σ_k β_k K(x, x_k) + b.
| Problem | loss ℓ_i(t) |
constructor |
|---|---|---|
| SVC | w_i · m_δ(shift − y_i t) |
solve_classification / DualProblem::classification |
| ε-SVR | w_i · (m_δ(t − y_i − ε) + m_δ(y_i − t − ε)) |
solve_regression / DualProblem::regression |
| LS-SVM | w_i/2 · (t − y_i)² |
solve_least_squares / DualProblem::least_squares |
m_δ is the quadratically smoothed maximum (max(0, t) for δ = 0). The stopping tolerance
uses the same scaling as LIBSVM; with δ = 0 and λ = 1/C the solutions coincide with
sklearn.svm.SVC/SVR.
Stopping criterion
By default the solver stops when the violation measure r(α) = max_{α_i > lo_i} g_i − min_{α_j < hi_j} g_j
drops below tol. With stopping="bound_aware" it also stops when the bound-aware violation measure of
the thesis (Def. 7.21), normalized by ρ, is below tol:
r◇(α, ρ) / ρ = max_{i,j} min(ε_ij, ρ)/ρ · (g_j − g_i) ≤ tol, ε_ij = min(hi_i − α_i, α_j − lo_j)
Because min(ε_ij, ρ) ≤ ρ this measure never exceeds r(α), so the criterion stops no later than the
default one; it discounts violating pairs that can only move a tiny distance. It costs O(n log n) and is
checked every shrinking_period steps. rho defaults to λ (the value used in the thesis, Sec. 10.2.2);
the criterion is not available together with max_asum.
In our experiments it rarely differs from the default: with ρ = λ the two measures agree up to
pairs at a bound, in line with the observation r ≈ r◇/λ of the thesis (Sec. 10.2.2). It stops
earlier only for ε-regression at n = 5000 (292 000 instead of 387 707 steps at tol = 1e-3, with a
duality gap of 0.32 instead of 0.08). Larger ρ stops earlier still, but trades accuracy for steps
about like a larger tol does.
Performance
Training time against LIBSVM (sklearn.svm.SVC/SVR, same C = 1/λ, γ = 0.1, tolerance
1e-3) on synthetic data with 10 features (benchmarks/bench_vs_libsvm.py, single machine,
indicative only):
| task | n | smo-solver | LIBSVM | SMO steps (smo-solver / LIBSVM) |
|---|---|---|---|---|
| classification | 2000 | 0.08 s | 0.10 s | 13 996 / 14 125 |
| classification | 5000 | 0.60 s | 0.73 s | 51 759 / 51 754 |
| ε-regression | 2000 | 0.51 s | 0.55 s | 42 591 / 44 255 |
| ε-regression | 5000 | 11.1 s | 9.6 s | 387 707 / 304 960 |
Classification needs as many steps as LIBSVM. The higher step count for ε-regression at
n = 5000 is an effect of the stopping point, not of the working set rule: with LIBSVM's rule
(working_set="mud") the solver stops after 281 751 steps, but with a duality gap of 0.35
instead of 0.08. At equal gap both rules need the same number of steps (n = 3000, tolerances
1e-2 … 1e-4). Almost all steps are unconstrained two-variable steps on the free variables,
so the convergence speed is set by the conditioning of the problem, not by the selection rule.
The loops over the active set use AVX2 when available (detected at run time).
Decision values agree to about 1e-3.
Testing
cargo test --workspace --release # unit, integration and property tests
uv run pytest # Python tests (incl. scikit-learn checks)
Correctness is verified against independent references: zero duality gap, closed-form LS-SVM solutions, LIBSVM (via scikit-learn), SciPy's SLSQP and primal formulations solved with cvxpy.
Known limitations
- With an active 1-norm constraint and a very small
λ, two-variable steps can zigzag between the sign groups (for ε-SVR, both copies of a sample share one kernel row); convergence then needs very many steps. - Only quadratic conjugate losses are supported by SMO; smooth non-quadratic losses
(e.g. logistic, Poisson) are handled by the Newton solver in
optimized-svm.
Citation
If you use this software, please cite the dissertation:
@phdthesis{strasdat2023,
author = {Nico Strasdat},
title = {Duality, Derivative-Based Training Methods and
Hyperparameter Optimization for Support Vector Machines},
school = {Technische Universit{\"a}t Dresden},
type = {Dissertation},
year = {2023},
url = {https://nbn-resolving.org/urn:nbn:de:bsz:14-qucosa2-874731},
note = {urn:nbn:de:bsz:14-qucosa2-874731}
}
License
BSD-3-Clause. The predecessor implementation in Nim is preserved in the git tag legacy-nim.
Metadata
Release files for smo-solver 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smo_solver-0.1.2.tar.gz | 54.7 kB | With provenance | Details for smo_solver-0.1.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| smo_solver-0.1.2-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for smo_solver-0.1.2-cp310-abi3-win_amd64.whl |
| smo_solver-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for smo_solver-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| smo_solver-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for smo_solver-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| smo_solver-0.1.2-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for smo_solver-0.1.2-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 1.6 MB
Release files / smo_solver-0.1.2.tar.gz
| Download URL | smo_solver-0.1.2.tar.gz |
|---|---|
| Size | 54.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a187861b517cfba7f0abbb2c0a9cd8f2710ebdd0407ee42678485460d477457a
|
|
BLAKE2b-256 checksum How to use checksums |
2a01c7a5c5c41dd8c762241a0a26f0afe3acf84d55d8e71f7f5fd57538594dc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / smo_solver-0.1.2-cp310-abi3-win_amd64.whl
| Download URL | smo_solver-0.1.2-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 291.9 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bb50dcfc27b4d56937662b63a9048476abbf11c37cb91ef06479e594fb129412
|
|
BLAKE2b-256 checksum How to use checksums |
256c46c6d9b135fd0934f7ee4a0214e9489c6a489a372a0d044606a9e8253d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / smo_solver-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | smo_solver-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 422.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bda008464a0823dc645698c2beb6831d9729aa0d5fbe2285784f4d0658a69ca1
|
|
BLAKE2b-256 checksum How to use checksums |
10fc7da99989197dacbdc0ec5ef801edadd814f5146c93bf0d05c9f4b4939194
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / smo_solver-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | smo_solver-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 411.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0631ca0f226373bc3fda892525d1b9b1f847015bb2924b68d4334086d26fd4f8
|
|
BLAKE2b-256 checksum How to use checksums |
91d3a1cbf054f198dc4814ac939d9064a0948a3844919244ab0aa6bfedb819ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / smo_solver-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | smo_solver-0.1.2-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 373.4 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fc48e4a5ebbf4f6f36a59ee649bbc2cbb57cbf2f05340bcba0a7a6c826d5bc08
|
|
BLAKE2b-256 checksum How to use checksums |
08193d2dfbb657e1ad56103525876b35a55984b8ee13e233609881542a040757
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logSecurity for smo-solver 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for smo_solver-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.