graphix
graphix copied to clipboard
Transpiler API for noise models
Introduce a new API for noise models, which transpile perfect patterns
into noisy ones. Noisy patterns use an additional command, A, to
apply a noise operator to a subset of qubits.
The existing Command type remains unchanged and does not include A.
We introduce:
CommandOrNoise— a union of all pattern commands plusANoiseCommands— a sequence ofCommandOrNoise, i.e. a noisy pattern
A noise model must implement the three abstract methods of NoiseModel:
-
input_nodes(self, nodes: list[int]) -> NoiseCommandsNoisy commands to apply to the input nodes. -
command(self, cmd: CommandOrNoise) -> NoiseCommandsGenerate a noisy pattern sequence for a single command. Noise may be inserted before or after the command, or the command itself may be modified (e.g., rerouted to a different qubit). The input can be either a perfect command or a noise command, enabling composition of multiple noise effects. -
confuse_result(self, cmd: BaseM, result: bool) -> boolOptionally modify the outcome of a measurement.
We provide two concrete noise models:
DepolarisingNoiseModelComposeNoiseModel— compose multiple noise models in sequence
Abstract base class Noise encapsulates a noise operator:
-
nqubits(self) -> intNumber of qubits targeted by this noise (must match the arity ofA). -
to_kraus_channel(self) -> KrausChannelReturns the Kraus description, used by the density‑matrix backend. Backends can also inspect theNoisesubclass (e.g.DepolarisingNoise) directly without parsing Kraus operators.