graphix.noise_models.noise_model module¶
Abstract interface for noise models.
This module defines NoiseModel, the base class used by
graphix.simulator.PatternSimulator when running noisy
simulations. Child classes implement concrete noise processes by
overriding the abstract methods defined here.
- class Noise[source]¶
Bases:
ABCAbstract base class for noise.
- abstractmethod to_krauschannel() KrausChannel[source]¶
Return the Kraus channel describing the noise.
- class ApplyNoise(noise: Noise, nodes: list[int], domain: set[int] | None = None)[source]¶
Bases:
_KindCheckerApply 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 amongdomainthat have been measured with outcome 1 (as forXandZcommands). Note that the noise is never applied ifdomainis the empty set.
- CommandOrNoise: TypeAlias¶
- class NoiseModel[source]¶
Bases:
ABCAbstract 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 NoiselessNoiseModel[source]¶
Bases:
NoiseModelNoise model that performs no operation.
- 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.
- class ComposeNoiseModel(models: list[NoiseModel])[source]¶
Bases:
NoiseModelCompose 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¶