Noisy Simulations

Quantum systems are subject to noise during computations, from application of gates, imperfection of the measurement or an interaction with the environment. Being able to simulate and validate quantum algorithms in a noisy setup is crucial in the direction of achieving any advantage on current NISQ machines. This section provides an overview on how to instantiate noise models, how to specify target qubits and gates, and what are the predefined noise models.

We strongly encourage the user to have a look at the dedicated notebook, where all the details about the manipulation, usage, and simulation of noise models are presented.

from mpqp.noise import *

Note

Noisy simulations are, for the moment, only supported for QLM and AWS Braket devices.

Noise models

In order to represent a general noise model, we introduce the abstract class NoiseModel. It regroups all the attributes and methods common to all predefined noise models.

While currently abstract, the class is designed with extensibility in mind to support parameterized noise models in the future. This feature will enable users to define noise models with adjustable parameters, offering greater flexibility in simulating and analyzing the effects of noise on quantum circuits.

class NoiseModel(targets, gates=None)[source]

Bases: ABC

Abstract class used to represent a generic noise model, specifying criteria for applying different noise type to a quantum circuit, or some of its qubits.

It allows to specify which qubits (targets) and which gates of the circuit will be affected with this noise model.

Parameters
  • targets (list[int]) – List of qubit indices affected by this noise.

  • gates (Optional[list[type[Gate]]]) – List of Gates affected by this noise.

Raises
  • ValueError – When target list is empty, or target indices are duplicated

  • or negative. When the size of the gate is higher than the number of target qubits.

connections()[source]

Returns the indices of the qubits connected to the noise model (affected by the noise).

Returns

Set of qubit indices on which this NoiseModel is connected (applied on).

Return type

set[int]

to_other_language(language)[source]

Transforms this noise model into the corresponding object in the language specified in the language arg.

In the current version, only Braket and my_QLM are available for conversion.

Parameters

language (Language) – Enum representing the target language.

Returns

The corresponding noise model (or channel) in the target language.

Return type

BraketNoise | QLMNoise

gates

List of specific gates after which this noise model will be applied.

targets

List of target qubits that will be affected by this noise model.

Note

Only the predefined Depolarizing noise model is available for the moment. More will come in the future.

Depolarizing Noise Model

class Depolarizing(prob, targets, dimension=1, gates=None)[source]

Bases: NoiseModel

Class representing the depolarizing noise channel, which maps a state onto a linear combination of itself and the maximally mixed state. It can applied to a single or multiple qubits, and depends on a single parameter (probability or error rate).

When the number of qubits in the target is higher than the dimension, the noise will be applied to all possible combinations of indices of size dimension.

Parameters
  • prob (float) – Depolarizing error probability or error rate.

  • targets (list[int]) – List of qubit indices affected by this noise.

  • dimension (int) – Dimension of the depolarizing channel.

  • gates (Optional[list[type[Gate]]]) – List of Gates affected by this noise.

Raises
  • ValueError – When a wrong dimension (negative) or probability (outside of the expected interval) is input.

  • ValueError – When the size of the specified gates is not coherent with the number of targets or the dimension.

Examples

>>> circuit = QCircuit([H(i) for i in range(3)])
>>> d1 = Depolarizing(0.32, list(range(circuit.nb_qubits)))
>>> d2 = Depolarizing(0.05, [0, 1], dimension=2)
>>> d3 = Depolarizing(0.12, [2], gates=[H, Rx, Ry, Rz])
>>> d4 = Depolarizing(0.05, [0, 1, 2], dimension=2, gates=[CNOT, CZ])
>>> circuit.add([d1, d2, d3, d4])
>>> print(circuit)  
     ┌───┐
q_0: ┤ H ├
     ├───┤
q_1: ┤ H ├
     ├───┤
q_2: ┤ H ├
     └───┘
NoiseModel:
    Depolarizing(0.32, [0, 1, 2], 1)
    Depolarizing(0.05, [0, 1], 2)
    Depolarizing(0.12, [2], 1, [H, Rx, Ry, Rz])
    Depolarizing(0.05, [0, 1, 2], 2, [CNOT, CZ])
to_other_language(language=Language.QISKIT)[source]

See documentation of this method in abstract mother class NoiseModel.

Parameters

language (Language) – Enum representing the target language.

Return type

BraketNoise | TwoQubitDepolarizing | QLMNoise

Examples

>>> braket_depo = Depolarizing(0.3, [0,1], dimension=1).to_other_language(Language.BRAKET)
>>> braket_depo
Depolarizing('probability': 0.3, 'qubit_count': 1)
>>> type(braket_depo)
<class 'braket.circuits.noises.Depolarizing'>
>>> qlm_depo = Depolarizing(0.3, [0,1], dimension=1).to_other_language(Language.MY_QLM)
>>> print(qlm_depo)  
Depolarizing channel, p = 0.3:
[[0.83666003 0.        ]
 [0.         0.83666003]]
[[0.        +0.j 0.31622777+0.j]
 [0.31622777+0.j 0.        +0.j]]
[[0.+0.j         0.-0.31622777j]
 [0.+0.31622777j 0.+0.j        ]]
[[ 0.31622777+0.j  0.        +0.j]
 [ 0.        +0.j -0.31622777+0.j]]
>>> type(qlm_depo)
<class 'qat.quops.quantum_channels.QuantumChannelKraus'>
dimension

Dimension of the depolarizing noise model.

proba

Probability, or error rate, of the depolarizing noise model.