- class quri_parts.circuit.noise.noise_model.NoiseModel(noises: Sequence[CircuitNoiseInstruction | GateNoiseInstruction] = )#
Backend independent noise model that can hold multiple
NoiseInstructionobjects to specify the noise type and application conditions. Then, given a list of these
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 the
QuantumCircuitto generate a circuit to which noise is applied.
Below is an example of using the Qulacs backend.
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_gatesare specified, noise is applied to any of the gates in
target_gates, acting on any of the qubits in
# 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=)
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"])
noises – Sequence of
- noises_for_gate(gate: QuantumGate) Iterable[tuple[Sequence[int], GateNoiseInstruction]] #
For a given Gate, search for matching qubit indices and
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 which
NoiseInstructionsare added to the noise model.
QuantumGateto which noises are applied.
- noises_for_circuit() Sequence[CircuitNoiseInstruction] #
Returns sequence of
CircuitNoiseInstructionin the model.
- add_noise(noise: CircuitNoiseInstruction | GateNoiseInstruction, custom_gate_filter: Callable[[QuantumGate], bool] | None = None) None #
NoiseInstructionto the model and update the state of the model.
NoiseInstructionto be added to the model.
custom_gate_filter – (If specified) Additional condition to determine if the noise is applied to the target gate.