quri_parts.circuit.noise.noise_instruction module#
- NoiseInstruction#
Represents a backend-independent noise instruction to be added to NoiseModel.
alias of
Union
[CircuitNoiseInstruction
,GateNoiseInstruction
]
- class CircuitNoiseInstruction(name)#
Bases:
ABC
Represents the noise applied depending on the structure of the circuit.
- Parameters:
name (str) –
- property name: str#
- abstract create_resolver()#
Returns new
CircuitNoiseResolverProtocol
instance for each concrete class ofCircuitNoiseInstruction
.When converting from the original circuit to a circuit with the noise model applied for each backend,
noises_for_gate()
method andnoises_for_depth()
method ofCircuitNoiseResolverProtocol
are called for each gate while scanning the circuit from front to back, returning the noises that needs to be applied to each position in the circuit.- Return type:
- class CircuitNoiseResolverProtocol(*args, **kwargs)#
Bases:
Protocol
This is an helper object used when a quantum circuit is converted into a concrete backend circuit.
- noises_for_gate(gate, index, circuit)#
Returns the noises that should be inserted at the
index
position in the original circuit by being called with thegate
from the front while scanning the circuit.Each
CircuitNoiseInstruction
must implement its ownTraversalIndicatorProtocol
and must returns the instance bycreate_traversal_indicator()
method.- Parameters:
gate (QuantumGate) –
QuantumGate
at index position.index (int) – An index indicating the position of the gate in the circuit.
circuit (NonParametricQuantumCircuit) – Reference of the target circuit.
- Return type:
Sequence[circuit.noise.noise_instruction.QubitNoisePair]
- noises_for_depth(qubit, depths, circuit)#
Returns qubit and noise pairs that shoud be applied to the
qubit
withindepths
.For each qubit, it is assumed that this function will be called each time the depth is progressed by each gate or the scan reaches to the end of the circuit while scanning from the front.
- Parameters:
qubit (int) – Target qubit indice.
depths (Sequence[int]) – Sequence of progressed depths of
qubit
.circuit (NonParametricQuantumCircuit) – Reference of the target circuit.
- Return type:
Sequence[circuit.noise.noise_instruction.QubitNoisePair]
- class GateNoiseInstruction(name, qubit_count, params, qubit_indices, target_gates)#
Bases:
object
Represents the noise that is applied when individual gates act on qubits.
- Parameters:
name (str) –
qubit_count (int) –
params (tuple[float, ...]) –
qubit_indices (tuple[int, ...]) –
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) –
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class GateIntervalNoise(single_qubit_noises, gate_interval)#
Bases:
CircuitNoiseInstruction
For each qubit, given single qubit noises are applied each time a certain number of gates are applied.
- Parameters:
single_qubit_noises (Sequence[GateNoiseInstruction]) – Sequence of single qubit
GateNoiseInstruction
.gate_interval (int) – Gate interval. For each qubit,
single_qubit_noises
are applied every timegate_interval
gates are applied.
- property gate_interval: int#
- property single_qubit_noises: Sequence[GateNoiseInstruction]#
- class GateIntervalResolver(gate_interval, noises)#
Bases:
CircuitNoiseResolverProtocol
- Parameters:
gate_interval (int) –
noises (Sequence[GateNoiseInstruction]) –
- noises_for_gate(gate, index, circuit)#
Returns the noises that should be inserted at the
index
position in the original circuit by being called with thegate
from the front while scanning the circuit.Each
CircuitNoiseInstruction
must implement its ownTraversalIndicatorProtocol
and must returns the instance bycreate_traversal_indicator()
method.- Parameters:
gate (QuantumGate) –
QuantumGate
at index position.index (int) – An index indicating the position of the gate in the circuit.
circuit (NonParametricQuantumCircuit) – Reference of the target circuit.
- Return type:
Sequence[circuit.noise.noise_instruction.QubitNoisePair]
- create_resolver()#
Returns new
CircuitNoiseResolverProtocol
instance for each concrete class ofCircuitNoiseInstruction
.When converting from the original circuit to a circuit with the noise model applied for each backend,
noises_for_gate()
method andnoises_for_depth()
method ofCircuitNoiseResolverProtocol
are called for each gate while scanning the circuit from front to back, returning the noises that needs to be applied to each position in the circuit.- Return type:
- class DepthIntervalNoise(single_qubit_noises, depth_interval)#
Bases:
CircuitNoiseInstruction
Trace the gates of the
QuantumCircuit
from the front to the back, and apply the given single qubitGateNoiseInstruction
to all qubits every time a certain depth is advanced.- Parameters:
single_qubit_noises (Sequence[GateNoiseInstruction]) – Sequence of single qubit
GateNoiseInstruction
.depth_interval (int) – Depth interval. Every time the depth advances
depth_interval
,single_qubit_noises
are applied to all qubits.
- property depth_interval: int#
- property single_qubit_noises: Sequence[GateNoiseInstruction]#
- class DepthIntervalResolver(depth_interval, noises)#
Bases:
CircuitNoiseResolverProtocol
- Parameters:
depth_interval (int) –
noises (Sequence[GateNoiseInstruction]) –
- noises_for_depth(qubit, depths, circuit)#
Returns qubit and noise pairs that shoud be applied to the
qubit
withindepths
.For each qubit, it is assumed that this function will be called each time the depth is progressed by each gate or the scan reaches to the end of the circuit while scanning from the front.
- Parameters:
qubit (int) – Target qubit indice.
depths (Sequence[int]) – Sequence of progressed depths of
qubit
.circuit (NonParametricQuantumCircuit) – Reference of the target circuit.
- Return type:
Sequence[circuit.noise.noise_instruction.QubitNoisePair]
- create_resolver()#
Returns new
CircuitNoiseResolverProtocol
instance for each concrete class ofCircuitNoiseInstruction
.When converting from the original circuit to a circuit with the noise model applied for each backend,
noises_for_gate()
method andnoises_for_depth()
method ofCircuitNoiseResolverProtocol
are called for each gate while scanning the circuit from front to back, returning the noises that needs to be applied to each position in the circuit.- Return type:
- class MeasurementNoise(single_qubit_noises, qubit_indices=[])#
Bases:
CircuitNoiseInstruction
Represents the noise which occurs during the measurement of a qubit. At the right end of the circuit, it applies single qubit noises to all qubits or specified qubits (if given).
- Parameters:
single_qubit_noises (Sequence[GateNoiseInstruction]) – Sequence of single qubit
GateNoiseInstruction
.qubit_indices (Sequence[int]) – Sequence of target qubit indices. If empty, all qubits will be covered.
- property qubit_indices: Sequence[int]#
- property apply_to_all_qubits: bool#
- property single_qubit_noises: Sequence[GateNoiseInstruction]#
- class MeasurementResolver(qubits, noises)#
Bases:
CircuitNoiseResolverProtocol
- Parameters:
qubits (Sequence[int]) –
noises (Sequence[GateNoiseInstruction]) –
- noises_for_depth(qubit, depths, circuit)#
Returns qubit and noise pairs that shoud be applied to the
qubit
withindepths
.For each qubit, it is assumed that this function will be called each time the depth is progressed by each gate or the scan reaches to the end of the circuit while scanning from the front.
- Parameters:
qubit (int) – Target qubit indice.
depths (Sequence[int]) – Sequence of progressed depths of
qubit
.circuit (NonParametricQuantumCircuit) – Reference of the target circuit.
- Return type:
Sequence[circuit.noise.noise_instruction.QubitNoisePair]
- create_resolver()#
Returns new
CircuitNoiseResolverProtocol
instance for each concrete class ofCircuitNoiseInstruction
.When converting from the original circuit to a circuit with the noise model applied for each backend,
noises_for_gate()
method andnoises_for_depth()
method ofCircuitNoiseResolverProtocol
are called for each gate while scanning the circuit from front to back, returning the noises that needs to be applied to each position in the circuit.- Return type:
- class BitFlipNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstruction
Single qubit bit flip noise.
- Parameters:
error_prob (float) – Probability of noise generation.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property error_prob: float#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class PhaseFlipNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstruction
Single qubit phase flip noise.
- Parameters:
error_prob (float) – Probability of noise generation.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property error_prob: float#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class BitPhaseFlipNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstruction
Single qubit bit and phase flip noise.
- Parameters:
error_prob (float) – Probability of noise generation.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property error_prob: float#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class DepolarizingNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstruction
Single qubit depolarizing noise.
- Parameters:
error_prob (float) – Probability of noise generation.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property error_prob: float#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class PauliNoise(pauli_list, prob_list, qubit_indices=(), target_gates=(), eq_tolerance=1e-08)#
Bases:
GateNoiseInstruction
Multi qubit Pauli noise.
In the case of multi qubit noise, qubit_indices should specify the qubits on which the target gate is acting, in any order, without excess or deficiency.
- Parameters:
pauli_list (Sequence[Sequence[int]]) – Sequence of series of Pauli ids.
prob_list (Sequence[float]) – Sequence of probability for each Pauli operations.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
eq_tolerance (float) – Allowed error in the total probability over 1.
- property pauli_list: Sequence[Sequence[int]]#
- property prob_list: Sequence[float]#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class GeneralDepolarizingNoise(error_prob, qubit_count, qubit_indices=(), target_gates=())#
Bases:
PauliNoise
Multi qubit general depolarizing noise.
In the case of multi qubit noise, qubit_indices should specify the qubits on which the target gate is acting, in any order, without excess or deficiency.
- Parameters:
error_prob (float) – Probability of noise generation.
qubit_count (int) – Number of qubits of the noise.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class ProbabilisticNoise(gate_matrices, prob_list, qubit_indices=(), target_gates=(), eq_tolerance=1e-08)#
Bases:
GateNoiseInstruction
Multi qubit probabilistic noise.
This noise is defined by giving matrices representing noise gate operations and the probability of each operation explicitly.
In the case of multi qubit noise, qubit_indices should specify the qubits on which the target gate is acting, in any order, without excess or deficiency.
- Parameters:
gate_matrices (Sequence[Sequence[Sequence[float]]]) – Sequence of matrices representing gate operations.
prob_list (Sequence[float]) – Sequence of probability for each operation.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
eq_tolerance (float) – Allowed error in the total probability over 1.
- property prob_list: Sequence[float]#
- property gate_matrices: tuple[ndarray[Any, dtype[float64]], ...]#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class AbstractKrausNoise(name, qubit_count, params, qubit_indices, target_gates)#
Bases:
GateNoiseInstruction
,ABC
Abstract base class of gate noise instractions which can return their Kraus operators.
- Parameters:
name (str) –
qubit_count (int) –
params (tuple[float, ...]) –
qubit_indices (tuple[int, ...]) –
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) –
- abstract property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class KrausNoise(kraus_list, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoise
Multi qubit Kraus noise.
In the case of multi qubit noise, qubit_indices should specify the qubits on which the target gate is acting, in any order, without excess or deficiency.
- Parameters:
kraus_list (Sequence[Sequence[Sequence[float]]]) – Sequence of Kraus operator matrices.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class ResetNoise(p0, p1, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoise
Single qubit reset noise.
- Parameters:
p0 (float) – Reset probability to \(|0\rangle\).
p1 (float) – Reset probability to \(|1\rangle\).
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property p0: float#
- property p1: float#
- property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class PhaseDampingNoise(phase_damping_rate, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoise
Single qubit phase damping noise.
- Parameters:
phase_damping_rate (float) – Probability of phase damping.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property phase_damping_rate: float#
- property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class AmplitudeDampingNoise(amplitude_damping_rate, excited_state_population, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoise
Single qubit amplitude damping noise.
- Parameters:
amplitude_damping_rate (float) – Probability of amplitude damping.
excited_state_population (float) – Excited state population.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property amplitude_damping_rate: float#
- property excited_state_population: float#
- property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class PhaseAmplitudeDampingNoise(phase_damping_rate, amplitude_damping_rate, excited_state_population, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoise
Single qubit phase and amplitude damping noise.
- Parameters:
phase_damping_rate (float) – Probability of phase damping.
amplitude_damping_rate (float) – Probability of amplitude damping.
excited_state_population (float) – Excited state population.
qubit_indices (tuple[int, ...]) – Sequence of target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Sequence of target gate names.
- property phase_damping_rate: float#
- property amplitude_damping_rate: float#
- property excited_state_population: float#
- property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#
- class ThermalRelaxationNoise(t1, t2, gate_time, excited_state_population, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoise
Sigle qubit thermal relaxation noise.
- Parameters:
t1 (float) – \(T_1\) relaxation time.
t2 (float) – \(T_2\) relaxation time.
gate_time (float) – Gate time.
excited_state_population (float) – Excited state population.
qubit_indices (tuple[int, ...]) – Target qubit indices.
target_gates (tuple[circuit.gate_names.NonParametricGateNameType, ...]) – Target gate names.
- property t1: float#
- property t2: float#
- property gate_time: float#
- property excited_state_population: float#
- property kraus_operators: circuit.noise.noise_instruction.KrausOperatorSequence#
- name: str#
- qubit_count: int#
- params: tuple[float, ...]#
- qubit_indices: tuple[int, ...]#
- target_gates: tuple[circuit.gate_names.NonParametricGateNameType, ...]#