NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Fast and Scalable Mixed Precision Euclidean Distance Calculations Using GPU Tensor Cores

Brian Curless, Michael GowanlockarXiv 2025 · DOI

Abstract

Euclidean distance calculations are fundamental to data analytics but often represent a significant computational bottleneck. This paper introduces FaSTED (Fast and Scalable Tensor core Euclidean Distance), a novel algorithm that repurposes GPU Tensor Cores for these calculations. By reformulating the Euclidean distance formula into a matrix multiplication task and employing aggressive memory optimizations like asynchronous pipelining and XOR swizzling, FaSTED achieves speedups of 2.5× to 51× over state-of-the-art methods. With a sustained throughput of 150 TFLOPS on an Nvidia A100 and negligible accuracy loss (<0.06%), FaSTED demonstrates that optimized brute-force approaches on specialized hardware can outperform traditional indexed methods.

Introduction

Euclidean distance calculations power essential data analytics tasks, including k-nearest neighbor searches, clustering, and outlier detection. As datasets grow in size and dimensionality, these calculations increasingly become a primary computational bottleneck. Modern GPUs feature specialized Tensor Cores (TCs) designed for AI matrix multiplications, offering significantly higher theoretical throughput than standard CUDA cores (e.g., 312 TFLOPS vs. 19.5 TFLOPS on an Nvidia A100). However, TCs are challenging to utilize for non-AI tasks due to rigid data layout requirements and the risk of "data starvation," where memory bandwidth cannot keep pace with processing speed.

Methodology: The FaSTED Algorithm

The authors developed FaSTED to saturate Tensor Cores by reformulating the Euclidean distance formula $(p - q)^2$ as $p^2 - 2pq + q^2$. This expansion allows the computationally intensive middle term ($2pq$) to be treated as a matrix multiplication, a task perfectly suited for TCs.

To achieve peak performance, FaSTED employs several low-level optimizations:

  • PTX Inline Assembly: Provides granular control over data movement from global memory to registers, bypassing standard library overhead.
  • Asynchronous Pipelining: Uses cuda::memcpy_async to overlap data loading with computation.
  • XOR Swizzling: Prevents shared memory bank conflicts, ensuring high-concurrency access.
  • Software-Controlled Cache: Manages on-chip memory manually to maximize throughput.
The Single Warp Tile design illustrates how data is organized in registers to maximize reuse and throughput.

The algorithm's "block tile" design (shown above) is critical for maintaining high occupancy and ensuring that data fetched from memory is reused as many times as possible before being discarded.

Evaluation and Results

FaSTED was evaluated against state-of-the-art (SOTA) indexed algorithms using real-world datasets (Sift10M, Tiny5M, Cifar60K, Gist1M) and synthetic data scaling up to 4,096 dimensions.

Key performance metrics include:

  • Throughput: Sustained 150 TFLOPS on an Nvidia A100, nearly 8x the peak theoretical performance of standard CUDA cores.
  • Speedup: Outperformed SOTA methods by 2.5× to 51× across various datasets.
  • Accuracy: Mixed-precision (FP16-32) implementation resulted in <0.06% accuracy loss compared to 64-bit standards.
  • Scalability: Successfully handled high-dimensional data (up to 4,096 dimensions) where previous TC implementations often failed.

Discussion: Data Reuse and Hardware Limits

A central insight of this work is that data reuse is the primary driver of performance. To reach peak throughput, every element read from global memory must be reused approximately 98 times.

Calculations showing the required data reuse factors for global and shared memory to achieve peak throughput.

Despite its success, FaSTED encountered hardware limitations. On PCIe-based A100 GPUs, the intense computational load triggered power-limit throttling, reducing clock speeds. Future improvements could involve hybrid approaches—using indexing to prune search spaces before applying FaSTED—and input normalization to further enhance FP16 precision.

Conclusion

FaSTED demonstrates that a highly optimized brute-force approach leveraging specialized hardware can significantly outperform sophisticated indexing structures. By focusing on data reuse and low-level memory management, the authors have unlocked the potential of Tensor Cores for general-purpose data analytics.

Summary updated

BibTeX
@misc{curless2025fast,
  author = {Brian Curless and Michael Gowanlock},
  title = {{Fast and Scalable Mixed Precision Euclidean Distance Calculations Using GPU Tensor Cores}},
  year = {2025},
  eprint = {2508.21230},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.21230},
}
Figure