braket.circuits.noises module
- class braket.circuits.noises.BitFlip(probability: FreeParameterExpression | float)[source]
Bases:
SingleProbabilisticNoise
Bit 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
BF
in circuit diagrams.Initializes a
SingleProbabilisticNoise
.- Parameters:
probability (Union[FreeParameterExpression, float]) – The probability that the noise occurs.
qubit_count (Optional[int]) – 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_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
,probability
is notfloat
orFreeParameterExpression
,probability
> 1/2, orprobability
< 0
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static bit_flip(target: Qubit | int | Iterable[Qubit | int], probability: float) Iterable[Instruction] [source]
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
probability (float) – Probability of bit flipping.
- Returns:
Iterable[Instruction] –
Iterable
of BitFlip instructions.
Examples
>>> circ = Circuit().bit_flip(0, probability=0.1)
- bind_values(**kwargs: FreeParameter | str) Noise [source]
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (Union[FreeParameter, str]) – Arbitrary keyword arguments.
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- class braket.circuits.noises.PhaseFlip(probability: FreeParameterExpression | float)[source]
Bases:
SingleProbabilisticNoise
Phase 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
PF
in circuit diagrams.Initializes a
SingleProbabilisticNoise
.- Parameters:
probability (Union[FreeParameterExpression, float]) – The probability that the noise occurs.
qubit_count (Optional[int]) – 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_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
,probability
is notfloat
orFreeParameterExpression
,probability
> 1/2, orprobability
< 0
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static phase_flip(target: Qubit | int | Iterable[Qubit | int], probability: float) Iterable[Instruction] [source]
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
probability (float) – Probability of phase flipping.
- Returns:
Iterable[Instruction] –
Iterable
of PhaseFlip instructions.
Examples
>>> circ = Circuit().phase_flip(0, probability=0.1)
- bind_values(**kwargs: FreeParameter | str) Noise [source]
Takes in parameters and attempts to assign them to values.
- Parameters:
**kwargs (Union[FreeParameter, str]) – Arbitrary keyword arguments.
- Returns:
Noise – A new Noise object of the same type with the requested parameters bound.
- class braket.circuits.noises.PauliChannel(probX: FreeParameterExpression | float, probY: FreeParameterExpression | float, probZ: FreeParameterExpression | float)[source]
Bases:
PauliNoise
Pauli 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
PC
in circuit diagrams.Creates PauliChannel noise.
- Parameters:
probX (Union[FreeParameterExpression, float]) – X rotation probability.
probY (Union[FreeParameterExpression, float]) – Y rotation probability.
probZ (Union[FreeParameterExpression, float]) – Z rotation probability.
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static pauli_channel(target: Qubit | int | Iterable[Qubit | int], probX: float, probY: float, probZ: float) Iterable[Instruction] [source]
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.
- Returns:
Iterable[Instruction] –
Iterable
of PauliChannel instructions.
Examples
>>> circ = Circuit().pauli_channel(0, probX=0.1, probY=0.2, probZ=0.3)
- class braket.circuits.noises.Depolarizing(probability: FreeParameterExpression | float)[source]
Bases:
SingleProbabilisticNoise_34
Depolarizing 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
DEPO
in circuit diagrams.Initializes a
SingleProbabilisticNoise_34
.- Parameters:
probability (Union[FreeParameterExpression, float]) – The probability that the noise occurs.
qubit_count (Optional[int]) – 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_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
,probability
is notfloat
orFreeParameterExpression
,probability
> 3/4, orprobability
< 0
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static depolarizing(target: Qubit | int | Iterable[Qubit | int], probability: float) Iterable[Instruction] [source]
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
probability (float) – Probability of depolarizing.
- Returns:
Iterable[Instruction] –
Iterable
of Depolarizing instructions.
Examples
>>> circ = Circuit().depolarizing(0, probability=0.1)
- class braket.circuits.noises.TwoQubitDepolarizing(probability: FreeParameterExpression | float)[source]
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
DEPO
in circuit diagrams.Initializes a
SingleProbabilisticNoise_1516
.- Parameters:
probability (Union[FreeParameterExpression, float]) – The probability that the noise occurs.
qubit_count (Optional[int]) – 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_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
,probability
is notfloat
orFreeParameterExpression
,probability
> 15/16, orprobability
< 0
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static two_qubit_depolarizing(target1: Qubit | int, target2: Qubit | int, probability: float) Iterable[Instruction] [source]
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.
- Returns:
Iterable[Instruction] –
Iterable
of Depolarizing instructions.
Examples
>>> circ = Circuit().two_qubit_depolarizing(0, 1, probability=0.1)
- class braket.circuits.noises.TwoQubitDephasing(probability: FreeParameterExpression | float)[source]
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
DEPH
in circuit diagrams.Initializes a
SingleProbabilisticNoise_34
.- Parameters:
probability (Union[FreeParameterExpression, float]) – The probability that the noise occurs.
qubit_count (Optional[int]) – 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_count
is less than 1,ascii_symbols
areNone
, orascii_symbols
length !=qubit_count
,probability
is notfloat
orFreeParameterExpression
,probability
> 3/4, orprobability
< 0
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static two_qubit_dephasing(target1: Qubit | int, target2: Qubit | int, probability: float) Iterable[Instruction] [source]
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.
- Returns:
Iterable[Instruction] –
Iterable
of Dephasing instructions.
Examples
>>> circ = Circuit().two_qubit_dephasing(0, 1, probability=0.1)
- class braket.circuits.noises.TwoQubitPauliChannel(probabilities: dict[str, float])[source]
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.[summary]
- Parameters:
probabilities (dict[str, Union[FreeParameterExpression, float]]) – A dictionary with Pauli strings as keys and the probabilities as values, i.e. {“XX”: 0.1. “IZ”: 0.2}.
qubit_count (Optional[int]) – 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_symbols
isNone
,ascii_symbols
length !=qubit_count
,probabilities
are 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.
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static two_qubit_pauli_channel(target1: Qubit | int, target2: Qubit | int, probabilities: dict[str, float]) Iterable[Instruction] [source]
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.
- Returns:
Iterable[Instruction] –
Iterable
of Depolarizing instructions.
Examples
>>> circ = Circuit().two_qubit_pauli_channel(0, 1, {"XX": 0.1})
- class braket.circuits.noises.AmplitudeDamping(gamma: FreeParameterExpression | float)[source]
Bases:
DampingNoise
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}\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
AD
in circuit diagrams.Initializes a
DampingNoise
.- Parameters:
gamma (Union[FreeParameterExpression, float]) – Probability of damping.
qubit_count (Optional[int]) – 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_symbols
isNone
,len(ascii_symbols)
!=qubit_count
,gamma
is notfloat
orFreeParameterExpression
, orgamma
> 1.0 orgamma
< 0.0.
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static amplitude_damping(target: Qubit | int | Iterable[Qubit | int], gamma: float) Iterable[Instruction] [source]
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s).
gamma (float) – decaying rate of the amplitude damping channel.
- Returns:
Iterable[Instruction] –
Iterable
of AmplitudeDamping instructions.
Examples
>>> circ = Circuit().amplitude_damping(0, gamma=0.1)
- class braket.circuits.noises.GeneralizedAmplitudeDamping(gamma: FreeParameterExpression | float, probability: FreeParameterExpression | float)[source]
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
GAD
in circuit diagrams.Inits a
GeneralizedAmplitudeDampingNoise
.- Parameters:
gamma (Union[FreeParameterExpression, float]) – Probability of damping.
probability (Union[FreeParameterExpression, float]) – Probability of the system being excited by the environment.
qubit_count (Optional[int]) – 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_symbols
isNone
,len(ascii_symbols)
!=qubit_count
,probability
orgamma
is notfloat
orFreeParameterExpression
,probability
> 1.0 orprobability
< 0.0, orgamma
> 1.0 orgamma
< 0.0.
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static generalized_amplitude_damping(target: Qubit | int | Iterable[Qubit | int], gamma: float, probability: float) Iterable[Instruction] [source]
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.
- Returns:
Iterable[Instruction] –
Iterable
of GeneralizedAmplitudeDamping instructions.
Examples
>>> circ = Circuit().generalized_amplitude_damping(0, gamma=0.1, probability = 0.9)
- class braket.circuits.noises.PhaseDamping(gamma: FreeParameterExpression | float)[source]
Bases:
DampingNoise
Phase 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
PD
in circuit diagrams.Initializes a
DampingNoise
.- Parameters:
gamma (Union[FreeParameterExpression, float]) – Probability of damping.
qubit_count (Optional[int]) – 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_symbols
isNone
,len(ascii_symbols)
!=qubit_count
,gamma
is notfloat
orFreeParameterExpression
, orgamma
> 1.0 orgamma
< 0.0.
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static fixed_qubit_count() int [source]
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
.- Returns:
int – The number of qubits this quantum operator acts on.
- static phase_damping(target: Qubit | int | Iterable[Qubit | int], gamma: float) Iterable[Instruction] [source]
Registers this function into the circuit class.
- Parameters:
target (QubitSetInput) – Target qubit(s)
gamma (float) – Probability of phase damping.
- Returns:
Iterable[Instruction] –
Iterable
of PhaseDamping instructions.
Examples
>>> circ = Circuit().phase_damping(0, gamma=0.1)
- class braket.circuits.noises.Kraus(matrices: Iterable[ndarray], display_name: str = 'KR')[source]
Bases:
Noise
User-defined noise channel that uses the provided matrices as Kraus operators This noise channel is shown as
NK
in circuit diagrams.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
matrices
is not a two-dimensional square matrix, or has a dimension length which is not a positive exponent of 2, or thematrices
do not satisfy CPTP condition.
- to_matrix() Iterable[ndarray] [source]
Returns a matrix representation of this noise.
- Returns:
Iterable[ndarray] – A list of matrix representations of this noise.
- static kraus(targets: Qubit | int | Iterable[Qubit | int], matrices: Iterable[array], display_name: str = 'KR') Iterable[Instruction] [source]
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.
- Returns:
Iterable[Instruction] –
Iterable
of Kraus instructions.
Examples
>>> K0 = np.eye(4) * np.sqrt(0.9) >>> K1 = np.kron([[1., 0.],[0., 1.]], [[0., 1.],[1., 0.]]) * np.sqrt(0.1) >>> circ = Circuit().kraus([1, 0], matrices=[K0, K1])