Abstract
Randomized Numerical Linear Algebra (RandNLA) has become an essential tool for processing massive datasets, yet the random projection step remains a significant computational bottleneck. This paper, presented by researchers from the Tokyo Institute of Technology, introduces SHGEMM (Single and Half-precision General Matrix Multiplication), a novel mixed-precision kernel designed to leverage NVIDIA Tensor Cores. By storing random matrices in FP16 while maintaining data in FP32, the authors achieve significant speedups—up to 1.75x for tensor decompositions—without sacrificing the numerical accuracy required for scientific computing.
Introduction
In the era of "Big Data," traditional algorithms for matrix decompositions, such as Singular Value Decomposition (SVD), often struggle with the sheer scale of modern datasets. RandNLA addresses this by utilizing random projections: multiplying a massive input matrix by a smaller random matrix to create a "sketch" that preserves the essential structural properties of the data.
While theoretically efficient, the practical implementation of the random projection step is often limited by hardware constraints. Modern NVIDIA GPUs feature Tensor Cores optimized for low-precision arithmetic (FP16/BF16) common in deep learning. However, scientific computing typically requires single-precision (FP32) to maintain accuracy. Simply converting data to lower precision leads to unacceptable errors. The challenge addressed in this research is how to harness the high throughput of Tensor Cores for RandNLA while preserving FP32-level precision.
Methodology: The SHGEMM Kernel
The authors propose the SHGEMM approach, which rests on three technical pillars designed to bridge the gap between hardware speed and numerical rigor.
1. Precision Asymmetry
The researchers provide a theoretical proof that the precision requirements for the two matrices in a random projection are not equal. While the input data requires high precision (FP32) to maintain the integrity of the signal, the random matrix acts as a structural probe. They demonstrate that a Gaussian random matrix stored in FP16 still satisfies the mathematical requirements for a valid projection, as the inherent variance of the random distribution outweighs the rounding errors introduced by the lower precision format.
2. Mantissa Splitting and Compensated Summation
To perform the multiplication on Tensor Cores without losing precision, the authors utilize a technique called "mantissa splitting." The FP32 input matrix is decomposed into lower-precision components. The multiplication is then executed on the Tensor Cores, and the results are accumulated back into FP32 on the GPU’s standard SIMT (Single Instruction, Multiple Threads) cores using compensated summation. This hybrid approach ensures that the bulk of the math happens at high speed while the final result remains accurate.
3. Rounding Correction
A critical insight in the paper involves the default behavior of GPU hardware. Tensor Cores typically utilize "Round to Zero" (RZ) logic, which can cause systematic bias and accuracy degradation in scientific simulations. By moving the final accumulation step to the SIMT cores, the authors are able to implement "Round to Nearest" (RN), effectively preserving the accuracy of a standard single-precision implementation.
Experimental Evaluation
The authors evaluated SHGEMM on an NVIDIA A100 GPU using a variety of synthetic matrices and tensors designed to stress-test numerical stability:
- Haar Distribution Matrices: Synthetic matrices with specific target ranks and decaying singular values to simulate real-world data.
- Cauchy Matrices: Matrices containing extreme values used to test the limits of the FP16 exponent range.
- 3D Tensors: Used to evaluate performance in High-Order SVD (HOSVD) tasks.
Performance Results
The SHGEMM-FP16 kernel achieved a peak throughput of 61.0 TFlop/s on the A100, a substantial improvement over standard FP32 libraries. When integrated into broader algorithms, the results were as follows:
- Randomized SVD (RSVD): Total execution time was reduced by 1.28x.
- Random Projection HOSVD: Achieved a 1.75x speedup.
- Accuracy: In nearly all test cases, the mixed-precision approach produced results numerically identical to pure FP32 baselines, effectively providing a "speed for free" upgrade for RandNLA tasks.
Limitations and Future Outlook
Despite the performance gains, the authors identify specific constraints. The limited exponent range of FP16 makes it susceptible to overflow when dealing with extreme values, such as those found in Cauchy matrices. For such cases, the authors suggest SHGEMM-TF32 as a fallback; while slower than the FP16 version (40.5 TFlop/s), it offers a safer range for volatile data.
Additionally, the kernels currently reach approximately 39-53% of the theoretical peak performance of Tensor Cores. This efficiency gap is attributed to the overhead of matrix splitting and the synchronization required between Tensor Cores and SIMT cores. Future work may focus on extending this mixed-precision strategy to other randomized algorithms, including randomized LU decomposition and least-squares solvers, further expanding the utility of specialized AI hardware in the realm of general scientific computing.
Summary updated