Giga-scale Kernel Matrix-Vector Multiplication on GPU

Robert Hu, Siu Lun Chau, Dino Sejdinovic, Joan Glaunès

TL;DR

Researchers have developed $F^3M$ (Faster-Fast and Free Memory Method), a new algorithm that performs kernel matrix-vector multiplication (KMVM) for a billion data points in under a minute on a single GPU. By combining clever geometric partitioning with GPU-optimized interpolation, $F^3M$ achieves linear scaling and provides a massive speedup (up to 8500x) over existing methods for "tall and skinny" datasets.

The Scaling Bottleneck of KMVM

Kernel matrix-vector multiplication (KMVM) is the "engine room" of many scientific and machine learning applications, from Gaussian Processes to fluid dynamics. The primary challenge is scaling: a standard KMVM requires $O(n^2)$ time and memory. If you have a billion points ($n=10^9$), a direct calculation would require roughly $10^{18}$ operations and petabytes of memory—a completely impossible feat on modern hardware.

Existing solutions like KeOps use GPU acceleration to compute results on-the-fly without storing the matrix, but they still scale quadratically in time; for a billion points, KeOps would take about 11 days. Other methods like the Fast Multipole Method (FMM) offer better scaling but are traditionally restricted to very low dimensions (usually $D \leq 3$) and are often optimized for CPUs rather than GPUs.

Methods: Introducing $F^3M$

The authors introduce $F^3M$, which builds upon the Fast and Free Memory (FFM) framework. FFM uses a "divide and conquer" strategy: it partitions data into boxes and uses Lagrange interpolation to approximate "far-field" interactions (points far apart) while calculating "near-field" interactions exactly.

Evolution of FMM to F3M

The core innovations in $F^3M$ that enable giga-scale processing include:

  • GPU-Native Parallelization: Moving the entire FFM logic to the GPU, which required rewriting core components like data sorting.
  • In-place Grouping: Standard sorting libraries often cause Out-of-Memory (OOM) errors at giga-scale. The authors designed a custom linear-time, in-place grouping algorithm to organize points into geometric boxes.
  • Hash List Indexing: To handle higher dimensions (up to $D=7$), they implemented a hashing scheme that ignores empty space, preventing the exponential memory explosion typical of grid-based methods.
  • Smoothness & Adaptive Approximation: The algorithm detects when a kernel field is "smooth" or very far away and automatically reduces the number of interpolation nodes used, saving massive amounts of computation without sacrificing much accuracy.

Datasets Evaluated

The authors evaluated $F^3M$ on a mix of synthetic and massive real-world datasets to ensure robustness:

  • Synthetic: Uniformly and normally distributed data, Brownian motion, and clustered data (up to $n=10^9$).
  • Open Street Map (OSM): A dataset of 1 billion GPS coordinates ($D=2$).
  • NYC Taxi: Data used for predicting tips based on trip features ($D=3$).
  • UCI Machine Learning Repository: Datasets like 3DRoad, Song, Buzz, and House Electric for Gaussian Process regression tests.

Key Insights

  • Breaking the $D=3$ Barrier: Most FMM-style algorithms are stuck in 2D or 3D (physics-based problems). $F^3M$ pushes this to $D=7$, making it useful for a much wider range of machine learning tasks.
  • Memory is the Real Bottleneck: At the giga-scale, even $O(n)$ memory can be dangerous. The paper emphasizes that avoiding "empty boxes" in the geometric partition is the key to fitting a billion-point problem onto a single 32GB GPU.
  • Precision vs. Speed Trade-off: $F^3M$ allows users to specify an error tolerance. They found that a relative error of $10^{-3}$ is often more than enough for downstream ML tasks, allowing for much faster computation than "exact" methods.

Key Results

  • Billion-Point Performance: $F^3M$ computed a KMVM for $10^9$ points in 125 seconds on a single NVIDIA V100 GPU. For comparison, the CPU-based FFM took over 3 hours (a 90x speedup).
  • FALKON Integration: When used as a drop-in replacement for the solver in FALKON (a state-of-the-art kernel solver), $F^3M$ sped up the process by 1.5x to 5.5x with less than a 1% drop in accuracy.
  • Linear Scaling: Empirical tests confirmed that both time and memory usage grow linearly with $n$, proving the algorithm can handle the "Giga-scale" effectively.
  • Superiority over KeOps: For $n=10^8$, $F^3M$ was roughly 873x faster than KeOps.

Limitations and Future Work

  • The Dimensionality Wall: While $D=7$ is a great improvement, the number of interpolation nodes still grows exponentially with dimension. $F^3M$ is not yet suitable for high-dimensional data like image embeddings ($D=128+$).
  • Kernel Specificity: While the method is "kernel agnostic," the current smoothness criteria are optimized for the Gaussian kernel. Extending this to a broader library of kernels is a suggested next step.
  • Randomized Partitioning: The authors suggest that moving away from rigid geometric boxes toward randomized partitioning might help the algorithm scale to even higher dimensions in the future.

Summary updated

BibTeX
@inproceedings{hu2022giga,
  author = {Robert Hu and Siu Lun Chau and Dino Sejdinovic and Joan Glaunès},
  title = {{Giga-scale Kernel Matrix-Vector Multiplication on GPU}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=Y513uEBq6y},
}
Figure