qsim and qsimh

qsim and qsimh are a collection of C++ libraries for quantum circuit simulation. These libraries provide powerful, low-cost tools for researchers to test quantum algorithms before running on quantum hardware.

qsim makes use of AVX/FMA vector operations, OpenMP multithreading, and gate fusion [1] [2] to accelerate simulations. This performance is best demonstrated by the use of qsim in cross-entropy benchmarks [3].

Integration with Cirq makes getting started with qsim easy! Check out the installation guide or try the runnable notebook tutorial.

Design

The git repository for qsim includes three libraries for simulation:

  • qsim is a Schrödinger state-vector simulator designed to run on a single machine. It produces the full state vector as output which, for instance, allows users to sample repeatedly from a single execution.
  • qsimh is a hybrid Schrödinger-Feynman simulator built for parallel execution on a cluster of machines. It produces amplitudes for user-specified output bitstrings. Compared to qsim, by limiting what it returns, qsimh can simulate more qubits.
  • MPS is a truncated Matrix Product State simulator. Instead of storing the full state vector, it represents the quantum state as a chain of small tensors — one per qubit — connected by a configurable "bond dimension". This makes it much more memory-efficient for circuits with low entanglement (such as shallow or 1D-structured circuits), at the cost of being approximate for highly entangled states. See the MPS simulator docs for details.

These libraries can be invoked either directly or through the qsim-Cirq interface to perform the following operations:

  • Determine the final state vector of a circuit (qsim only).
  • Sample results from a circuit. Multiple samples can be generated with minimal additional cost for circuits with no intermediate measurements (qsim only).
  • Calculate amplitudes for user-specified result bitstrings. With qsimh, this is trivially parallelizable across several machines.
  • Simulate circuits with low entanglement at reduced memory cost (MPS only, C++ only).

Circuits of up to 30 qubits can be simulated in qsim with ~16GB of RAM; each additional qubit doubles the RAM requirement. In contrast, careful use of qsimh can support 50 qubits or more.

[1] M. Smelyanskiy, N. P. Sawaya, A. Aspuru-Guzik, "qHiPSTER: The Quantum High Performance Software Testing Environment", arXiv:1601.07195 (2016).

[2] T. Häner, D. S. Steiger, "0.5 Petabyte Simulation of a 45-Qubit Quantum Circuit", arXiv:1704.01127 (2017).

[3], F. Arute et al, "Quantum Supremacy Using a Programmable Superconducting Processor", Nature 574, 505, (2019).