Similarity Search with Tensor Core Units

Thomas D. Ahle, Francesco Silvestri

Thomas D. Ahle and Francesco Silvestri

Introduction

Similarity search—the process of identifying items in a dataset that are "close" to a given query—is a fundamental operation in modern computer science. It underpins applications ranging from recommendation engines and duplicate detection to large-scale data mining. However, as datasets grow in both cardinality ($n$) and dimensionality ($d$), the computational burden of these operations becomes a significant bottleneck.

In the paper "Similarity Search with Tensor Core Units," authors Thomas D. Ahle and Francesco Silvestri investigate whether specialized hardware designed for deep learning can be repurposed to accelerate these fundamental algorithmic tasks. Specifically, they explore the potential of Tensor Core Units (TCUs), such as those found in NVIDIA GPUs and Google TPUs, to optimize the Johnson-Lindenstrauss (JL) transform and Locality Sensitive Hashing (LSH).

The $(m, au)$-TCU Model

To analyze the potential gains, the authors define the $(m, au)$-TCU model. This theoretical framework treats the TCU as a specialized component within a standard RAM machine. The unit is capable of performing a single instruction: multiplying two $\sqrt{m} \times \sqrt{m}$ matrices in $\tau$ time.

On modern hardware, $\tau$ is typically $O(m)$, meaning the hardware can perform $m^{1.5}$ operations in linear time. This creates a theoretical efficiency gap of $\sqrt{m}$. The challenge addressed in this research is how to restructure general similarity search algorithms—which are often expressed as matrix-vector operations—into the rigid, block-based matrix-matrix operations required by the TCU.

Recursive Dimensionality Reduction

The Johnson-Lindenstrauss (JL) transform is a standard method for dimensionality reduction, projecting high-dimensional vectors into a lower-dimensional space while preserving pairwise distances. Traditionally, this involves multiplying a vector by a large random matrix, an $O(dk)$ operation where $k$ is the target dimension.

Because TCUs are optimized for matrix-matrix multiplication rather than matrix-vector products, the authors propose a Recursive JL Construction. By utilizing Kronecker products ($I \otimes A$), they decompose a large projection matrix into a sequence of smaller, sparse matrices. This structure allows the transform to be computed as a series of small, dense matrix multiplications that fit perfectly into the TCU's $\sqrt{m} \times \sqrt{m}$ architecture. This method achieves a complexity of $O(dk/\sqrt{m})$, representing a $\sqrt{m}$ speedup over naive approaches and even outperforming the Fast Johnson-Lindenstrauss Transform (FJLT) in specific parameter regimes.

High-Throughput Similarity Joins

For similarity joins—finding all pairs of points within a certain distance threshold—the authors adapt Locality Sensitive Hashing (LSH). In traditional CPU-based LSH, the goal is to minimize "false positives" (distant points that collide in the same bucket) to reduce unnecessary distance computations.

However, the authors introduce a counter-intuitive strategy for TCUs: increasing the collision rate. Because TCUs provide massive throughput for dense blocks of data, it is more efficient to allow more points to land in the same bucket and then use the TCU to "brute force" the distance calculations within those buckets. By treating the TCU as a "massive hammer," the algorithm effectively trades a higher number of comparisons for the extreme parallelism of the hardware, resulting in a $\sqrt{m}$ theoretical speedup compared to traditional LSH implementations.

Key Results and Insights

The paper’s primary contribution is the proof that TCUs can provide a significant, provable speedup for non-AI tasks. Key insights include:

  • The $\sqrt{m}$ Advantage: The core algorithmic gain stems from exploiting the $O(m^{1.5})$ work capacity of TCUs within $O(m)$ time.
  • Matrix-Vector to Matrix-Matrix: The research provides a mathematical bridge to translate linear algebra operations into the specific format required by hardware accelerators.
  • Throughput over Precision: The LSH results suggest that for specialized hardware, maximizing parallelism is often more important than minimizing redundant work.

Limitations and Future Directions

As a theoretical work, this paper focuses on algorithmic complexity and provable speedups within the $(m, au)$ model. It does not account for real-world hardware constraints such as memory bandwidth, the latency of data transfer between the CPU and the TCU, or specific warp-level primitives in NVIDIA architectures.

The authors acknowledge that these factors may impact the practical realization of the $\sqrt{m}$ gain. Future work will involve experimental evaluations on modern hardware, such as the NVIDIA Tesla V100 or A100, to determine how closely empirical performance matches these theoretical breakthroughs.

Summary updated

Abstract

Tensor Core Units (TCUs) are hardware accelerators developed for deep neural networks, which efficiently support the multiplication of two dense $\sqrt{m}\times \sqrt{m}$ matrices, where $m$ is a given hardware parameter. In this paper, we show that TCUs can speed up similarity search problems as well. We propose algorithms for the Johnson-Lindenstrauss dimensionality reduction and for similarity join that, by leveraging TCUs, achieve a $\sqrt{m}$ speedup up with respect to traditional approaches.
BibTeX
@inproceedings{ahle2020similarity,
  author = {Thomas D. Ahle and Francesco Silvestri},
  title = {{Similarity Search with Tensor Core Units}},
  booktitle = {SISAP},
  year = {2020},
  doi = {10.1007/978-3-030-60936-8\_6},
}
Figure