Noise Models (qiskit_aer.noise)#

This module contains classes and functions to build a noise model for simulating a Qiskit quantum circuit in the presence of errors.

Building Noise Models#

The NoiseModel class is used to represent noise model for the QasmSimulator. It can be used to construct custom noise models for simulator, to automatically generate a basic device noise model for an IBMQ or fake backend.

Device Noise Models#

A simplified approximate NoiseModel can be generated automatically from the properties of real device backends from the IBMQ provider or fake backends of the fake_provider using the NoiseModel.from_backend() method. See the method documentation for details.

Example: Basic device noise model

from qiskit import IBMQ
from qiskit.providers.aer.noise import NoiseModel
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram
from qiskit_aer.noise import NoiseModel

# Make a circuit
circ = QuantumCircuit(3, 3)
circ.h(0)
circ.cx(0, 1)
circ.cx(1, 2)
circ.measure([0, 1, 2], [0, 1, 2])

# Get the noise model of ibmq_lima
provider = IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
backend_lima = provider.get_backend('ibmq_lima')
noise_model = NoiseModel.from_backend(backend_lima)

# Get coupling map from backend
coupling_map = backend_lima.configuration().coupling_map

# Get basis gates from noise model
basis_gates = noise_model.basis_gates

# Perform a noise simulation
backend = AerSimulator(noise_model=noise_model,
                       coupling_map=coupling_map,
                       basis_gates=basis_gates)
transpiled_circuit = transpile(circ, backend)
result = backend.run(transpiled_circuit).result()

counts = result.get_counts(0)
plot_histogram(counts)

Example: Basic device noise model using a `fake_provider` backend

from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram
from qiskit_aer.noise import NoiseModel
from qiskit.providers.fake_provider import FakeVigo

# Build noise model from backend properties
backend = FakeVigo()
noise_model = NoiseModel.from_backend(backend)

# Get coupling map from backend
coupling_map = backend.configuration().coupling_map

# Get basis gates from noise model
basis_gates = noise_model.basis_gates

# Make a circuit
circ = QuantumCircuit(3, 3)
circ.h(0)
circ.cx(0, 1)
circ.cx(1, 2)
circ.measure([0, 1, 2], [0, 1, 2])

# Perform a noise simulation
backend = AerSimulator(noise_model=noise_model,
                       coupling_map=coupling_map,
                       basis_gates=basis_gates)
transpiled_circuit = transpile(circ, backend)
result = backend.run(transpiled_circuit).result()

counts = result.get_counts(0)
plot_histogram(counts)

Custom Noise Models#

Custom noise models can be used by adding QuantumError to circuit gate, reset or measure instructions, and ReadoutError to measure instructions. This module includes several helper functions for generating QuantumError instances based on canonical error models used in Quantum Information Theory that can simplify building noise models. See the documentation for the NoiseModel class for additional details.

Example: depolarizing noise model

from qiskit import QuantumCircuit, transpile, Aer
from qiskit.visualization import plot_histogram
from qiskit_aer import AerSimulator
import qiskit_aer.noise as noise

# Error probabilities
prob_1 = 0.001  # 1-qubit gate
prob_2 = 0.01   # 2-qubit gate

# Depolarizing quantum errors
error_1 = noise.depolarizing_error(prob_1, 1)
error_2 = noise.depolarizing_error(prob_2, 2)

# Add errors to noise model
noise_model = noise.NoiseModel()
noise_model.add_all_qubit_quantum_error(error_1, ['u1', 'u2', 'u3'])
noise_model.add_all_qubit_quantum_error(error_2, ['cx'])

# Get basis gates from noise model
basis_gates = noise_model.basis_gates

# Make a circuit
circ = QuantumCircuit(3, 3)
circ.h(0)
circ.cx(0, 1)
circ.cx(1, 2)
circ.measure([0, 1, 2], [0, 1, 2])

# Perform a noise simulation
backend = AerSimulator(noise_model=noise_model,
                       coupling_map=coupling_map,
                       basis_gates=basis_gates)
transpiled_circuit = transpile(circ, backend)
result = backend.run(transpiled_circuit).result()

counts = result.get_counts(0)
plot_histogram(counts)

Classes#

The following are the classes used to represented noise and error terms.

NoiseModel([basis_gates])

Noise model class for Aer simulators.

QuantumError(noise_ops)

Quantum error class for Aer noise model

PauliLindbladError(generators, rates)

A Pauli channel generated by a Pauli Lindblad dissipator.

ReadoutError(probabilities[, atol])

Readout error class for Aer noise model.

Quantum Error Functions#

The following functions can be used to generate many common types of QuantumError objects for inclusion in a NoiseModel.

pauli_error(noise_ops)

Return a mixed Pauli quantum error channel.

depolarizing_error(param, num_qubits)

Return a depolarizing quantum error channel.

mixed_unitary_error(noise_ops)

Return a mixed unitary quantum error channel.

coherent_unitary_error(unitary)

Return a coherent unitary quantum error channel.

reset_error(prob0[, prob1])

Return a single qubit reset quantum error channel.

amplitude_damping_error(param_amp[, ...])

Return a single-qubit generalized amplitude damping quantum error channel.

phase_damping_error(param_phase[, ...])

Return a single-qubit generalized phase damping quantum error channel.

phase_amplitude_damping_error(param_amp, ...)

Return a single-qubit combined phase and amplitude damping quantum error channel.

thermal_relaxation_error(t1, t2, time[, ...])

Return a single-qubit thermal relaxation quantum error channel.

kraus_error(noise_ops[, canonical_kraus])

Return a Kraus quantum error channel.

Noise Transpiler Passes#

These transpiler passes can be used to build noise models that can be applied to circuits via transpilation.

LocalNoisePass(*args, **kwargs)

Transpiler pass to insert noise into a circuit.

RelaxationNoisePass(*args, **kwargs)

Add duration dependent thermal relaxation noise after instructions.

Device Noise Parameters#

The following are utility functions which can be used for extracting error parameters and error objects from device BackendProperties.

device.basic_device_readout_errors([...])

Return readout error parameters from either of device Target or BackendProperties.

device.basic_device_gate_errors([...])

Return QuantumErrors derived from either of a devices BackendProperties or Target.

device.gate_param_values(properties)

Return parameter error values from a devices BackendProperties.

device.gate_error_values(properties)

Return gate error values from a devices BackendProperties.

device.gate_length_values(properties)

Return gate length values from a devices BackendProperties.

device.readout_error_values(properties)

Return readout error values from a devices BackendProperties.

device.thermal_relaxation_values(properties)

Return T1, T2 and frequency values from a devices BackendProperties.