Quantization Algorithms for Random Fourier Features

Xiaoyun Li, Ping Li

Introduction

In large-scale machine learning, kernel methods are essential for capturing non-linear relationships. However, their scalability is limited by the memory requirements of storing kernel matrices, which grow quadratically with the number of samples. Random Fourier Features (RFF) mitigate this by mapping data into a low-dimensional space where an inner product approximates the Gaussian kernel. Despite this improvement, RFFs remain memory-intensive for massive datasets. Quantization—converting high-precision floats into low-bit integers—offers a solution to further compress these features and accelerate computation.

A significant hurdle in quantizing RFFs is the dependence of the Gaussian kernel on a tuning parameter, $\gamma$. Typically, changing $\gamma$ alters the feature distribution, necessitating a redesign of the quantizer for every model iteration. This paper introduces a robust quantization framework that overcomes this limitation by leveraging a "universal" property of RFF distributions.

The Universal Distribution of RFF

The core insight of this work is the discovery that the marginal distribution of an unscaled Random Fourier Feature is independent of the kernel parameter $\gamma$. Specifically, the authors prove that the marginal density follows the form: $$f(z) = \frac{1}{\pi \sqrt{1-z^2}}$$ As shown in Figure 1, this distribution is U-shaped and bounded between -1 and 1. Because this formula contains no $\gamma$, a single quantizer can be designed to work across all Gaussian kernel settings. This "universal" property simplifies the deployment of quantized RFFs in practical machine learning pipelines.

The marginal density $f_z$ (red) is independent of the kernel parameter $\gamma$, while $f_{z_2}$ (black) represents the density of the squared features.

Quantization Methods: LM-RFF and $LM^2$-RFF

The researchers propose two algorithms based on the Lloyd-Max (LM) quantization framework, which optimizes "bins" and "reconstruction values" to minimize signal distortion.

  1. LM-RFF: This algorithm minimizes the mean squared error (MSE) of the RFF values themselves. It is a general-purpose quantizer that performs well across a wide range of similarities.
  2. $LM^2$-RFF: This variant optimizes for the squared values of the features. The authors demonstrate that $LM^2$-RFF provides higher accuracy in "high-similarity" regions, where data points are closely clustered.

Figure 6 illustrates how these two methods partition the feature space. While both target the same underlying distribution, their optimal thresholds and reconstruction points differ based on their respective optimization objectives.

Quantization thresholds (vertical lines) and reconstruction points (stars) for the 2-bit LM-RFF (red) and $LM^2$-RFF (blue) algorithms.

Experimental Results

The proposed algorithms were evaluated on several benchmark datasets, including Isolet (speech recognition), BASEHOCK, RELATHE, and PCMAC (text classification). Key findings include:

  • Significant Compression: On the Isolet dataset, LM-RFF achieved 95% accuracy using only ~2,000 bits per sample, compared to ~18,000 bits for standard RFF—a nearly 10x reduction in memory usage.
  • Efficiency of 2-Bit Quantization: The authors found that 2-bit quantization (4 levels) serves as a "sweet spot," delivering performance nearly identical to full 64-bit precision.
  • Superiority over Baselines: LM-RFF consistently outperformed Stochastic Quantization (StocQ) at low bit-rates. Furthermore, because LM-RFF relies on a fixed lookup table, it is computationally more efficient than StocQ, which requires generating random numbers during quantization.

Conclusion

By identifying the $\gamma$-independent marginal distribution of RFFs, this work enables the use of efficient, universal Lloyd-Max quantizers. The proposed LM-RFF and $LM^2$-RFF algorithms provide a practical way to scale kernel methods to billions of features without sacrificing accuracy. Future research may extend these principles to other kernel types, such as Laplacian or Matérn kernels, and explore hardware-specific implementations to further leverage low-bitwidth arithmetic.

Summary updated

BibTeX
@inproceedings{li2021quantization,
  author = {Xiaoyun Li and Ping Li},
  title = {{Quantization Algorithms for Random Fourier Features}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
}
Figure