Noise & Decoding paulicert.noise paulicert.decode
Create single-qubit Qiskit Kraus noise channels, extract their Pauli twirl probabilities, and build syndrome lookup-table decoders. For channel formulas and Pauli-twirl tables, see Foundations.
Single-Qubit Noise Channels
def pauli_channel(px: float = 0.0, py: float = 0.0, pz: float = 0.0) → Kraus
Asymmetric single-qubit Pauli channel with independent X, Y, and Z flip probabilities.
def depolarizing(p: float) → Kraus
Symmetric single-qubit depolarizing channel where X, Y, and Z each occur with probability p / 3.
def amplitude_damping(gamma: float) → Kraus
Energy-relaxation (T1 decay) channel with decay probability gamma in [0, 1].
def phase_damping(lam: float) → Kraus
Pure dephasing channel with dephasing parameter lam in [0, 1].
def thermal_relaxation(t1: float, t2: float, time: float) → Kraus
Combined T1 relaxation and T2 dephasing channel over gate/idle duration time (requires t2 ≤ 2 * t1).
def coherent_rotation(axis: str, theta: float) → Kraus
Unitary over-rotation by angle theta (radians) around a single Pauli axis.
Pauli Twirling & Channel Families
def pauli_twirl(channel: QuantumChannel) → tuple[float, float, float, float]
Validates CPTP and extracts the diagonal Pauli-twirl error probabilities (p_I, p_X, p_Y, p_Z) of any single-qubit Qiskit channel.
CHANNEL_FAMILIES: Mapping[str, ChannelFamily]
Built-in read-only dictionary of nine one-parameter channel factories (ChannelFamily = Callable[[float], QuantumChannel | Sequence[QuantumChannel]]; each built-in entry maps p to a Kraus channel): "depolarizing", "bit_flip", "phase_flip", "bit_phase_flip", "amplitude_damping", "phase_damping", "coherent_x", "coherent_y", and "coherent_z".
Lookup-Table Decoders paulicert.decode
class StabilizerLUTDecoder(code: StabilizerCode, *, max_weight: int | None = None, pauli_probs: tuple[float, float, float, float] | ArrayLike | None = None, ml: bool = False)
Builds a syndrome lookup table (up to r ≤ 18) supporting three decoding rules. When max_weight=None, covers all 2^r syndromes automatically for n ≤ 10 (and up to weight 4 for n ≤ 13), emitting a UserWarning if default bounded-weight search leaves reachable syndromes uncovered.
def build_mpe_lut(code: StabilizerCode, pauli_probs: tuple[float, float, float, float] | ArrayLike, *, max_weight: int | None = None) → StabilizerLUTDecoder
Builds a most-probable-error lookup-table decoder for a homogeneous (p_I, p_X, p_Y, p_Z) or per-qubit (n, 4) Pauli distribution (excluding zero-probability errors in bounded-weight tables; bounded-weight tables with max_weight < n require p_I ≥ max(p_X, p_Y, p_Z)).
def build_ml_decoder(code: StabilizerCode, pauli_probs: tuple[float, float, float, float] | ArrayLike) → StabilizerLUTDecoder
Builds an exact degenerate coset maximum-likelihood decoder (n ≤ 10) for homogeneous or per-qubit (n, 4) Pauli probabilities.
def compute_syndrome(h_x: ArrayLike, h_z: ArrayLike, ex: ArrayLike, ez: ArrayLike) → NDArray[np.uint8]
Computes the binary syndrome vector (or batch of syndromes) for Pauli errors specified by binary arrays ex and ez.
def pauli_string_to_symplectic(pauli_str: str, *, qiskit_order: bool = False) → tuple[NDArray[np.uint8], NDArray[np.uint8]]
Converts an n-qubit Pauli string (such as "XZIIIII") into binary symplectic arrays (ex, ez). Defaults to textbook left-to-right order (qiskit_order=False, qubit 0 on the left); pass qiskit_order=True for Qiskit labels (qubit 0 on the right, matching from_pauli_list’s default).
[[5, 1, 3]].import paulicert as pc
c5 = pc.get_preset_code("5-1-3-perfect")
probs = pc.pauli_twirl(pc.amplitude_damping(0.20))
dec_mpe = pc.build_mpe_lut(c5, probs)
dec_ml = pc.build_ml_decoder(c5, probs)
rx, rz = dec_ml.decode_batch([[1, 0, 0, 1]])
print(f"mpe.ml={dec_mpe.ml} | ml.ml={dec_ml.ml} | decoded shape={rx.shape}")
# mpe.ml=False | ml.ml=True | decoded shape=(1, 5)