quri_parts.circuit.noise.noise_model module#
- class NoiseModel(noises=[])#
Bases:
objectBackend independent noise model that can hold multiple
NoiseInstructionconditions.First, create
NoiseInstructionobjects to specify the noise type and application conditions. Then, given a list of theseNoiseInstruction,NoiseModelcan be created to represent the noise types and application conditions independently of the backend. Finally, when converting to a concrete backend,NoiseModelis given together with theQuantumCircuitto generate a circuit to which noise is applied.Below is an example of using the Qulacs backend.
Examples
NoiseInstructionincludesGateNoiseInstruction, which is applied when a specific gate acts, andCircuitNoiseInstruction, 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_gatesare specified, noise is applied to any of the gates intarget_gates, acting on any of the qubits inqubit_indices.# H or CNOT gate, acting on 1 or 3 index qubit. BitFlipNoise( 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
NoiseInstructionapplied 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"])
- Parameters:
noises (Sequence[NoiseInstruction]) – Sequence of
NoiseInstruction.
- noises_for_gate(gate)#
For a given Gate, search for matching qubit indices and
NoiseInstructionpairs.Returns a list of pairs of qubit indices and
NoiseInstructionthat match the given gate conditions in this noise model. The order of the list is the order in whichNoiseInstructionsare added to the noise model.- Parameters:
gate (QuantumGate) –
QuantumGateto which noises are applied.- Return type:
Iterable[circuit.noise.noise_instruction.QubitNoisePair]
- noises_for_circuit()#
Returns sequence of
CircuitNoiseInstructionin the model.- Return type:
Sequence[CircuitNoiseInstruction]
- add_noise(noise, custom_gate_filter=None)#
Add single
NoiseInstructionto the model and update the state of the model.- Parameters:
noise (circuit.noise.noise_instruction.NoiseInstruction) –
NoiseInstructionto 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:
None
- extend(noises)#
Add multiple
NoiseInstructionto the model and update the state of the model.- Parameters:
noises (Sequence[circuit.noise.noise_instruction.NoiseInstruction]) –
- Return type:
None