Welcome to the Quantum Gates documentation
Quantum Gates is a Python library for simulating the noisy behaviour of real quantum devices. The noise is incorporated directly into the gates, which become stochastic matrices. The corresponding model was published in Di Bartolomeo, 2023 in Physical Review Research.
Note
This project is under active development.
How to install
Requirements
The Python version should be 3.9 or later. We recommend using the library together with a IBM Quantum Lab account, as it necessary for circuit compilation with Qiskit.
Installation as a user
The library is available on the Python Package Index (PyPI) with pip install quantum-gates.
Installation as a contributor
For users who want to contribute to the project or work with the latest source code, we recommend the following steps:
Clone the Repository from Github:
git clone https://github.com/CERN-QTI/quantum-gates.git
Navigate to the project directory:
cd quantum-gates
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install the package in editable Mode:
pip install -e .
Installing in editable mode allows you to work directly with the source code. Any changes you make will be reflected immediately without the need to reinstall the package.
Functionality
Gates
To sample quantum gates with the noise incorporated in them, one can set
up a Gates instance. The methods of this object return the matrices
as numpy array. The sampling is stochastic, and one can set the numpy seed
to always get the same sequence of noise. For finer control over noise, the
gates module also provides CustomNoiseGates,
CustomNoiseChannelsGates and SpecificNoiseGates along with gate sets
like numerical_gates and low_pauli_noise_gates.
Factories
To produce gates, we use factories, such as the CNOTFactory. One can combine factories into a custom gates class. The factories have a construct() method, with a well documented signature.
Pulses
When constructing a set of quantum gates with the Gates class, one can specify a Pulse instance. This pulse describes the shape of the RF pulses used to implement the gates.
Integrators
Behind the scenes, we solve Ito integrals to deal with the different pulse shapes. This is handled by the integrator.
Simulators
The MrAndersonSimulator can be used to simulate a quantum circuit transpiled with Qiskit with a specific noisy gate set.
Backends
For the computation, we provide backends out of the box, such as the EfficientBackend that uses optimized tensor contractions to simulate 20+ qubits with the statevector method.
Circuits
The simulators can be configured with a Circuits class, such as
EfficientCircuit. This class is responsible for sampling the
noisy gates. The class can be configured with a Gates instance and one of
the Backends that executes the statevector simulation. The circuit
classes also support mid-circuit measurement (mid_measurement), reset
gates (reset), and direct state-vector readout (statevector_readout).
Quantum Algorithms
Four quantum algorithms are provided as functions which return the Qiskit circuit for a specific number of qubits
Hadamard reverse QFT circuit
GHZ circuit
QFT circuit
Quantum Approximate Optimization Algorithm circuit
Legacy
We also provide the legacy implementations of the gates, simulator and circuit classes. They can be used for unit testing.
Utility
In performing quantum simulation, there are many steps that are performed repeatedly, such as setup the IBM backend with setup_backend(), loading the noise information as DeviceParameters, transpiling the quantum circuits with create_qc_list(), and executing the simulation in parallel with multiprocessing_parallel_simulation() on a powerful machine. For this reason, the most frequently used functions are part of the utilities.
Metrics
The metrics module provides helpers like
hellinger_distance for comparing simulated and reference distributions.
Qiskit Provider
The library exposes a Qiskit provider so existing Qiskit code can run noisy simulations without touching the call sites.
Structure
Pulses
Integrators
Simulators
Backends
Quantum Algorithm
Legacy
Utilities
Metrics
Qiskit Provider
Indices and tables
Citation
You may cite this library using the following BibTex entry:
@article{PhysRevResearch.5.043210,
title = {Noisy gates for simulating quantum computers},
author = {Di Bartolomeo, Giovanni and Vischi, Michele and Cesa, Francesco and Wixinger, Roman and Grossi, Michele and Donadi, Sandro and Bassi, Angelo},
journal = {Phys. Rev. Res.},
volume = {5},
issue = {4},
pages = {043210},
numpages = {19},
year = {2023},
month = {Dec},
publisher = {American Physical Society},
doi = {10.1103/PhysRevResearch.5.043210},
url = {https://link.aps.org/doi/10.1103/PhysRevResearch.5.043210}
}