DGEMM on integer matrix multiplication unit

Hiroyuki Ootomo, Katsuhisa Ozaki, Rio Yokota

This paper, recently published by researchers from the Tokyo Institute of Technology and Shibaura Institute of Technology, explores a clever way to repurpose the "AI engines" inside modern GPUs for high-precision scientific computing.

TL;DR

Researchers have developed a method to perform high-precision double-precision (FP64) matrix multiplication using the lightning-fast integer units (INT8) found in modern GPUs. By leveraging the "Ozaki scheme," they achieved up to a 4.33x speedup in quantum circuit simulations on consumer-grade hardware while maintaining full double-precision accuracy.

What Problem Does This Paper Address?

In the world of High-Performance Computing (HPC), double-precision floating-point (FP64) is the gold standard for accuracy. However, the hardware industry is currently obsessed with AI, leading to a massive disparity in performance. Modern GPUs are packed with specialized units like NVIDIA’s Tensor Cores, which are designed for low-precision math (like INT8 or FP16) used in deep learning.

On consumer-grade GPUs (like the RTX series), FP64 performance is often intentionally limited to a tiny fraction of the chip's total power. This leaves scientists and engineers with a dilemma: buy incredibly expensive enterprise GPUs (like the H100) or find a way to make high-precision math work on low-precision hardware. This paper tackles the latter.

Methods

The authors utilize the Ozaki scheme, an algorithm that allows high-precision matrix multiplication to be computed using lower-precision units.

The core idea is to "slice" the mantissa (the significant digits) of high-precision numbers into multiple lower-precision chunks. These chunks are then multiplied separately. Because the chunks are small enough, these multiplications can be performed on low-precision hardware without any rounding errors. The final result is obtained by summing these error-free products in high precision.

What’s New: While previous work applied the Ozaki scheme to low-precision floating-point units (FMMUs), this paper is the first to optimize it for Integer Matrix Multiplication Units (IMMUs).

  • Integer Slicing: They treat the slices as integers, which is more memory-efficient because it eliminates the need to store redundant exponent bits for every element.
  • ozIMMU Library: They implemented a custom library that uses bitwise operations to split matrices and leverages standard libraries like cublasGemmEx to run the heavy lifting on INT8 Tensor Cores.
  • Auto-Tuning: They introduced an automatic mechanism to determine the optimal number of "slices" based on the distribution of exponents in the input data, balancing speed and accuracy.

Datasets

As a systems and algorithms paper, the evaluation focused on:

  1. Synthetic Benchmarks: Randomly generated matrices with varying "exponent ranges" to test how well the algorithm handles data with widely different scales.
  2. Quantum Circuit Simulation: They used "brickwork random unitary circuits" for StateVec simulations, a real-world, compute-intensive HPC application.

Key Insights and Ideas

  • Integer Efficiency: Integer units are actually better for the Ozaki scheme than floating-point units. Because integer slices use a "shared exponent" for the whole block, they consume 50% to 75% less working memory than previous FP16-based methods.
  • The Consumer GPU Advantage: On consumer GPUs where FP64 hardware is sparse, this method is a game-changer. It allows an RTX 6000 Ada to outperform the theoretical peak of its own FP64 hardware by a significant margin.
  • Better than "Standard" Accuracy: Surprisingly, the Ozaki scheme can sometimes be more accurate than standard DGEMM. In cases of "zero-cancellation" (where two large numbers subtract to nearly zero), the Ozaki scheme's digit-by-digit approach avoids the precision loss typical of standard floating-point math.

Key Results

  • Speedups: On consumer GPUs (TITAN RTX, RTX A6000), the INT8-based Ozaki implementation outperformed standard cuBLAS DGEMM by up to 6x.
  • Quantum Simulation: In a practical StateVec quantum simulation, the researchers achieved a 4.33x speedup over the standard cuBLAS ZGEMM (complex double-precision) while maintaining the same level of accuracy.
  • Hardware Comparison: On the enterprise-grade NVIDIA A100, standard FP64 units are still faster. However, on every consumer-grade GPU tested, the INT8 Ozaki method was the clear winner.

Limitations and Future Work

  • The "Wide Exponent" Penalty: The Ozaki scheme’s performance depends on the data. If a matrix contains numbers that vary wildly in scale (e.g., $10^{-20}$ and $10^{20}$), the algorithm requires more slices, which slows it down.
  • Accumulation Bottleneck: The final step of the algorithm—summing the high-precision slices—is currently a performance bottleneck. The authors suggest that future work should focus on optimizing these custom summation kernels.
  • Underflow Risks: Very small values might be treated as zero during the splitting process. While usually harmless, this can cause accuracy issues in specific edge cases where those tiny values are later multiplied by massive ones.

Reference: Ootomo, H., Ozaki, K., & Yokota, R. (2024). DGEMM on Integer Matrix Multiplication Unit. arXiv:2306.11975v4.

Summary updated

BibTeX
@article{ootomo2024dgemm,
  author = {Hiroyuki Ootomo and Katsuhisa Ozaki and Rio Yokota},
  title = {{DGEMM on integer matrix multiplication unit}},
  journal = {Int. J. High Perform. Comput. Appl.},
  year = {2024},
  doi = {10.1177/10943420241239588},
}
Figure