quri_parts.circuit.noise package#
- class AmplitudeDampingNoise(amplitude_damping_rate, excited_state_population, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoiseSingle 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 BitFlipNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstructionSingle 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 BitPhaseFlipNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstructionSingle 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 CircuitNoiseInstruction(name)#
Bases:
ABCRepresents the noise applied depending on the structure of the circuit.
- Parameters:
name (str) –
- property name: str#
- abstract create_resolver()#
Returns new
CircuitNoiseResolverProtocolinstance 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 ofCircuitNoiseResolverProtocolare 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 ProbabilisticNoise(gate_matrices, prob_list, qubit_indices=(), target_gates=(), eq_tolerance=1e-08)#
Bases:
GateNoiseInstructionMulti 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 DepolarizingNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstructionSingle 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 DepthIntervalNoise(single_qubit_noises, depth_interval)#
Bases:
CircuitNoiseInstructionTrace the gates of the
QuantumCircuitfrom the front to the back, and apply the given single qubitGateNoiseInstructionto 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_noisesare 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
qubitwithindepths.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
CircuitNoiseResolverProtocolinstance 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 ofCircuitNoiseResolverProtocolare 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 GateIntervalNoise(single_qubit_noises, gate_interval)#
Bases:
CircuitNoiseInstructionFor 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_noisesare applied every timegate_intervalgates 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
indexposition in the original circuit by being called with thegatefrom the front while scanning the circuit.Each
CircuitNoiseInstructionmust implement its ownTraversalIndicatorProtocoland must returns the instance bycreate_traversal_indicator()method.- Parameters:
gate (QuantumGate) –
QuantumGateat 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
CircuitNoiseResolverProtocolinstance 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 ofCircuitNoiseResolverProtocolare 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 GateNoiseInstruction(name, qubit_count, params, qubit_indices, target_gates)#
Bases:
objectRepresents 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 GeneralDepolarizingNoise(error_prob, qubit_count, qubit_indices=(), target_gates=())#
Bases:
PauliNoiseMulti 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 KrausNoise(kraus_list, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoiseMulti 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 AbstractKrausNoise(name, qubit_count, params, qubit_indices, target_gates)#
Bases:
GateNoiseInstruction,ABCAbstract 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 MeasurementNoise(single_qubit_noises, qubit_indices=[])#
Bases:
CircuitNoiseInstructionRepresents 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
qubitwithindepths.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
CircuitNoiseResolverProtocolinstance 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 ofCircuitNoiseResolverProtocolare 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 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
- NoiseInstruction#
Represents a backend-independent noise instruction to be added to NoiseModel.
alias of
Union[CircuitNoiseInstruction,GateNoiseInstruction]
- class PauliNoise(pauli_list, prob_list, qubit_indices=(), target_gates=(), eq_tolerance=1e-08)#
Bases:
GateNoiseInstructionMulti 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 PhaseAmplitudeDampingNoise(phase_damping_rate, amplitude_damping_rate, excited_state_population, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoiseSingle 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 PhaseDampingNoise(phase_damping_rate, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoiseSingle 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 PhaseFlipNoise(error_prob, qubit_indices=(), target_gates=())#
Bases:
GateNoiseInstructionSingle 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, ...]#
- QubitNoisePair#
alias of
tuple[Sequence[int], GateNoiseInstruction]
- class ResetNoise(p0, p1, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoiseSingle 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 ThermalRelaxationNoise(t1, t2, gate_time, excited_state_population, qubit_indices=(), target_gates=())#
Bases:
AbstractKrausNoiseSigle 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, ...]#
- class CircuitNoiseResolverProtocol(*args, **kwargs)#
Bases:
ProtocolThis 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
indexposition in the original circuit by being called with thegatefrom the front while scanning the circuit.Each
CircuitNoiseInstructionmust implement its ownTraversalIndicatorProtocoland must returns the instance bycreate_traversal_indicator()method.- Parameters:
gate (QuantumGate) –
QuantumGateat 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
qubitwithindepths.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]
Submodules#
- quri_parts.circuit.noise.noise_instruction module
NoiseInstructionCircuitNoiseInstructionCircuitNoiseResolverProtocolGateNoiseInstructionGateIntervalNoiseDepthIntervalNoiseMeasurementNoiseBitFlipNoisePhaseFlipNoiseBitPhaseFlipNoiseDepolarizingNoisePauliNoiseGeneralDepolarizingNoiseProbabilisticNoiseAbstractKrausNoiseKrausNoiseResetNoisePhaseDampingNoiseAmplitudeDampingNoisePhaseAmplitudeDampingNoisePhaseAmplitudeDampingNoise.phase_damping_ratePhaseAmplitudeDampingNoise.amplitude_damping_ratePhaseAmplitudeDampingNoise.excited_state_populationPhaseAmplitudeDampingNoise.kraus_operatorsPhaseAmplitudeDampingNoise.namePhaseAmplitudeDampingNoise.qubit_countPhaseAmplitudeDampingNoise.paramsPhaseAmplitudeDampingNoise.qubit_indicesPhaseAmplitudeDampingNoise.target_gates
ThermalRelaxationNoiseThermalRelaxationNoise.t1ThermalRelaxationNoise.t2ThermalRelaxationNoise.gate_timeThermalRelaxationNoise.excited_state_populationThermalRelaxationNoise.kraus_operatorsThermalRelaxationNoise.nameThermalRelaxationNoise.qubit_countThermalRelaxationNoise.paramsThermalRelaxationNoise.qubit_indicesThermalRelaxationNoise.target_gates
- quri_parts.circuit.noise.noise_model module