# Speeding up simulations of quantum circuits

**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.

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*.

### 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.