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 p | Pauli model | True coherent channel | Steane + twirl 3 qubits | Better 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.
{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.
[[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 error | After correction | Effect on the encoded qubit |
|---|---|---|
IIIXIII | IIIIIII | Corrected (no error) |
XXIIIII | XXIXIII = · g1g2 | Logical error |
IIXIIIX | IIXXIIX = · g3 | Logical error |
IIIIXXI | IIIXXXI = | Logical error |
The three failures differ only by stabilizers, so they act identically on the code: they all apply logical .
- Pauli model: Three separate random events of probability
p²each, so the probabilities add:3p². Summed over the 7 syndromes this gives21p². - Coherent noise: Three branches of one superposition, each with amplitude
−p, ending in the same state. The amplitudes add before squaring:|3p|² = 9p². Summed over the 7 syndromes this gives63p².
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 (XXXXX) on [[5, 1, 3]]. For the full formal proof and the 8-run selective-twirling sign table, see Foundations.
Scope and Limitations
- Complementary to Stim: Stim simulates Pauli noise at millions of shots per second;
paulicertchecks beforehand whether Pauli simulation is actually faithful for your code and physical noise model, and tells you the fewest qubits to twirl if it isn’t. - Distance suppresses logical rotations, not low-weight check interference: Off-diagonal logical coherence scales as
O(θ^d)and decays exponentially with code distanced(Beale et al., PRL 2018; Iverson & Preskill, NJP 2020), whereas diagonal infidelity bias (gap != 1) is governed by minimum witness weight — sharpest in small near-term codes and persistent in large CSS/qLDPC families whenever constant-weight checks align with a coherent error axis. - Independent single-qubit code-capacity model only: Single-qubit noise acts independently once on each data qubit with ideal syndrome extraction and one round of lookup-table recovery. Correlated two-qubit coherent noise (e.g. ZZ crosstalk), circuit-level noise, and measurement errors are outside v0.1.
- Scaling & four simulation engines: Exact superoperators (
logical_channel,method="exact_channel") and coset ML decoding supportn ≤ 10; lookup-table error-rate sweeps supportr ≤ 16; Qiskit V2SamplerV2Pauli-frame circuit simulation (method="aer_circuit") supportsn + k ≤ 24. Certification (pauli_exact,minimal_twirl_set) scales in milliseconds–seconds to large qLDPC codes up to[[756, 16, ≤34]]. - Sufficient, not necessary & calibrated-channel threshold (
tol=1e-10):exact=Trueis a proof of equality;exact=Falsewarns that interference is possible, not guaranteed. On tomographically calibrated hardware gates with small off-axis tilt, raisetolto match your physical floor or inspect quantitativegapandchoi_distancevialogical_channel(n ≤ 10). - Validated: Cross-checked to machine precision against 10 published papers and 980 exact sweep points (see Benchmarks).
Where to Go Next
| Page | Best for |
|---|---|
| Foundations | Understanding the math: coherent interference, the 8-run Steane sign table, Theorem 1a/1b, minimal twirling, and references. |
| Benchmarks | Viewing the 980-row exact sweep, 10-paper machine-precision validation, and scaling across all 7 Bravyi et al. BB codes. |
| Examples | Task-driven copy-and-run workflows from the four executed Jupyter notebooks (01–04). |
| API Reference | Fast 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}
}