Speeding up simulations of quantum circuits

FLOPS measurement taken from the cluster monitoring. The segments without floating-point operations indicate that a substantial amount of time is spent between individual simulation runs.

Background

A possible application for near-term quantum computers is the simulation of quantum systems, e.g., in condensed-matter physics. Here, the user considered the dynamics of an Ising system driven out of equilibrium by a periodic perturbation, and compared different approximations by simulating the corresponding quantum circuits for manageable system sizes (20 qubits). The model is formulated using the python library Cirq and then passed to the simulator qsim written in C++.

Calculations were carried out as single-node jobs on the Woody cluster. In the cluster monitoring, the jobs showed relatively poor performance with strongly fluctuating FLOPS and vectorization values.

 Analysis

Profiling data indicated most of the compute time is spent on translating the quantum circuit from the Cirq to the qsim format, and not on the actual simulations.  Analyzing the Cirq-qsim interface function revealed that this happens because most gates occurring in the quantum circuits belong to a class not supported by qsim and first need to be decomposed.

The Ryy gate is supported by qsim, but the corresponding Pauli phasor object does not get recognized. Instead it is decomposed as shown, which causes a significant increase of the runtime if many of such gates appear in the circuit.

These gates, called Pauli phasors, appear when approximating the time-evolution operator of a general Hamiltonian by a Suzuki-Trotter decomposition. For the Hamiltonians studied here, however, only specific Pauli phasors are needed and those are in fact equivalent to standard gates supported by qsim.

Contributions to the runtime for the simulation of a typical quantum circuit considered by the user.

Optimization

By avoiding the use of Pauli phasors and formulating the quantum circuit in terms of more specialized gates, the time needed for the conversion between Cirq and qsim becomes negligible. Additional optimizations can be done to reduce the time spent on constructing the quantum circuits in Cirq.

Summary

Simulations of quantum circuits were sped up by significantly reducing the overhead due to the conversion of the circuits between Cirq and the external simulator qsim. For the considered model and systems of 20 qubits, the overall speedup factor is about 4–5. This is achieved by reducing the operations done in python/Cirq without modifying the actual simulation code of the qsim library.