High-performance quantum circuit simulator for C++ and Python.
Features – Usage – Documentation – Citing qsim – Contact
qsim is a state-vector simulator for quantum circuits. Also known as a Schrödinger simulator, it represents a quantum state as a vector of complex-valued amplitudes (a state vector) and applies matrix-vector multiplication to simulate transformations that evolve the state over time.
qsim was used to produce landmark cross-entropy benchmark results published in 2019 (Arute et al., "Quantum Supremacy Using a Programmable Superconducting Processor", Nature vol. 574, 2019).
Being a full state-vector simulator means that qsim computes all the 2 n amplitudes of the state vector, where n is the number of qubits. The total runtime is proportional to g2n, where g is the number of 2-qubit gates.
-
To speed up simulation, qsim uses gate fusion (Smelyanskiy et al., arXiv:1601.07195, 2016; Häner and Steiger, arXiv:1704.01127, 2017), single-precision arithmetic, AVX/FMA instructions for vectorization, and OpenMP for multithreading (on hardware that provides those features).
-
qsim is highly tuned to take advantage of vector arithmetic instruction sets and multithreading on computers that provide them, as well as GPUs when available.
-
qsim includes a Cirq interface (
qsimcirq) and can be used to simulate quantum circuits written in Cirq.
The code is designed as a library that can be included in users' applications. The sample applications provided in the qsim apps directory can be used as starting points. More information about the sample applications can be found in the qsim documentation.
The qsim-Cirq Python interface is called qsimcirq and is available as a PyPI
package for Linux, MacOS and Windows users. It can be installed by using the
following command:
pip install qsimcirqNote: The core qsim library (located in the source repository under the
lib/ subdirectory) can
be included directly in C++ programs without installing the Python interface.
Cirq is a framework for modeling and invoking Noisy Intermediate-Scale Quantum (NISQ) circuits. Cirq can use qsim as its simulation library. To get started with simulating Cirq circuits using qsim, please refer to the tutorial.
More detailed information about the qsim-Cirq API can be found in the docs.
Unit tests for C++ libraries use the GoogleTest framework, and are located in tests. Python tests use pytest, and are located in qsimcirq_tests.
To build and run all tests, run:
make run-testsThis will compile all test binaries to files with .x extensions, and run each
test in series. Testing will stop early if a test fails. It will also run tests
of the qsimcirq python interface. To run C++ or python tests only, run
make run-cxx-tests or make run-py-tests, respectively.
To clean up generated test files, run make clean from the test directory
Please visit the qsim documentation site guides, tutorials, and API reference documentation.
When publishing articles or otherwise writing about qsim, please cite the qsim version you use – it will help others reproduce your results. We use Zenodo to preserve releases. The following links let you download the bibliographic record for the latest stable release of qsim in some popular formats:
For formatted citations and records in other formats, as well as records for all releases of qsim past and present, please visit the qsim page on Zenodo.
For any questions or concerns not addressed here, please email quantum-oss-maintainers@google.com.
This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.
Copyright 2019 Google LLC.