Noise
- class braket.circuits.noise.Noise(qubit_count, ascii_symbols)[source]
Bases:
QuantumOperatorClass
Noiserepresents a noise channel that operates on one or multiple qubits. Noise are considered as building blocks of quantum circuits that simulate noise. It can be used as an operator in anInstructionobject. It appears in the diagram when user prints a circuit withNoise. This class is considered the noise channel definition containing the metadata that defines what the noise channel is and what it does.- Parameters:
qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes a
Noiseobject.- Parameters:
qubit_count (int | None) – Number of qubits this noise channel interacts with.
ascii_symbols (Sequence[str]) – ASCII string symbols for this noise channel. These are used when printing a diagram of circuits. Length must be the same as
qubit_count, and index ordering is expected to correlate with target ordering on the instruction.
- Raises:
ValueError –
qubit_countis less than 1,ascii_symbolsare None, or length ofascii_symbolsis not equal toqubit_count
- property name: str
Returns the name of the quantum operator
- Returns:
str – The name of the quantum operator as a string
- to_ir(target, ir_type=IRType.JAQCD, serialization_properties=None)[source]
Returns IR object of quantum operator and target
- Parameters:
target (QubitSet) – target qubit(s)
ir_type (IRType) – The IRType to use for converting the noise object to its IR representation. Defaults to IRType.JAQCD.
serialization_properties (SerializationProperties | None) – The serialization properties to use while serializing the object to the IR representation. The serialization properties supplied must correspond to the supplied
ir_type. Defaults to None.
- Return type:
Any- Returns:
Any – IR object of the quantum operator and target
- Raises:
ValueError – If the supplied
ir_typeis not supported, or if the supplied serializationproperties don't correspond to the ir_type. –
- to_matrix(*args, **kwargs)[source]
Returns a list of matrices defining the Kraus matrices of the noise channel.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – list of matrices defining the Kraus matrices of the noise channel.
- classmethod from_dict(noise)[source]
Converts a dictionary representing an object of this class into an instance of this class.
- Parameters:
noise (dict) – A dictionary representation of an object of this class.
- Return type:
- Returns:
Noise – An object of this class that corresponds to the passed in dictionary.
- classmethod register_noise(noise)[source]
Register a noise implementation by adding it into the Noise class.
- class AmplitudeDamping(gamma)
Bases:
DampingNoiseAmplitudeDamping noise channel which transforms a density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow E_0 \\rho E_0^{\\dagger} + E_1 \\rho E_1^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}E_0 = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & \\sqrt{1-\\gamma} \\end{matrix} \\right)\end{split}\\\begin{split}E_1 = \\left( \\begin{matrix} 0 & \\sqrt{\\gamma} \\\\ 0 & 0 \\end{matrix} \\right)\end{split}\end{aligned}\end{align} \]This noise channel is shown as
ADin circuit diagrams.- Parameters:
gamma (
float|FreeParameterExpression)
Initializes a
DampingNoise.- Parameters:
gamma (float | FreeParameterExpression) – Probability of damping.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,len(ascii_symbols)!=qubit_count,gammais notfloatorFreeParameterExpression, orgamma> 1.0 orgamma< 0.0.
- static amplitude_damping(target, gamma)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s).
gamma (float) – decaying rate of the amplitude damping channel.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof AmplitudeDamping instructions.
Examples
>>> circ = Circuit().amplitude_damping(0, gamma=0.1)
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class BitFlip(probability)
Bases:
SingleProbabilisticNoiseBit flip noise channel which transforms a density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-p) \\rho + p X \\rho X^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}X = \\left( \\begin{matrix} 0 & 1 \\\\ 1 & 0 \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{probability}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
BFin circuit diagrams.- Parameters:
probability (
float|FreeParameterExpression)
Initializes a
SingleProbabilisticNoise.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.max_probability (float) – Maximum allowed probability of the noise channel. Default: 0.5
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 1/2, orprobability< 0
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (FreeParameter | str) – Arbitrary keyword arguments.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static bit_flip(target, probability)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
probability (float) – Probability of bit flipping.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof BitFlip instructions.
Examples
>>> circ = Circuit().bit_flip(0, probability=0.1)
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class Depolarizing(probability)
Bases:
SingleProbabilisticNoise_34Depolarizing noise channel which transforms a density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-p) \\rho + p/3 X \\rho X^{\\dagger} + p/3 Y \\rho Y^{\\dagger} + p/3 Z \\rho Z^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}X = \\left( \\begin{matrix} 0 & 1 \\\\ 1 & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Y = \\left( \\begin{matrix} 0 & -i \\\\ i & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Z = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & -1 \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{probability}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
DEPOin circuit diagrams.- Parameters:
probability (
float|FreeParameterExpression)
Initializes a
SingleProbabilisticNoise_34.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 3/4, orprobability< 0
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static depolarizing(target, probability)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
probability (float) – Probability of depolarizing.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof Depolarizing instructions.
Examples
>>> circ = Circuit().depolarizing(0, probability=0.1)
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class GeneralizedAmplitudeDamping(gamma, probability)
Bases:
GeneralizedAmplitudeDampingNoise- Generalized AmplitudeDamping noise channel which transforms a
density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow E_0 \\rho E_0^{\\dagger} + E_1 \\rho E_1^{\\dagger} + E_2 \\rho E_2^{\\dagger} + E_3 \\rho E_3^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}E_0 = \\sqrt(probability)\\left( \\begin{matrix} 1 & 0 \\\\ 0 & \\sqrt{1-\\gamma} \\end{matrix} \\right)\end{split}\\\begin{split}E_1 = \\sqrt(probability)\\left( \\begin{matrix} 0 & \\sqrt{\\gamma} \\\\ 0 & 0 \\end{matrix} \\right) E_2 = \\sqrt(1-probability)\\left( \\begin{matrix} \\sqrt{1-\\gamma} & 0 \\\\ 0 & 1 \\end{matrix} \\right) E_3 = \\sqrt(1-probability)\\left( \\begin{matrix} 0 & 0 \\\\ \\sqrt{\\gamma} & 0 \\end{matrix} \\right)\end{split}\end{aligned}\end{align} \]This noise channel is shown as
GADin circuit diagrams.- Parameters:
gamma (
float|FreeParameterExpression)probability (
float|FreeParameterExpression)
Inits a
GeneralizedAmplitudeDampingNoise.- Parameters:
gamma (float | FreeParameterExpression) – Probability of damping.
probability (float | FreeParameterExpression) – Probability of the system being excited by the environment.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,len(ascii_symbols)!=qubit_count,probabilityorgammais notfloatorFreeParameterExpression,probability> 1.0 orprobability< 0.0, orgamma> 1.0 orgamma< 0.0.
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- static generalized_amplitude_damping(target, gamma, probability)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s).
gamma (float) – The damping rate of the amplitude damping channel.
probability (float) – Probability of the system being excited by the environment.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof GeneralizedAmplitudeDamping instructions.
Examples
>>> circ = Circuit().generalized_amplitude_damping(0, gamma=0.1, probability=0.9)
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class Kraus(matrices, display_name='KR')
Bases:
NoiseUser-defined noise channel that uses the provided matrices as Kraus operators This noise channel is shown as
NKin circuit diagrams.- Parameters:
matrices (
Iterable[ndarray])display_name (
str)
Inits
Kraus.- Parameters:
matrices (Iterable[ndarray]) – A list of matrices that define a noise channel. These matrices need to satisfy the requirement of CPTP map.
display_name (str) – Name to be used for an instance of this general noise channel for circuit diagrams. Defaults to
KR.
- Raises:
ValueError – If any matrix in
matricesis not a two-dimensional square matrix, or has a dimension length which is not a positive exponent of 2, or thematricesdo not satisfy CPTP condition.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- static kraus(targets, matrices, display_name='KR')
Registers this function into the circuit class.
- Parameters:
targets (QubitSetInput) – Target qubit(s)
matrices (Iterable[array]) – Matrices that define a general noise channel.
display_name (str) – The display name.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof Kraus instructions.
Examples
>>> K0 = np.eye(4) * np.sqrt(0.9) >>> K1 = np.kron([[1.0, 0.0], [0.0, 1.0]], [[0.0, 1.0], [1.0, 0.0]]) * np.sqrt(0.1) >>> circ = Circuit().kraus([1, 0], matrices=[K0, K1])
- to_dict()
Converts this object into a dictionary representation. Not implemented at this time.
- Return type:
dict- Returns:
dict – Not implemented at this time..
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class PauliChannel(probX, probY, probZ)
Bases:
PauliNoisePauli noise channel which transforms a density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-probX-probY-probZ) \\rho + probX X \\rho X^{\\dagger} + probY Y \\rho Y^{\\dagger} + probZ Z \\rho Z^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}X = \\left( \\begin{matrix} 0 & 1 \\\\ 1 & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Y = \\left( \\begin{matrix} 0 & -i \\\\ i & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Z = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & -1 \\end{matrix} \\right)\end{split}\end{aligned}\end{align} \]This noise channel is shown as
PCin circuit diagrams.- Parameters:
probX (
float|FreeParameterExpression)probY (
float|FreeParameterExpression)probZ (
float|FreeParameterExpression)
Creates PauliChannel noise.
- Parameters:
probX (float | FreeParameterExpression) – X rotation probability.
probY (float | FreeParameterExpression) – Y rotation probability.
probZ (float | FreeParameterExpression) – Z rotation probability.
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- static pauli_channel(target, probX, probY, probZ)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s) probability list[float]: Probabilities for the Pauli X, Y and Z noise happening in the Kraus channel.
probX (float) – X rotation probability.
probY (float) – Y rotation probability.
probZ (float) – Z rotation probability.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof PauliChannel instructions.
Examples
>>> circ = Circuit().pauli_channel(0, probX=0.1, probY=0.2, probZ=0.3)
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class PhaseDamping(gamma)
Bases:
DampingNoisePhase damping noise channel which transforms a density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow E_0 \\rho E_0^{\\dagger} + E_1 \\rho E_1^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}E_0 = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & \\sqrt{1-gamma} \\end{matrix} \\right)\end{split}\\\begin{split}E_1 = \\left( \\begin{matrix} 0 & 0 \\\\ 0 & \\sqrt{gamma} \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{probability}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
PDin circuit diagrams.- Parameters:
gamma (
float|FreeParameterExpression)
Initializes a
DampingNoise.- Parameters:
gamma (float | FreeParameterExpression) – Probability of damping.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,len(ascii_symbols)!=qubit_count,gammais notfloatorFreeParameterExpression, orgamma> 1.0 orgamma< 0.0.
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- static phase_damping(target, gamma)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
gamma (float) – Probability of phase damping.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof PhaseDamping instructions.
Examples
>>> circ = Circuit().phase_damping(0, gamma=0.1)
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class PhaseFlip(probability)
Bases:
SingleProbabilisticNoisePhase flip noise channel which transforms a density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-p) \\rho + p X \\rho X^{\\dagger}\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}Z = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & -1 \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{probability}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
PFin circuit diagrams.- Parameters:
probability (
float|FreeParameterExpression)
Initializes a
SingleProbabilisticNoise.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.max_probability (float) – Maximum allowed probability of the noise channel. Default: 0.5
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 1/2, orprobability< 0
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (FreeParameter | str) – Arbitrary keyword arguments.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- static phase_flip(target, probability)
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
probability (float) – Probability of phase flipping.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof PhaseFlip instructions.
Examples
>>> circ = Circuit().phase_flip(0, probability=0.1)
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- class TwoQubitDephasing(probability)
Bases:
SingleProbabilisticNoise_34- Two-Qubit Dephasing noise channel which transforms a
density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-p) \\rho + p/3 ( IZ \\rho IZ^{\\dagger} + ZI \\rho ZI^{\\dagger} + ZZ \\rho ZZ^{\\dagger})\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}Z = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & -1 \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{probability}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
DEPHin circuit diagrams.- Parameters:
probability (
float|FreeParameterExpression)
Initializes a
SingleProbabilisticNoise_34.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 3/4, orprobability< 0
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static two_qubit_dephasing(target1, target2, probability)
Registers this function into the circuit class.
- Parameters:
target1 (QubitInput) – Target qubit 1.
target2 (QubitInput) – Target qubit 2.
probability (float) – Probability of two-qubit dephasing.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof Dephasing instructions.
Examples
>>> circ = Circuit().two_qubit_dephasing(0, 1, probability=0.1)
- class TwoQubitDepolarizing(probability)
Bases:
SingleProbabilisticNoise_1516- Two-Qubit Depolarizing noise channel which transforms a
density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-p) \\rho + p/15 ( IX \\rho IX^{\\dagger} + IY \\rho IY^{\\dagger} + IZ \\rho IZ^{\\dagger} + XI \\rho XI^{\\dagger} + XX \\rho XX^{\\dagger} + XY \\rho XY^{\\dagger} + XZ \\rho XZ^{\\dagger} + YI \\rho YI^{\\dagger} + YX \\rho YX^{\\dagger} + YY \\rho YY^{\\dagger} + YZ \\rho YZ^{\\dagger} + ZI \\rho ZI^{\\dagger} + ZX \\rho ZX^{\\dagger} + ZY \\rho ZY^{\\dagger} + ZZ \\rho ZZ^{\\dagger})\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}X = \\left( \\begin{matrix} 0 & 1 \\\\ 1 & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Y = \\left( \\begin{matrix} 0 & -i \\\\ i & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Z = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & -1 \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{probability}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
DEPOin circuit diagrams.- Parameters:
probability (
float|FreeParameterExpression)
Initializes a
SingleProbabilisticNoise_1516.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 15/16, orprobability< 0
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static two_qubit_depolarizing(target1, target2, probability)
Registers this function into the circuit class.
- Parameters:
target1 (QubitInput) – Target qubit 1.
target2 (QubitInput) – Target qubit 2.
probability (float) – Probability of two-qubit depolarizing.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof Depolarizing instructions.
Examples
>>> circ = Circuit().two_qubit_depolarizing(0, 1, probability=0.1)
- class TwoQubitPauliChannel(probabilities)
Bases:
MultiQubitPauliNoise- Two-Qubit Pauli noise channel which transforms a
density matrix \(\\rho\) according to:
\[\begin{split}\\rho \\Rightarrow (1-p) \\rho + p_{IX} IX \\rho IX^{\\dagger} + p_{IY} IY \\rho IY^{\\dagger} + p_{IZ} IZ \\rho IZ^{\\dagger} + p_{XI} XI \\rho XI^{\\dagger} + p_{XX} XX \\rho XX^{\\dagger} + p_{XY} XY \\rho XY^{\\dagger} + p_{XZ} XZ \\rho XZ^{\\dagger} + p_{YI} YI \\rho YI^{\\dagger} + p_{YX} YX \\rho YX^{\\dagger} + p_{YY} YY \\rho YY^{\\dagger} + p_{YZ} YZ \\rho YZ^{\\dagger} + p_{ZI} ZI \\rho ZI^{\\dagger} + p_{ZX} ZX \\rho ZX^{\\dagger} + p_{ZY} ZY \\rho ZY^{\\dagger} + p_{ZZ} ZZ \\rho ZZ^{\\dagger})\end{split}\]where
\[ \begin{align}\begin{aligned}\begin{split}I = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & 1 \\end{matrix} \\right)\end{split}\\\begin{split}X = \\left( \\begin{matrix} 0 & 1 \\\\ 1 & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Y = \\left( \\begin{matrix} 0 & -i \\\\ i & 0 \\end{matrix} \\right)\end{split}\\\begin{split}Z = \\left( \\begin{matrix} 1 & 0 \\\\ 0 & -1 \\end{matrix} \\right)\end{split}\\\begin{split}p = \\text{sum of all probabilities}\end{split}\end{aligned}\end{align} \]This noise channel is shown as
PC_2({"pauli_string": probability})in circuit diagrams.- Parameters:
probabilities (
dict[str,float])
[summary]
- Parameters:
probabilities (dict[str, float | FreeParameterExpression]) – A dictionary with Pauli strings as keys and the probabilities as values, i.e. {“XX”: 0.1. “IZ”: 0.2}.
qubit_count (int | None) – The number of qubits the Pauli noise acts on.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,ascii_symbolslength !=qubit_count,probabilitiesare notfloat`s or FreeParameterExpressions, any of `probabilities> 1 orprobabilities< 0, the sum of all probabilities is > 1, if “II” is specified as a Pauli string, if any Pauli string contains invalid strings, or if the length of probabilities is greater than 4**qubit_count.TypeError – If the type of the dictionary keys are not strings. If the probabilities are not floats.
- bind_values(**kwargs)
Takes in parameters and attempts to assign them to values.
- Return type:
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- static fixed_qubit_count()
Returns the number of qubits this quantum operator acts on, if instances are guaranteed to act on the same number of qubits.
If different instances can act on a different number of qubits, this method returns
NotImplemented.- Return type:
int- Returns:
int – The number of qubits this quantum operator acts on.
- classmethod from_dict(noise)
Converts a dictionary representation of this class into this class.
- Parameters:
noise (dict) – The dictionary representation of this noise.
- Return type:
- Returns:
Noise – A Noise object that represents the passed in dictionary.
- to_matrix()
Returns a matrix representation of this noise.
- Return type:
Iterable[ndarray]- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static two_qubit_pauli_channel(target1, target2, probabilities)
Registers this function into the circuit class.
- Parameters:
target1 (QubitInput) – Target qubit 1.
target2 (QubitInput) – Target qubit 2.
probabilities (dict[str, float]) – Probability of two-qubit Pauli channel.
- Return type:
Iterable[Instruction]- Returns:
Iterable[Instruction] –
Iterableof Depolarizing instructions.
Examples
>>> circ = Circuit().two_qubit_pauli_channel(0, 1, {"XX": 0.1})
- class braket.circuits.noise.SingleProbabilisticNoise(probability, qubit_count, ascii_symbols, max_probability=0.5)[source]
Bases:
Noise,ParameterizableClass
SingleProbabilisticNoiserepresents the bit/phase flip noise channel on N qubits parameterized by a single probability.- Parameters:
probability (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])max_probability (
float)
Initializes a
SingleProbabilisticNoise.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.max_probability (float) – Maximum allowed probability of the noise channel. Default: 0.5
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 1/2, orprobability< 0
- property probability: float
The probability that parametrizes the noise channel.
- Returns:
float – The probability that parametrizes the noise channel.
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameter expressions or bound values.
- Returns:
list[float | FreeParameterExpression] – The free parameter expressions or fixed values associated with the object.
- class braket.circuits.noise.SingleProbabilisticNoise_34(probability, qubit_count, ascii_symbols)[source]
Bases:
SingleProbabilisticNoiseClass
SingleProbabilisticNoiserepresents the Depolarizing and TwoQubitDephasing noise channels parameterized by a single probability.- Parameters:
probability (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes a
SingleProbabilisticNoise_34.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 3/4, orprobability< 0
- class braket.circuits.noise.SingleProbabilisticNoise_1516(probability, qubit_count, ascii_symbols)[source]
Bases:
SingleProbabilisticNoiseClass
SingleProbabilisticNoiserepresents the TwoQubitDepolarizing noise channel parameterized by a single probability.- Parameters:
probability (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes a
SingleProbabilisticNoise_1516.- Parameters:
probability (float | FreeParameterExpression) – The probability that the noise occurs.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probabilityis notfloatorFreeParameterExpression,probability> 15/16, orprobability< 0
- class braket.circuits.noise.MultiQubitPauliNoise(probabilities, qubit_count, ascii_symbols)[source]
Bases:
Noise,ParameterizableClass
MultiQubitPauliNoiserepresents a general multi-qubit Pauli channel, parameterized by up to 4**N - 1 probabilities.- Parameters:
probabilities (
dict[str,float|FreeParameterExpression])qubit_count (
int|None)ascii_symbols (
Sequence[str])
[summary]
- Parameters:
probabilities (dict[str, float | FreeParameterExpression]) – A dictionary with Pauli strings as keys and the probabilities as values, i.e. {“XX”: 0.1. “IZ”: 0.2}.
qubit_count (int | None) – The number of qubits the Pauli noise acts on.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,ascii_symbolslength !=qubit_count,probabilitiesare notfloat`s or FreeParameterExpressions, any of `probabilities> 1 orprobabilities< 0, the sum of all probabilities is > 1, if “II” is specified as a Pauli string, if any Pauli string contains invalid strings, or if the length of probabilities is greater than 4**qubit_count.TypeError – If the type of the dictionary keys are not strings. If the probabilities are not floats.
- property probabilities: dict[str, float]
A map of a Pauli string to its corresponding probability.
- Returns:
dict[str, float] – A map of a Pauli string to its corresponding probability.
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameter expressions or bound values.
Parameters are in alphabetical order of the Pauli strings in
probabilities.- Returns:
list[float | FreeParameterExpression] – The free parameter expressions or fixed values associated with the object.
- class braket.circuits.noise.PauliNoise(probX, probY, probZ, qubit_count, ascii_symbols)[source]
Bases:
Noise,ParameterizableClass
PauliNoiserepresents the a single-qubit Pauli noise channel acting on one qubit. It is parameterized by three probabilities.- Parameters:
probX (
float|FreeParameterExpression)probY (
float|FreeParameterExpression)probZ (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes a
PauliNoise.- Parameters:
probX (float | FreeParameterExpression) – The X coefficient of the Kraus operators in the channel.
probY (float | FreeParameterExpression) – The Y coefficient of the Kraus operators in the channel.
probZ (float | FreeParameterExpression) – The Z coefficient of the Kraus operators in the channel.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If the
qubit_countis less than 1,ascii_symbolsareNone, orascii_symbolslength !=qubit_count,probXorprobYorprobZis notfloator FreeParameterExpression,probXorprobYorprobZ> 1.0, orprobXorprobYorprobZ< 0.0, orprobX`+`probY`+`probZ> 1
- property probX: float | FreeParameterExpression
The probability of a Pauli X error.
- Returns:
float | FreeParameterExpression – The probability of a Pauli X error.
- property probY: float | FreeParameterExpression
The probability of a Pauli Y error.
- Returns:
float | FreeParameterExpression – The probability of a Pauli Y error.
- property probZ: float | FreeParameterExpression
The probability of a Pauli Z error.
- Returns:
float | FreeParameterExpression – The probability of a Pauli Z error.
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameter expressions or bound values.
Parameters are in the order [probX, probY, probZ]
- Returns:
list[float | FreeParameterExpression] – The free parameter expressions or fixed values associated with the object.
- class braket.circuits.noise.DampingNoise(gamma, qubit_count, ascii_symbols)[source]
Bases:
Noise,ParameterizableClass
DampingNoiserepresents a damping noise channel on N qubits parameterized by gamma.- Parameters:
gamma (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Initializes a
DampingNoise.- Parameters:
gamma (float | FreeParameterExpression) – Probability of damping.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,len(ascii_symbols)!=qubit_count,gammais notfloatorFreeParameterExpression, orgamma> 1.0 orgamma< 0.0.
- property gamma: float
Probability of damping.
- Returns:
float – Probability of damping.
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameter expressions or bound values.
- Returns:
list[float | FreeParameterExpression] – The free parameter expressions or fixed values associated with the object.
- class braket.circuits.noise.GeneralizedAmplitudeDampingNoise(gamma, probability, qubit_count, ascii_symbols)[source]
Bases:
DampingNoiseClass
GeneralizedAmplitudeDampingNoiserepresents the generalized amplitude damping noise channel on N qubits parameterized by gamma and probability.- Parameters:
gamma (
float|FreeParameterExpression)probability (
float|FreeParameterExpression)qubit_count (
int|None)ascii_symbols (
Sequence[str])
Inits a
GeneralizedAmplitudeDampingNoise.- Parameters:
gamma (float | FreeParameterExpression) – Probability of damping.
probability (float | FreeParameterExpression) – Probability of the system being excited by the environment.
qubit_count (int | None) – The number of qubits to apply noise.
ascii_symbols (Sequence[str]) – ASCII string symbols for the noise. These are used when printing a diagram of a circuit. The length must be the same as
qubit_count, and index ordering is expected to correlate with the target ordering on the instruction.
- Raises:
ValueError – If
qubit_count< 1,ascii_symbolsisNone,len(ascii_symbols)!=qubit_count,probabilityorgammais notfloatorFreeParameterExpression,probability> 1.0 orprobability< 0.0, orgamma> 1.0 orgamma< 0.0.
- property probability: float
Probability of the system being excited by the environment.
- Returns:
float – Probability of the system being excited by the environment.
- property parameters: list[float | FreeParameterExpression]
Returns the parameters associated with the object, either unbound free parameter expressions or bound values.
Parameters are in the order [gamma, probability]
- Returns:
list[float | FreeParameterExpression] – The free parameter expressions or fixed values associated with the object.