Quantum Circuit Simulation by SGEMM Emulation on Tensor Cores and Automatic Precision Selection

Hiroyuki Ootomo, Hidetaka Manabe, Kenji Harada, Rio Yokota · DOI

Abstract

Classical simulation of quantum circuits is a critical tool for the development of quantum algorithms and the verification of quantum supremacy. However, these simulations face a significant trade-off between computational throughput and numerical fidelity. This paper presents a novel approach to accelerate quantum circuit simulations using NVIDIA Tensor Cores while maintaining the high precision required for quantum physics. By implementing a custom SGEMM (Single-precision General Matrix Multiply) emulation library, cuMpSGEMM, and an automatic precision selection algorithm, the researchers achieved up to a 1.86x speedup over standard libraries without sacrificing simulation accuracy.

Introduction

As quantum computing hardware advances, the need for robust classical simulation becomes increasingly urgent. Researchers primarily utilize two methodologies: state vector methods, which are memory-intensive, and tensor network contraction, which is computationally demanding but more memory-efficient. In tensor network methods, General Matrix Multiplication (GEMM) operations can account for up to 90% of the total workload.

While modern GPUs feature specialized Tensor Cores designed to accelerate GEMM operations, these units typically operate at lower precisions such as FP16 or TF32. Quantum simulations are highly sensitive to numerical errors; the limited precision of these formats often leads to "fidelity loss," where the simulation results diverge from the theoretical quantum state. Furthermore, the narrow exponent range of FP16 frequently causes the small probability amplitudes characteristic of quantum systems to underflow to zero, rendering the simulation invalid.

Methodology

To bridge the gap between high-speed machine learning hardware and high-fidelity scientific computing, the authors introduced three primary technical innovations.

1. The cuMpSGEMM Library

The researchers developed cuMpSGEMM, a drop-in replacement for standard NVIDIA libraries. This library utilizes compensated summation, a technique that decomposes a single-precision (FP32) number into two lower-precision components. These components are processed via Tensor Cores and subsequently recombined. This approach allows the system to emulate full FP32 accuracy while leveraging the massive throughput of Tensor Core hardware.

2. Automatic Precision Selection and Scaling

Recognizing that not all matrix operations require the same level of precision, the authors implemented a dynamic selection system that analyzes the "exponent statistics" of input matrices in real-time.

  • FP16TCEC (Error-Corrected FP16): Used when numerical values are within a "safe" range.
  • TF32TCEC (Error-Corrected TF32): Employed when values risk underflow, as TF32 provides a wider exponent range.
  • Dynamic Scaling: To maximize the utility of FP16, the system applies scaling factors to matrices, shifting their values into the optimal range for the hardware's precision capabilities.

3. Zero-Overhead Kernel Switching

A common bottleneck in dynamic systems is the latency involved in transferring decision logic between the CPU and GPU. To mitigate this, the authors developed a "zero-overhead" switching mechanism. The system preemptively launches multiple GPU kernels and utilizes flags set directly in GPU device memory to "kill" unnecessary kernels, ensuring that the precision logic does not impede execution speed.

Experimental Evaluation

The methodology was evaluated using Random Circuit Sampling (RCS), the standard benchmark for demonstrating quantum advantage. The tests included:

  • Rectangular Lattice Circuits: 4x4 and 9x9 qubit grids with varying depths.
  • Google’s Sycamore Circuit: The 53-qubit circuit utilized in the 2019 quantum supremacy experiment.

Key Results and Insights

The implementation demonstrated significant performance gains over the standard cuBLAS baseline:

  • Throughput: The system achieved a 1.86x speedup for 9x9 qubit circuits and a 1.44x speedup for the Sycamore circuit.
  • Fidelity: Despite the use of mixed-precision hardware, the simulation fidelity remained virtually identical to full FP32 calculations. The authors noted that specific "Round to Nearest" modes were essential for recovering FP32 accuracy.
  • Hardware Efficiency: The custom kernels, optimized for the irregular matrix shapes common in quantum gates, achieved up to 90% of the theoretical peak memory bandwidth on an NVIDIA A100 GPU. In contrast, standard libraries often utilize as little as 10% of the bandwidth for these specific shapes.

Conclusion and Future Work

This research demonstrates that specialized machine learning hardware can be effectively repurposed for high-precision scientific tasks through clever software emulation and dynamic logic. While the current implementation is highly optimized for the NVIDIA Ampere architecture, future work may involve porting these techniques to other hardware platforms. Additionally, the authors suggest that integrating these precision-selection techniques directly into higher-level frameworks like cuTensorNet could further optimize data movement and overall simulation performance.

Summary updated

BibTeX
@inproceedings{ootomo2023quantum,
  author = {Hiroyuki Ootomo and Hidetaka Manabe and Kenji Harada and Rio Yokota},
  title = {{Quantum Circuit Simulation by SGEMM Emulation on Tensor Cores and Automatic Precision Selection}},
  booktitle = {ISC},
  year = {2023},
  doi = {10.1007/978-3-031-32041-5\_14},
}
Figure