Random matrices in service of ML footprint: ternary random features with no performance loss

Hafiz Tiomoko Ali, Zhenyu Liao, Romain Couillet

Abstract

Kernel methods are powerful tools for non-linear modeling but face significant scalability challenges in high-dimensional settings. This paper introduces Ternary Random Features (TRF), a method that leverages Random Matrix Theory (RMT) to simplify random feature weights and activations to ternary values $\{-1, 0, 1\}$. By matching the first and second Gaussian moments of the approximating function to the target kernel, TRF achieves performance parity with full-precision methods while reducing memory requirements by up to $32\times$ and eliminating the need for floating-point multiplications.

Introduction

Machine learning practitioners often rely on kernel methods to capture complex, non-linear relationships in data. However, as datasets grow in size ($n$) and dimensionality ($p$), the computational and memory costs of standard kernel techniques become prohibitive. Random Features (RF) emerged as a popular solution, approximating kernels by projecting data into a lower-dimensional space via a random weight matrix $W$ and a non-linear activation $\sigma$.

Despite their efficiency, standard RF implementations still require storing large, high-precision weight matrices and performing intensive floating-point operations. This creates a substantial "ML footprint," particularly problematic for edge devices with limited resources or for large-scale "green computing" initiatives. The central question addressed in this research is whether these random features can be simplified to the extreme—using only ternary values—without sacrificing predictive accuracy.

Methods: Leveraging Spectral Universality

The core innovation of Ternary Random Features (TRF) lies in the application of Random Matrix Theory (RMT) to analyze the spectral behavior of kernel matrices in high-dimensional regimes.

The Universality Discovery

The researchers proved that the eigenspectrum of a random feature kernel matrix is "universal." In the limit where $n, p \to \infty$, the distribution of eigenvalues does not depend on the specific distribution of the random weights $W$, provided they are properly normalized. Instead, the spectral properties are determined primarily by the activation function $\sigma$ through its first and second Gaussian moments, denoted as $d_1$ and $d_2$.

Spectral comparison between the original kernel K and the TRF approximation, showing nearly identical eigenvalue distributions.

Ternary Random Features (TRF)

Based on this universality, the authors propose a scheme where both weights and activations are constrained to the set $\{-1, 0, 1\}$.

  1. Weights ($W$): Drawn from a ternary distribution.
  2. Activation ($\sigma$): Replaced by a ternary step function.
  3. Moment Matching: To ensure the TRF kernel approximates a target kernel (such as the Gaussian RBF kernel), the authors developed an algorithm to calculate optimal thresholds for the ternary activation function. By matching the $d_1$ and $d_2$ moments of the ternary function to those of the target kernel, the two become asymptotically equivalent.

This approach effectively decouples the "shape" of the activation function from its performance, allowing complex functions like cos(x) to be replaced by computationally inexpensive step functions.

Experimental Validation

The TRF method was validated across several benchmarks, including the UCI Cov-Type and Census datasets, MNIST, and Fashion-MNIST. Additionally, the researchers tested TRF on deep embeddings extracted from pre-trained models like VGG16 and LeNet-64 to demonstrate its compatibility with modern neural architectures.

Performance and Efficiency

The results demonstrate that TRF achieves nearly identical accuracy to full-precision Nyström approximations and standard Random Fourier Features (RFF). Crucially, this performance is achieved with a significantly smaller memory footprint.

Accuracy vs. Memory (bits) for various methods on the Cov-Type dataset. The proposed TRF achieves superior accuracy at lower memory costs compared to quantized RFF and Nyström methods.

Key findings include:

  • Massive Compression: TRF requires $8\times$ less memory than 8-bit quantized features and up to $32\times$ less than standard 32-bit methods.
  • Multiplication-Free Compute: The ternary nature of weights and activations transforms the core operations from floating-point multiplications to simple integer additions and subtractions, leading to significant speedups on hardware.
  • Robustness to Sparsity: The method remains effective even when the weight matrix is up to 90% sparse, allowing for further computational gains.

Discussion and Future Work

While TRF shows remarkable promise, some limitations remain. The current theoretical proofs rely on a Gaussian Mixture Model (GMM) assumption for the data. Although empirical results on non-Gaussian real-world data are strong, extending the formal theory to more general data distributions is a key area for future research. Additionally, while the numerical solver for finding thresholds is fast, a closed-form solution would be a valuable theoretical advancement.

The principles of RMT-based quantization explored here could potentially be extended to deep, fully-trained neural networks, paving the way for more environmentally friendly and resource-efficient AI systems.

Summary updated

BibTeX
@inproceedings{ali2022random,
  author = {Hafiz Tiomoko Ali and Zhenyu Liao and Romain Couillet},
  title = {{Random matrices in service of ML footprint: ternary random features with no performance loss}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=qwULHx9zld},
}
Figure