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.
|
Noise model class for Aer simulators. |
|
Quantum error class for Aer noise model |
|
A Pauli channel generated by a Pauli Lindblad dissipator. |
|
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
.
|
Return a mixed Pauli quantum error channel. |
|
Return a depolarizing quantum error channel. |
|
Return a mixed unitary quantum error channel. |
|
Return a coherent unitary quantum error channel. |
|
Return a single qubit reset quantum error channel. |
|
Return a single-qubit generalized amplitude damping quantum error channel. |
|
Return a single-qubit generalized phase damping quantum error channel. |
|
Return a single-qubit combined phase and amplitude damping quantum error channel. |
|
Return a single-qubit thermal relaxation quantum error channel. |
|
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.
|
Transpiler pass to insert noise into a circuit. |
|
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.
Return readout error parameters from either of device Target or BackendProperties. |
|
Return QuantumErrors derived from either of a devices BackendProperties or Target. |
|
|
Return parameter error values from a devices BackendProperties. |
|
Return gate error values from a devices BackendProperties. |
|
Return gate length values from a devices BackendProperties. |
|
Return readout error values from a devices BackendProperties. |
|
Return T1, T2 and frequency values from a devices BackendProperties. |