qml.from_qiskit_noise

from_qiskit_noise(noise_model, verbose=False, decimal_places=None)[source]

Converts a Qiskit NoiseModel into a PennyLane NoiseModel.

Parameters
  • noise_model (qiskit_aer.noise.NoiseModel) – a Qiskit NoiseModel instance.

  • verbose (bool) – when printing a NoiseModel, a complete list of Kraus matrices for each qml.QubitChannel is displayed with verbose=True. By default, verbose=False and only the number of Kraus matrices and the number of qubits they act on is displayed for brevity.

  • decimal_places (int | None) – number of decimal places to round the elements of Kraus matrices when they are being displayed for each qml.QubitChannel when verbose=True.

Returns

The PennyLane noise model converted from the input Qiskit NoiseModel object.

Return type

qml.NoiseModel

Raises

ValueError – When a quantum error present in the noise model cannot be converted.

Note

  • This function depends upon the PennyLane-Qiskit plugin, which can be installed following these installation instructions. You may need to restart your kernel if you are running it in a notebook environment.

  • Each quantum error present in the qiskit noise model is converted into an equivalent QubitChannel operator with the same canonical Kraus representation.

  • Currently, PennyLane noise models do not support readout errors, so those will be skipped during conversion.

Example

Consider the following noise model constructed in Qiskit:

>>> import qiskit_aer.noise as noise
>>> error_1 = noise.depolarizing_error(0.001, 1) # 1-qubit noise
>>> error_2 = noise.depolarizing_error(0.01, 2) # 2-qubit noise
>>> noise_model = noise.NoiseModel()
>>> noise_model.add_all_qubit_quantum_error(error_1, ['rz', 'ry'])
>>> noise_model.add_all_qubit_quantum_error(error_2, ['cx'])

This noise model can be converted into PennyLane using:

>>> import pennylane as qml
>>> qml.from_qiskit_noise(noise_model)
NoiseModel({
    OpIn(['RZ', 'RY']): QubitChannel(num_kraus=4, num_wires=1)
    OpIn(['CNOT']): QubitChannel(num_kraus=16, num_wires=2)
})

Contents

Using PennyLane

Release news

Development

API

Internals