graphix.noise_models package

Submodules

Module contents

Noise models.

class AmplitudeDampingNoise(prob: float)[source]

Bases: Noise

One-qubit amplitude damping noise with damping parameter prob.

__init__(prob: float) → None[source]

Initialize one-qubit amplitude damping noise.

Parameters:

prob (float) – Damping parameter \(\\gamma\) of the noise, between 0 and 1.

prob

Descriptor for probability (between 0 and 1).

property nqubits: int

Return the number of qubits targetted by the noise element.

to_krauschannel() → KrausChannel[source]

Return the Kraus channel describing the noise element.

class AmplitudeDampingNoiseModel(prepare_error_prob: float = 0.0, x_error_prob: float = 0.0, z_error_prob: float = 0.0, entanglement_error_prob: float = 0.0, measure_channel_prob: float = 0.0, measure_error_prob: float = 0.0)[source]

Bases: NoiseModel

Amplitude damping noise model.

Parameters:

NoiseModel (class) – Parent abstract class class:NoiseModel

__init__(prepare_error_prob: float = 0.0, x_error_prob: float = 0.0, z_error_prob: float = 0.0, entanglement_error_prob: float = 0.0, measure_channel_prob: float = 0.0, measure_error_prob: float = 0.0) → None[source]
input_nodes(nodes: Iterable[int], rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to input nodes.

command(cmd: CommandOrNoise, rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to the command cmd.

confuse_result(cmd: BaseM, result: Outcome, rng: Generator | None = None, *, stacklevel: int = 1) → Outcome[source]

Assign wrong measurement result with probability measure_error_prob.

class ApplyNoise(noise: Noise, nodes: list[int], domain: set[int] | None = None)[source]

Bases: _KindChecker

Apply noise command.

Parameters:
  • noise (Noise) – noise to be applied

  • nodes (list[Node]) – list of node indices on which to apply noise

  • domain (set[Node] | None = None) – Optional domain for conditional noise. If None, the noise is applied unconditionally. Otherwise, the noise is applied if there is an odd number of nodes among domain that have been measured with outcome 1 (as for X and Z commands). Note that the noise is never applied if domain is the empty set.

kind: ClassVar[Literal[CommandKind.ApplyNoise]] = 9
noise: Noise
nodes: list[int]
domain: set[int] | None = None
__init__(noise: Noise, nodes: list[int], domain: set[int] | None = None) → None
class ComposeNoiseModel(models: list[NoiseModel])[source]

Bases: NoiseModel

Compose noise models.

models: list[NoiseModel]
input_nodes(nodes: Iterable[int], rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to input nodes.

command(cmd: CommandOrNoise, rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to the command cmd.

confuse_result(cmd: BaseM, result: Outcome, rng: Generator | None = None, *, stacklevel: int = 1) → Outcome[source]

Assign wrong measurement result.

__init__(models: list[NoiseModel]) → None
class DepolarisingNoise(prob: float)[source]

Bases: Noise

One-qubit depolarising noise with probabibity prob.

__init__(prob: float) → None[source]

Initialize one-qubit depolarizing noise.

Parameters:

prob (float) – Probability parameter of the noise, between 0 and 1.

prob

Descriptor for probability (between 0 and 1).

property nqubits: int

Return the number of qubits targetted by the noise element.

to_krauschannel() → KrausChannel[source]

Return the Kraus channel describing the noise element.

class DepolarisingNoiseModel(prepare_error_prob: float = 0.0, x_error_prob: float = 0.0, z_error_prob: float = 0.0, entanglement_error_prob: float = 0.0, measure_channel_prob: float = 0.0, measure_error_prob: float = 0.0)[source]

Bases: NoiseModel

Depolarising noise model.

Parameters:

NoiseModel (class) – Parent abstract class class:NoiseModel

__init__(prepare_error_prob: float = 0.0, x_error_prob: float = 0.0, z_error_prob: float = 0.0, entanglement_error_prob: float = 0.0, measure_channel_prob: float = 0.0, measure_error_prob: float = 0.0) → None[source]
input_nodes(nodes: Iterable[int], rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to input nodes.

command(cmd: CommandOrNoise, rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to the command cmd.

confuse_result(cmd: BaseM, result: Outcome, rng: Generator | None = None, *, stacklevel: int = 1) → Outcome[source]

Assign wrong measurement result cmd = “M”.

class Noise[source]

Bases: ABC

Abstract base class for noise.

abstract property nqubits: int

Return the number of qubits targetted by the noise.

abstractmethod to_krauschannel() → KrausChannel[source]

Return the Kraus channel describing the noise.

class NoiseModel[source]

Bases: ABC

Abstract base class for all noise models.

abstractmethod input_nodes(nodes: Iterable[int], rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to input nodes.

abstractmethod command(cmd: CommandOrNoise, rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Return the noise to apply to the command cmd.

abstractmethod confuse_result(cmd: BaseM, result: Outcome, rng: Generator | None = None, *, stacklevel: int = 1) → Outcome[source]

Return a possibly flipped measurement outcome.

Parameters:
  • result (Outcome) – Ideal measurement result.

  • cmd (BaseM) – The measurement command that produced the given outcome.

Returns:

Possibly corrupted result.

Return type:

Outcome

transpile(sequence: Iterable[CommandOrNoise], rng: Generator | None = None, *, stacklevel: int = 1) → list[CommandOrNoise][source]

Apply the noise to a sequence of commands and return the resulting sequence.

class TwoQubitAmplitudeDampingNoise(prob: float)[source]

Bases: Noise

Two-qubit amplitude damping noise with damping parameter prob.

__init__(prob: float) → None[source]

Initialize two-qubit amplitude damping noise.

Parameters:

prob (float) – Damping parameter \(\\gamma\) of the noise, between 0 and 1.

prob

Descriptor for probability (between 0 and 1).

property nqubits: int

Return the number of qubits targetted by the noise element.

to_krauschannel() → KrausChannel[source]

Return the Kraus channel describing the noise element.

class TwoQubitDepolarisingNoise(prob: float)[source]

Bases: Noise

Two-qubits depolarising noise with probabibity prob.

__init__(prob: float) → None[source]

Initialize two-qubit depolarizing noise.

Parameters:

prob (float) – Probability parameter of the noise, between 0 and 1.

prob

Descriptor for probability (between 0 and 1).

property nqubits: int

Return the number of qubits targetted by the noise element.

to_krauschannel() → KrausChannel[source]

Return the Kraus channel describing the noise element.