Noise Models
qiskit.providers.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 to automatically generate a basic device noise model for an IBMQ backend.
Device Noise Models
A simplified approximate NoiseModel
can be generated automatically from the properties of real device backends from the IBMQ provider using the NoiseModel.from_backend()
method. See the method documentation for details.
Example: Basic device noise model
from qiskit import QuantumCircuit, execute
from qiskit import IBMQ, Aer
from qiskit.visualization import plot_histogram
from qiskit.providers.aer.noise import NoiseModel
# Build noise model from backend properties
provider = IBMQ.load_account()
backend = provider.get_backend('ibmq_vigo')
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
result = execute(circ, Aer.get_backend('qasm_simulator'),
coupling_map=coupling_map,
basis_gates=basis_gates,
noise_model=noise_model).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, execute, Aer
from qiskit.visualization import plot_histogram
import qiskit.providers.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
result = execute(circ, Aer.get_backend('qasm_simulator'),
basis_gates=basis_gates,
noise_model=noise_model).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 Qiskit Aer simulators. |
QuantumError (noise_ops[, number_of_qubits, …]) | Quantum error class for Qiskit Aer noise model |
ReadoutError (probabilities[, atol]) | Readout error class for Qiskit 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[, standard_gates]) | Return a mixed Pauli quantum error channel. |
depolarizing_error (param, num_qubits[, …]) | Return a depolarizing quantum error channel. |
pauli_error (noise_ops[, standard_gates]) | Return a mixed Pauli quantum error channel. |
mixed_unitary_error (noise_ops[, standard_gates]) | 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[, standard_gates, …]) | 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 (func[, op_types, method]) | Transpiler pass to insert noise into a circuit. |
RelaxationNoisePass (t1s, t2s[, dt, …]) | 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 (properties) | Return readout error parameters from a devices BackendProperties. |
device.basic_device_gate_errors (properties) | Return QuantumErrors derived from a devices BackendProperties. |
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. |