quri_parts.circuit.noise package#

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 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 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 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 of CircuitNoiseInstruction.

When converting from the original circuit to a circuit with the noise model applied for each backend, noises_for_gate() method and noises_for_depth() method of CircuitNoiseResolverProtocol 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:

CircuitNoiseResolverProtocol

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 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 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 qubit GateNoiseInstruction 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:
noises_for_depth(qubit, depths, circuit)#

Returns qubit and noise pairs that shoud be applied to the qubit within depths.

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 of CircuitNoiseInstruction.

When converting from the original circuit to a circuit with the noise model applied for each backend, noises_for_gate() method and noises_for_depth() method of CircuitNoiseResolverProtocol 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:

CircuitNoiseResolverProtocol

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 time gate_interval gates are applied.

property gate_interval: int#
property single_qubit_noises: Sequence[GateNoiseInstruction]#
class GateIntervalResolver(gate_interval, noises)#

Bases: CircuitNoiseResolverProtocol

Parameters:
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 the gate from the front while scanning the circuit.

Each CircuitNoiseInstruction must implement its own TraversalIndicatorProtocol and must returns the instance by create_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 of CircuitNoiseInstruction.

When converting from the original circuit to a circuit with the noise model applied for each backend, noises_for_gate() method and noises_for_depth() method of CircuitNoiseResolverProtocol 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:

CircuitNoiseResolverProtocol

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 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 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 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 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:
noises_for_depth(qubit, depths, circuit)#

Returns qubit and noise pairs that shoud be applied to the qubit within depths.

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 of CircuitNoiseInstruction.

When converting from the original circuit to a circuit with the noise model applied for each backend, noises_for_gate() method and noises_for_depth() method of CircuitNoiseResolverProtocol 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:

CircuitNoiseResolverProtocol

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.

Examples

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.
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 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"])
Parameters:

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

noises_for_gate(gate)#

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.

Parameters:

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

Return type:

Iterable[circuit.noise.noise_instruction.QubitNoisePair]

noises_for_circuit()#

Returns sequence of CircuitNoiseInstruction in the model.

Return type:

Sequence[CircuitNoiseInstruction]

add_noise(noise, custom_gate_filter=None)#

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

Parameters:
  • 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:

None

extend(noises)#

Add multiple NoiseInstruction to 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: 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 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 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 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, ...]#
QubitNoisePair#

alias of tuple[Sequence[int], GateNoiseInstruction]

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 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, ...]#
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 the gate from the front while scanning the circuit.

Each CircuitNoiseInstruction must implement its own TraversalIndicatorProtocol and must returns the instance by create_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 within depths.

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#