SkillAgentSearch skills...

Qsim

Fast C++ and Python library for state-vector simulation of quantum circuits.

Install / Use

/learn @quantumlib/Qsim

README

<div align="center">

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

</div>

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

Features

Being a full state-vector simulator means that qsim computes all the 2<sup> n</sup> amplitudes of the state vector, where n is the number of qubits. The total runtime is proportional to g2<sup>n</sup>, 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.

Usage

C++ usage

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.

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

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.

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

Documentation

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

How to cite qsim<a name="citing-qsim"></a><a name="how-to-cite"></a>

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:

<div align="center">

Download BibTeX bibliography record for latest qsim
release   Download CSL JSON bibliography record for latest qsim
release

</div>

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.

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.

<div align="center"> <a href="https://quantumai.google"> <img width="15%" alt="Google Quantum AI" src="https://raw.githubusercontent.com/quantumlib/Cirq/refs/heads/main/docs/images/quantum-ai-vertical.svg"> </a> </div>
View on GitHub
GitHub Stars647
CategoryDevelopment
Updated6d ago
Forks200

Languages

C++

Security Score

100/100

Audited on Mar 19, 2026

No findings