Why do SVMs scale poorly to very large datasets, and what can you do about it when you need to classify millions of samples?
Answer
The bottleneck is the kernel matrix. A kernel SVM solves a quadratic program whose dual involves an Gram matrix of pairwise kernel evaluations, which costs O(n^2) storage and between O(n^2) and O(n^3) time depending on the solver and regularization. Beyond tens of thousands of samples the full matrix no longer fits in memory, and the QP solver’s iteration count grows with the number of support vectors, which itself scales roughly linearly with n. Scikit-learn’s documentation states this explicitly: SVC “scales at least quadratically with the number of samples and may be impractical beyond tens of thousands of samples,” and recommends LinearSVC or SGDClassifier for large datasets. The production answer is to either drop the kernel (linear SVM), approximate it (Nyström, Random Fourier Features), or accelerate the computation on GPU (NVIDIA RAPIDS cuML).
(1) Kernel Matrix Bottleneck: the dual QP requires the full kernel matrix in memory; at 1 million samples this is 8 TB in float64, and the solver time is superlinear in n.
(2) Support Vector Growth: the number of support vectors grows roughly linearly with training size, so inference cost also grows with n, unlike a fixed-size linear model.
(3) Production Solutions: scikit-learn recommends LinearSVC (liblinear, scales to millions) or kernel approximation via Nystroem transformer; RAPIDS cuML provides GPU acceleration for SVC and SVR; EigenPro 3.0 (ICML 2023) decoupled model size from data size, training on 5 million samples with 1 million centers.

Figure 1: Training time versus dataset size: kernel SVM grows as O(n^2) to O(n^3) because of the full Gram matrix and QP solver, while linear SVM (LinearSVC) and Nyström-approximated kernel SVM both scale near-linearly with a larger constant for the approximation.
The practical toolkit has four tiers. First, if a linear boundary is acceptable, use LinearSVC (liblinear) or SGDClassifier with hinge loss, both of which scale to millions of samples and features because they never form a kernel matrix. Second, if you need nonlinearity, approximate the kernel map: Nyström approximation samples m landmark points (m much less than n) and replaces the n-by-n matrix with a rank-m factorization, and Random Fourier Features (RFF) map data into an explicit finite-dimensional space where a linear solver applies; ICML 2024 showed Quasi-Monte Carlo features improve RFF’s error from O(1/sqrt(M)) to O(1/M). Third, GPU-accelerate: RAPIDS cuML provides zero-code-change GPU dispatch for SVC and SVR. Fourth, for true kernel-method scale, EigenPro 3.0 (ICML 2023) uses preconditioned SGD to train kernel models with 1 million centers on 5 million samples, decoupling model size from data size for the first time.

Figure 2: A practical decision flow: linearly separable data uses LinearSVC or SGDClassifier; if the boundary must be nonlinear, CPU-only setups use Nyström or Random Fourier Features with a linear solver, while GPU hardware unlocks RAPIDS cuML or EigenPro 3.0’s preconditioned SGD.
Mathematical Formulation:
Where:
is the dual variable vector; nonzero entries identify support vectors, and the solution is sparse but the number of support vectors grows with n.
is the
kernel (Gram) matrix with entries
; storing it costs O(n^2) and solving the QP costs O(n^2) to O(n^3) depending on cache efficiency and C.
is the kernel function (RBF, polynomial, etc.);
is the regularization parameter. Larger C means fewer support vectors but longer solver convergence, pushing toward the O(n^3) end.
| Approach | Training Cost | Practical Limit |
|---|---|---|
| Kernel SVC (libsvm) | O(n^2) to O(n^3) | Tens of thousands of samples |
| LinearSVC (liblinear) | O(n) per iteration | Millions of samples and features |
| Nyström + LinearSVC | O(nm) for approximation | Hundreds of thousands with nonlinearity |
| RAPIDS cuML (GPU) | Parallelized QP on GPU | Zero-code-change from sklearn, GPU memory bound |
| EigenPro 3.0 | O(np + p^2) per epoch | 5 million samples, 1 million centers (ICML 2023) |
Leave a Reply