quri_parts.circuit.noise.noise_model module#

class NoiseModel(noises=[])#

Bases: object

Backend independent noise model that can hold multiple NoiseInstruction conditions.

First, create NoiseInstruction objects to specify the noise type and application conditions. Then, given a list of these NoiseInstruction, NoiseModel can be created to represent the noise types and application conditions independently of the backend. Finally, when converting to a concrete backend, NoiseModel is given together with the QuantumCircuit to generate a circuit to which noise is applied.

Below is an example of using the Qulacs backend.


NoiseInstruction includes GateNoiseInstruction, which is applied when a specific gate acts, and CircuitNoiseInstruction, which is applied depending on the circuit structure.

When creating a GateNoiseInstruction, qubit indices and the type of gate can be specified in common, along with the parameters of each noise. The following explains how to specify the conditions for applying noise, using several concrete examples.

If both qubit_indices and target_gates are specified, noise is applied to any of the gates in target_gates, acting on any of the qubits in qubit_indices.

# H or CNOT gate, acting on 1 or 3 index qubit.
    error_prob=0.002, qubit_indices=[1, 3], target_gates=["H", "CNOT"]

An empty list matches everything.

# Any gate, acting on 1 or 3 index qubit.
BitFlipNoise(error_prob=0.002, qubit_indices=[1, 3], target_gates=[])

# H or CNOT gate, acting on any qubit.
BitFlipNoise(error_prob=0.002, qubit_indices=[], target_gates=["H", "CNOT"])

# Any gate, acting on any qubit.
BitFlipNoise(error_prob=0.002, qubit_indices=[], target_gates=[])

For NoiseInstruction applied to multiple qubits, qubit_indices must be a set equal to qubit indices on which the target gate acts.

# Match with CNOT(0, 2) and CNOT(2, 0).
PauliNoise([[1, 2], [2, 3]], [0.001, 0.002], [2, 0], ["CNOT"])

# Match with Pauli(1, 2, 3), Pauli(1, 3, 2), Pauli(2, 1, 3),
# Pauli(2, 3, 1), Pauli(3, 1, 2), and Pauli(3, 2, 1).
GeneralDepolarizingNoise(0.004, [1, 2, 3], ["Pauli"])

noises (Sequence[NoiseInstruction]) – Sequence of NoiseInstruction.


For a given Gate, search for matching qubit indices and NoiseInstruction pairs.

Returns a list of pairs of qubit indices and NoiseInstruction that match the given gate conditions in this noise model. The order of the list is the order in which NoiseInstructions are added to the noise model.


gate (QuantumGate) – QuantumGate to which noises are applied.

Return type:



Returns sequence of CircuitNoiseInstruction in the model.

Return type:


add_noise(noise, custom_gate_filter=None)#

Add single NoiseInstruction to the model and update the state of the model.

  • noise (circuit.noise.noise_instruction.NoiseInstruction) – NoiseInstruction to be added to the model.

  • custom_gate_filter (Callable[[QuantumGate], bool] | None) – (If specified) Additional condition to determine if the noise is applied to the target gate.

Return type:



Add multiple NoiseInstruction to the model and update the state of the model.


noises (Sequence[circuit.noise.noise_instruction.NoiseInstruction]) –

Return type: