Scaling Neural Tangent Kernels via Sketching and Random Features

Amir Zandieh, Insu Han, Haim Avron, Neta Shoham, Chaewon Kim, Jinwoo Shin

Introduction

In the "infinite width" limit, deep neural networks behave like linear models governed by a specific kernel called the Neural Tangent Kernel (NTK). While NTKs provide a powerful theoretical bridge between deep learning and kernel methods—and can even outperform finite-width networks on small datasets—they suffer from a massive computational bottleneck.

For a dataset of $n$ images, simply computing the Convolutional NTK (CNTK) matrix requires $\Omega(n^2)$ space and $O(n^3)$ time for regression, making it practically impossible for large-scale tasks. Previous attempts to approximate NTKs using the gradients of random finite-width networks required extremely wide (and thus slow) networks to be accurate. This paper introduces high-performance approximation algorithms using sketching and random features that achieve up to a 150× speedup on CIFAR-10 while matching or exceeding the accuracy of exact NTK models.

Approximation Methods

The authors propose two primary strategies to bypass the computational bottleneck of exact kernel methods:

  1. NTKSketch & CNTKSketch: These methods approximate the arc-cosine kernels (the building blocks of NTK) using Taylor expansions to create low-degree polynomial kernels. To handle the "curse of dimensionality" that arises when tensoring features across multiple layers, they use PolySketch and TensorSRHT. These dimensionality reduction techniques allow for fast computation of high-degree tensor products without ever explicitly forming the massive feature vectors. For the convolutional version (CNTK), the algorithm mimics a CNN by sketching local image patches and combining them at each layer, ensuring the runtime scales linearly with the number of pixels.
  2. NTK Random Features (NTKRF): This approach samples the feature space of the kernels directly. To ensure high-quality approximations, the authors utilize leverage score sampling. They propose a new distribution that tightly upper-bounds the leverage scores of arc-cosine kernels, providing the first spectral approximation guarantees for two-layer ReLU networks.

Key Insights

A crucial "aha moment" in this work is the realization that the ReLU-NTK function is smooth enough to be approximated by a low-degree polynomial.

Degree-8 polynomial approximation of the ReLU-NTK function

Because a degree-8 polynomial fits the kernel function so closely, the authors can leverage highly efficient sketching tools designed specifically for polynomial kernels. This sketching approach transforms the CNTK computation from a quadratic scaling (relative to pixels) to a linear one.

Interestingly, the approximate models sometimes outperform the exact ones. The authors suggest that the sketching process provides an implicit regularization effect, helping the model generalize better to unseen data. Furthermore, these sketching methods are theoretically and practically faster than using the gradients of ultra-wide random networks (GradRF), which was the previous standard for NTK approximation.

Experimental Results

The methods were evaluated on standard classification benchmarks (MNIST, CIFAR-10) and large-scale regression tasks from the UCI Machine Learning Repository (ranging up to ~470k data points).

Performance comparisons on MNIST and CIFAR-10 showing accuracy vs. feature dimension and running time
  • Speed and Accuracy: On CIFAR-10, the CNTKSketch method achieved a 150× speedup over exact CNTK. Remarkably, the sketched model reached 72.06% accuracy, actually surpassing the exact CNTK's 70.47%.
  • Scalability: On the MillionSongs dataset (467k points), exact NTK and RBF kernels crashed due to Out-of-Memory errors. The proposed NTKSketch and NTKRF handled the data easily, outperforming standard Random Fourier Features (RFF) in terms of Mean Squared Error.
  • Theoretical Grounding: The paper provides rigorous error bounds, proving that their sketches preserve the "spectral" properties of the kernel matrix, which is essential for stable performance in ridge regression and PCA.

Limitations and Future Work

While highly effective for fully-connected and convolutional architectures, the current work does not yet address more complex structures like Transformers or Attention mechanisms. Additionally, while the algorithms work well empirically for deep networks, the rigorous spectral approximation guarantees are currently proven only for two-layer networks. For deeper networks ($L > 2$), the authors rely on a polynomial-fitting heuristic rather than the full recursive sketching framework to maintain efficiency, leaving the extension of theoretical proofs to deeper architectures as an open challenge.

Summary updated

BibTeX
@inproceedings{zandieh2021scaling,
  author = {Amir Zandieh and Insu Han and Haim Avron and Neta Shoham and Chaewon Kim and Jinwoo Shin},
  title = {{Scaling Neural Tangent Kernels via Sketching and Random Features}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=gN7Do7zeZCz},
}
Figure