paulicert

Can you trust a Pauli-noise simulation of your quantum error-correcting code? Large-scale QEC simulations model noise as random Pauli errors (X, Y, Z flips) so stabilizer tableaux run in polynomial time. Physical qubits, however, also suffer coherent and non-unital processes — such as gate over-rotations R_X(θ) = exp(−iθX/2) and T1 relaxation — which stabilizer simulators approximate via the Pauli Twirl Approximation (PTA), replacing R_X(θ) with a stochastic X flip of probability p = sin²(θ/2). paulicert is a Qiskit-native library that certifies when that Pauli replacement is exact, quantifies the exact logical-channel discrepancy when it fails, and finds the minimum subset of qubits to Pauli-twirl — alongside local Clifford deformations that rotate stabilizer checks away from coherent noise.

How It Works

1Check

pauli_exact checks in milliseconds whether coherent errors can interfere inside your code (scales up to [[756, 16, ≤34]] qLDPC codes).

2Measure

logical_channel computes the exact decoded logical channel under true vs. Pauli-twirled noise (gap and choi_distance).

3Fix

minimal_twirl_set finds the smallest subset of qubits to physically twirl, and deform_stabilizer_code rotates stabilizers away from the noise.

The Problem in One Table

Take the [[7, 1, 3]] Steane code under a small coherent X over-rotation on every qubit (parameterized by single-qubit flip probability p = sin²(θ/2)):

Physical error pPauli modelTrue coherent channelSteane + twirl 3 qubitsBetter than bare qubit? (Pauli / True / Twirl 3)
1.0%0.20%0.59%0.20%yes / yes / yes
1.5%0.44%1.28%0.44%yes / yes / yes
2.0%0.76%2.19%0.76%yes / no / yes (2.6×)
3.0%1.64%4.60%1.64%yes / no / yes
5.0%4.15%11.06%4.15%yes / no / yes

The Pauli simulation puts the break-even point at 6.5%, while the true coherent break-even is 1.8%. At p = 2.0%, untwirled Steane (2.19%) is worse than sending a bare qubit (2.00%) — yet physically twirling just 3 of the 7 qubits (0, 1, 2) breaks the interference and drops the real error down to 0.76%. See Foundations for the exact step-by-step math.

Steane break-even shift under coherent X noise
Fig. 1.Block logical error rate of the Steane code under coherent X over-rotation. Between 1.8% and 6.5%, the Pauli model predicts error suppression while the true coherent channel makes the qubit worse; physically twirling just 3 qubits {0, 1, 2} collapses the true curve right back onto the Pauli baseline.

Installation

Requires Python 3.10+ with Qiskit 2.x, Qiskit Aer, NumPy, and Matplotlib (no extra dependencies).

pip install paulicert

Or install from source:

git clone https://github.com/moefqy/paulicert.git
cd paulicert
pip install -e .

Quick Start

A witness is a non-identity stabilizer (or normalizer element when full_channel=True) whose Paulis all lie inside the channel’s active coherent error axes, allowing distinct error paths to interfere. Zero witnesses means the Pauli Twirl Approximation is guaranteed exact.

Certify Steane, compute the exact logical-channel gap, twirl only 3 qubits, and check full-channel exactness on [[5, 1, 3]].
import paulicert as pc

steane = pc.get_preset_code("7-1-3-steane")
noise = pc.CHANNEL_FAMILIES["coherent_x"](0.01)  # p = sin^2(theta/2) = 0.01

# 1. Is Pauli simulation guaranteed exact for logical fidelity?
cert = pc.pauli_exact(steane, noise)
print(f"exact={cert.exact} | witnesses={cert.num_witnesses} | min_weight={cert.min_witness_weight}")
# exact=False | witnesses=7 | min_weight=4

# 2. Measure the exact true vs. Pauli logical channel
lc = pc.logical_channel(steane, noise)
print(f"true={lc.infidelity:.4e} | PTA={lc.twirled_infidelity:.4e} | gap={lc.gap:.4f} | D_Choi={lc.choi_distance:.2e}")
# true=5.8784e-03 | PTA=2.0041e-03 | gap=2.9332 | D_Choi=1.28e-02

# 3. Twirl only the minimum 3 qubits to restore exactness (gap = 1.0)
ts = pc.minimal_twirl_set(steane, noise)
pauli_ch = pc.pauli_channel(*pc.pauli_twirl(noise)[1:])
twirled = [pauli_ch if q in ts.qubits else noise for q in range(steane.n)]
print(f"Qubits to twirl: {ts.qubits} ({len(ts.qubits)}/{steane.n} qubits, provably_minimal={ts.provably_minimal})")
print(f"After twirling : exact={pc.pauli_exact(steane, twirled).exact} | gap={pc.logical_channel(steane, twirled).gap:.6f}")
# Qubits to twirl: (0, 1, 2) (3/7 qubits, provably_minimal=True)
# After twirling : exact=True | gap=1.000000

# 4. Fidelity exactness vs. full superoperator identity on [[5, 1, 3]]
five = pc.get_preset_code("5-1-3-perfect")
print("[[5, 1, 3]] exact       :", pc.pauli_exact(five, noise, full_channel=False).exact)  # True  (gap = 1.0)
print("[[5, 1, 3]] full_channel:", pc.pauli_exact(five, noise, full_channel=True).exact)   # False (logical XXXXX, D_Choi = 3.90e-05)

Why: Amplitudes Add, Probabilities Don’t

Write the Steane stabilizers in textbook order (qubit 0 on the left):

g1 = XIIXIXX   g4 = ZIIZIZZ
g2 = IXIXXIX   g5 = IZIZZIZ
g3 = IIXIXXX   g6 = IIZIZZZ        logical X̄ = IIIXXXI

Qubit ordering: Prose tables place qubit 0 on the left (XIIXIXX). from_pauli_list defaults to Qiskit’s right-to-left label order; pass qiskit_order=False when supplying left-to-right textbook strings.

Take one syndrome, 000110. The decoder reads it as “X on qubit 3” and applies IIIXIII. Three different two-qubit errors also produce this exact syndrome:

Actual errorAfter correctionEffect on the encoded qubit
IIIXIIIIIIIIIICorrected (no error)
XXIIIIIXXIXIII = X · g1g2Logical X error
IIXIIIXIIXXIIX = X · g3Logical X error
IIIIXXIIIIXXXI = XLogical X error

The three failures differ only by stabilizers, so they act identically on the code: they all apply logical X.

At leading order in p, constructive interference across stabilizer-equivalent failure paths triples the logical infidelity (63p² vs. 21p²).

Why [[5, 1, 3]] is immune to this fidelity bias: coherent X noise only produces X-type errors. For two error branches to merge inside a stabilizer coset, they must differ by a stabilizer made only of X’s. Steane has 7 such stabilizers; the 5-qubit code (XZZXI, …) has none, so its Pauli model matches exact logical fidelity (gap = 1.0). Passing full_channel=True also checks logical operators — essential across M repeated QEC cycles, where a residual logical rotation would otherwise accumulate coherently as M² instead of M — flagging the weight-5 logical X (XXXXX) on [[5, 1, 3]]. For the full formal proof and the 8-run selective-twirling sign table, see Foundations.

Scope and Limitations

Where to Go Next

PageBest for
FoundationsUnderstanding the math: coherent interference, the 8-run Steane sign table, Theorem 1a/1b, minimal twirling, and references.
BenchmarksViewing the 980-row exact sweep, 10-paper machine-precision validation, and scaling across all 7 Bravyi et al. BB codes.
ExamplesTask-driven copy-and-run workflows from the four executed Jupyter notebooks (01–04).
API ReferenceFast lookup of every public function, class, parameter, and return value (no math walls).

Citation & License

Created by A Muh Mufqi Zuhudi and released under the Apache-2.0 License. Machine-readable citation metadata is available in CITATION.cff:

@software{zuhudi2026paulicert,
  author  = {Zuhudi, A Muh Mufqi},
  title   = {paulicert: Exactness Certificates for Pauli-Channel Simulation of Stabilizer Codes},
  version = {0.1.1},
  year    = {2026},
  license = {Apache-2.0},
  url     = {https://paulicert.moefqy.com}
}