# 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-IT-INNOVATION/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.

### 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 LegacyMrAndersonSimulator 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.

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

## Structure

## Indices and tables

## Citation

You may cite this library using the following BibTex entry: