Skip to content

quantumlib/qsim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

qsim

High-performance quantum circuit simulator for C++ and Python.

Licensed under the Apache 2.0 license C++ qsim project on PyPI Compatible with Python versions 3.10 and higher Archived in Zenodo

FeaturesUsageDocumentationCiting qsimContact

qsim is a state-vector simulator for quantum circuits. It 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 also provides a Cirq interface (qsimcirq) and can be used to simulate quantum circuits written in Cirq.

Introduction

qsim is a Schrödinger full state-vector simulator: it models quantum computations by representing the quantum state of a system as a vector of complex numbers (a state vector) and evolving it through the application of quantum gates. One matrix-vector multiplication corresponds to the application of one gate. Essentially, the simulator performs matrix-vector multiplications repeatedly.

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 g2 n, 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 was used to produce landmark cross-entropy benchmarking results published in 2019 (Arute et al., "Quantum Supremacy Using a Programmable Superconducting Processor", Nature vol. 574, 2019).

Usage

C++ usage

The code is basically designed as a library. The user can modify sample applications in apps to meet their own needs. The usage of sample applications is described in the docs.

Python usage

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 qsimcirq

qsimcirq is also available for Conda for Linux and MacOS. To install it from conda-forge, you can use the following command:

conda install -c conda-forge qsimcirq

Note: 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 usage

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.

Input format

Warning

This format is deprecated, and no longer actively maintained.

The circuit input format is described in the docs.

Sample circuits

A number of sample circuits are provided in circuits.

Unit tests

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-tests

This 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

qsim documentation

Please visit the qsim documentation site guides, tutorials, and API reference documentation.

How to cite qsim

Qsim is uploaded to Zenodo automatically. Click on this badge DOI to see all the citation formats for all versions.

An equivalent BibTeX format reference is below for all the versions:

@software{quantum_ai_team_and_collaborators_2020_4023103,
  author       = {Quantum AI team and collaborators},
  title        = {qsim},
  month        = Sep,
  year         = 2020,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.4023103},
  url          = {https://doi.org/10.5281/zenodo.4023103}
}

Contact

For any questions or concerns not addressed here, please email quantum-oss-maintainers@google.com.

Disclaimer

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.