braket.circuits.noise module

class braket.circuits.noise.Noise(qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: QuantumOperator

Class Noise represents 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 an Instruction object. It appears in the diagram when user prints a circuit with Noise. This class is considered the noise channel definition containing the metadata that defines what the noise channel is and what it does.

Initializes a Noise object.

Parameters:
  • qubit_count (Optional[int]) – 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:

ValueErrorqubit_count is less than 1, ascii_symbols are None, or length of ascii_symbols is not equal to qubit_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: QubitSet, ir_type: IRType = IRType.JAQCD, serialization_properties: SerializationProperties | None = None) Any[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.

Returns:

Any – IR object of the quantum operator and target

Raises:
  • ValueError – If the supplied ir_type is not supported, or if the supplied serialization

  • properties don't correspond to the ir_type.

to_matrix(*args, **kwargs) Iterable[ndarray][source]

Returns a list of matrices defining the Kraus matrices of the noise channel.

Returns:

Iterable[ndarray] – list of matrices defining the Kraus matrices of the noise channel.

classmethod from_dict(noise: 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.

Returns:

Noise – An object of this class that corresponds to the passed in dictionary.

classmethod register_noise(noise: type[Noise]) None[source]

Register a noise implementation by adding it into the Noise class.

Parameters:

noise (type[Noise]) – Noise class to register.

class AmplitudeDamping(gamma: FreeParameterExpression | float)

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 is None, len(ascii_symbols) != qubit_count, gamma is not float or FreeParameterExpression, or gamma > 1.0 or gamma < 0.0.

static amplitude_damping(target: Qubit | int | Iterable[Qubit | int], gamma: float) Iterable[Instruction]

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)
bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class BitFlip(probability: FreeParameterExpression | float)

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 1/2, or probability < 0

bind_values(**kwargs: FreeParameter | str) Noise

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.

static bit_flip(target: Qubit | int | Iterable[Qubit | int], probability: float) Iterable[Instruction]

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)
static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class Depolarizing(probability: FreeParameterExpression | float)

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 3/4, or probability < 0

bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static depolarizing(target: Qubit | int | Iterable[Qubit | int], probability: float) Iterable[Instruction]

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)
static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class GeneralizedAmplitudeDamping(gamma: FreeParameterExpression | float, probability: FreeParameterExpression | float)

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 is None, len(ascii_symbols) != qubit_count, probability or gamma is not float or FreeParameterExpression, probability > 1.0 or probability < 0.0, or gamma > 1.0 or gamma < 0.0.

bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

static generalized_amplitude_damping(target: Qubit | int | Iterable[Qubit | int], gamma: float, probability: float) Iterable[Instruction]

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)
to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class Kraus(matrices: Iterable[ndarray], display_name: str = 'KR')

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 the matrices do not satisfy CPTP condition.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

static kraus(targets: Qubit | int | Iterable[Qubit | int], matrices: Iterable[array], display_name: str = 'KR') Iterable[Instruction]

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])
to_dict() dict

Converts this object into a dictionary representation. Not implemented at this time.

Returns:

dict – Not implemented at this time..

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class PauliChannel(probX: FreeParameterExpression | float, probY: FreeParameterExpression | float, probZ: FreeParameterExpression | float)

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:
bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

static pauli_channel(target: Qubit | int | Iterable[Qubit | int], probX: float, probY: float, probZ: float) Iterable[Instruction]

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)
to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class PhaseDamping(gamma: FreeParameterExpression | float)

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 is None, len(ascii_symbols) != qubit_count, gamma is not float or FreeParameterExpression, or gamma > 1.0 or gamma < 0.0.

bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

static phase_damping(target: Qubit | int | Iterable[Qubit | int], gamma: float) Iterable[Instruction]

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)
to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class PhaseFlip(probability: FreeParameterExpression | float)

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 1/2, or probability < 0

bind_values(**kwargs: FreeParameter | str) Noise

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.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

static phase_flip(target: Qubit | int | Iterable[Qubit | int], probability: float) Iterable[Instruction]

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)
to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

class TwoQubitDephasing(probability: FreeParameterExpression | float)

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 3/4, or probability < 0

bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

static two_qubit_dephasing(target1: Qubit | int, target2: Qubit | int, probability: float) Iterable[Instruction]

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 TwoQubitDepolarizing(probability: FreeParameterExpression | float)

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 15/16, or probability < 0

bind_values(**kwargs) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

static two_qubit_depolarizing(target1: Qubit | int, target2: Qubit | int, probability: float) Iterable[Instruction]

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 TwoQubitPauliChannel(probabilities: dict[str, float])

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 is None, ascii_symbols length != qubit_count, probabilities are not float`s or FreeParameterExpressions,     any of `probabilities > 1 or probabilities < 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) Noise

Takes in parameters and attempts to assign them to values.

Returns:

Noise – A new Noise object of the same type with the requested parameters bound.

static fixed_qubit_count() int

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.

classmethod from_dict(noise: dict) Noise

Converts a dictionary representation of this class into this class.

Parameters:

noise (dict) – The dictionary representation of this noise.

Returns:

Noise – A Noise object that represents the passed in dictionary.

to_matrix() Iterable[ndarray]

Returns a matrix representation of this noise.

Returns:

Iterable[ndarray] – A list of matrix representations of this noise.

static two_qubit_pauli_channel(target1: Qubit | int, target2: Qubit | int, probabilities: dict[str, float]) Iterable[Instruction]

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.noise.SingleProbabilisticNoise(probability: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str], max_probability: float = 0.5)[source]

Bases: Noise, Parameterizable

Class SingleProbabilisticNoise represents the bit/phase flip noise channel on N qubits parameterized by a single probability.

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 1/2, or probability < 0

property probability: float

The probability that parametrizes the noise channel.

Returns:

float – The probability that parametrizes the noise channel.

property parameters: list[FreeParameterExpression | float]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

Returns:

list[Union[FreeParameterExpression, float]] – The free parameter expressions or fixed values associated with the object.

bind_values(**kwargs) SingleProbabilisticNoise[source]

Takes in parameters and attempts to assign them to values.

Returns:

SingleProbabilisticNoise – A new Noise object of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

to_dict() dict[source]

Converts this object into a dictionary representation.

Returns:

dict – A dictionary object that represents this object. It can be converted back into this object using the from_dict() method.

class braket.circuits.noise.SingleProbabilisticNoise_34(probability: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: SingleProbabilisticNoise

Class SingleProbabilisticNoise represents the Depolarizing and TwoQubitDephasing noise channels parameterized by a single probability.

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 3/4, or probability < 0

class braket.circuits.noise.SingleProbabilisticNoise_1516(probability: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: SingleProbabilisticNoise

Class SingleProbabilisticNoise represents the TwoQubitDepolarizing noise channel parameterized by a single probability.

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 are None, or ascii_symbols length != qubit_count, probability is not float or FreeParameterExpression, probability > 15/16, or probability < 0

class braket.circuits.noise.MultiQubitPauliNoise(probabilities: dict[str, FreeParameterExpression | float], qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: Noise, Parameterizable

Class MultiQubitPauliNoise represents a general multi-qubit Pauli channel, parameterized by up to 4**N - 1 probabilities.

[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 is None, ascii_symbols length != qubit_count, probabilities are not float`s or FreeParameterExpressions,     any of `probabilities > 1 or probabilities < 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[FreeParameterExpression | float]

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[Union[FreeParameterExpression, float]] – The free parameter expressions or fixed values associated with the object.

bind_values(**kwargs) MultiQubitPauliNoise[source]

Takes in parameters and attempts to assign them to values.

Returns:

MultiQubitPauliNoise – A new Noise object of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

to_dict() dict[source]

Converts this object into a dictionary representation.

Returns:

dict – A dictionary object that represents this object. It can be converted back into this object using the from_dict() method.

class braket.circuits.noise.PauliNoise(probX: FreeParameterExpression | float, probY: FreeParameterExpression | float, probZ: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: Noise, Parameterizable

Class PauliNoise represents the a single-qubit Pauli noise channel acting on one qubit. It is parameterized by three probabilities.

Initializes a PauliNoise.

Parameters:
  • probX (Union[FreeParameterExpression, float]) – The X coefficient of the Kraus operators in the channel.

  • probY (Union[FreeParameterExpression, float]) – The Y coefficient of the Kraus operators in the channel.

  • probZ (Union[FreeParameterExpression, float]) – The Z coefficient of the Kraus operators in the channel.

  • 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 are None, or ascii_symbols length != qubit_count, probX or probY or probZ is not float or FreeParameterExpression, probX or probY or probZ > 1.0, or probX or probY or probZ < 0.0, or probX`+`probY`+`probZ > 1

property probX: FreeParameterExpression | float

The probability of a Pauli X error.

Returns:

Union[FreeParameterExpression, float] – The probability of a Pauli X error.

property probY: FreeParameterExpression | float

The probability of a Pauli Y error.

Returns:

Union[FreeParameterExpression, float] – The probability of a Pauli Y error.

property probZ: FreeParameterExpression | float

The probability of a Pauli Z error.

Returns:

Union[FreeParameterExpression, float] – The probability of a Pauli Z error.

property parameters: list[FreeParameterExpression | float]

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[Union[FreeParameterExpression, float]] – The free parameter expressions or fixed values associated with the object.

bind_values(**kwargs) PauliNoise[source]

Takes in parameters and attempts to assign them to values.

Returns:

PauliNoise – A new Noise object of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

to_dict() dict[source]

Converts this object into a dictionary representation.

Returns:

dict – A dictionary object that represents this object. It can be converted back into this object using the from_dict() method.

class braket.circuits.noise.DampingNoise(gamma: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: Noise, Parameterizable

Class DampingNoise represents a damping noise channel on N qubits parameterized by gamma.

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 is None, len(ascii_symbols) != qubit_count, gamma is not float or FreeParameterExpression, or gamma > 1.0 or gamma < 0.0.

property gamma: float

Probability of damping.

Returns:

float – Probability of damping.

property parameters: list[FreeParameterExpression | float]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

Returns:

list[Union[FreeParameterExpression, float]] – The free parameter expressions or fixed values associated with the object.

bind_values(**kwargs) DampingNoise[source]

Takes in parameters and attempts to assign them to values.

Returns:

DampingNoise – A new Noise object of the same type with the requested parameters bound.

Raises:

NotImplementedError – Subclasses should implement this function.

to_dict() dict[source]

Converts this object into a dictionary representation.

Returns:

dict – A dictionary object that represents this object. It can be converted back into this object using the from_dict() method.

class braket.circuits.noise.GeneralizedAmplitudeDampingNoise(gamma: FreeParameterExpression | float, probability: FreeParameterExpression | float, qubit_count: int | None, ascii_symbols: Sequence[str])[source]

Bases: DampingNoise

Class GeneralizedAmplitudeDampingNoise represents the generalized amplitude damping noise channel on N qubits parameterized by gamma and probability.

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 is None, len(ascii_symbols) != qubit_count, probability or gamma is not float or FreeParameterExpression, probability > 1.0 or probability < 0.0, or gamma > 1.0 or gamma < 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[FreeParameterExpression | float]

Returns the parameters associated with the object, either unbound free parameter expressions or bound values.

Parameters are in the order [gamma, probability]

Returns:

list[Union[FreeParameterExpression, float]] – The free parameter expressions or fixed values associated with the object.

to_dict() dict[source]

Converts this object into a dictionary representation.

Returns:

dict – A dictionary object that represents this object. It can be converted back into this object using the from_dict() method.