qsim and qsimh

Optimized quantum circuit simulators
import cirq
import qsimcirq

# Pick up to ~25 qubits to simulate (requires ~256MB of RAM)
qubits = [cirq.GridQubit(i,j) for i in range(5) for j in range(5)]

# Define a circuit to run
# (Example is from the 2019 "Quantum Supremacy" experiement)
circuit = cirq.experiments.
    qubits=qubits, depth=16)

# Measure qubits at the end of the circuit
circuit.append(cirq.measure(*qubits, key='all_qubits'))

# Simulate the circuit with qsim and return just the measurement values
# just like you would with Cirq
qsim_simulator = qsimcirq.QSimSimulator()
qsim_results = qsim_simulator.run(circuit, repetitions=5)
print('qsim results:')


qsim is a full wave function simulator written in C++. It uses gate fusion, AVX/FMA vectorized instructions and multi-threading using OpenMP to achieve state of the art simulations of quantum circuits. qsim is integrated with Cirq and can be used to run simulations of up to 40 qubits on a 90 core Intel Xeon workstation.


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.

Features and updates

qsim is a full wavefunction simulator that has been optimized to support vectorized operations and multi-threading.
qsimh is a hybrid Schrödinger-Feynman simulator. It simulates separate disjoint sets of qubit using a full wave vector simulator, and then uses Feynman paths to sum over gates that span the sets.
Cirq is a python framework for writing, simulating, and executing quantum programs. Cirq’s built in simulator is useful to around 20 qubits. By using the qsim Cirq simulator one can boost the number of qubits simulated to be mostly limited by available ram. Up to 40 qubits can be simulated on a 90 core Intel Xeon workstation.
Learn how to simulate up to 38 qubits on Google Cloud’s Compute Engine. qsim has a prepackaged docker image that allows easy deployment of qsim, Juypter, and Cirq onto a virtual machine.