QuantumCore

Lesson 52 · 90 min · advanced

Error Mitigation: ZNE & Readout Correction

Loading progress…

Noisy quantum processors cannot yet afford quantum error correction, but many applications only need expectation values, and those can be corrected statistically. This lesson derives three error-mitigation techniques from first principles. Zero-noise extrapolation measures an observable at amplified noise levels λ=1,3,5\lambda=1,3,5 produced by global unitary folding U↦U(U†U)kU\mapsto U(U^\dagger U)^k and extrapolates to λ=0\lambda=0 with the Richardson weights γi=∏j≠iλj/(λj−λi)\gamma_i=\prod_{j\ne i}\lambda_j/(\lambda_j-\lambda_i), which cancel the noise expansion up to order m−1m-1; the price is a variance amplified by ∑iγi2=5.21875\sum_i\gamma_i^2=5.21875 for the nodes {1,3,5}\{1,3,5\}. Readout mitigation inverts the column-stochastic confusion matrix AA of the measurement, qubit by qubit, and repairs negative quasi-probabilities. Probabilistic error cancellation writes the inverse of a noise channel as a signed mixture of implementable operations and pays a sampling overhead γ2\gamma^2 per gate.

Prerequisites: Noise, Decoherence, $T_1$ and $T_2$

Objectives and key results
  • Derive the Richardson weights γi=∏j≠iλj/(λj−λi)\gamma_i=\prod_{j\ne i}\lambda_j/(\lambda_j-\lambda_i) as Lagrange interpolation at λ=0\lambda=0, prove ∑iγi=1\sum_i\gamma_i=1 and ∑iγiλik=0\sum_i\gamma_i\lambda_i^k=0 for 1≤k≤m−11\le k\le m-1, and compute γ=(158,−54,38)\gamma=\big(\tfrac{15}8,-\tfrac54,\tfrac38\big) for the nodes {1,3,5}\{1,3,5\}.

  • Explain what global folding U↦U(U†U)kU\mapsto U(U^\dagger U)^k builds and prove that it multiplies first-order gate noise by λ=2k+1\lambda=2k+1, stating the assumptions on the noise.

  • Compute the variance amplification Var[E^0]=∑iγi2 Var[E^(λi)]\mathrm{Var}[\hat E_0]=\sum_i\gamma_i^2\,\mathrm{Var}[\hat E(\lambda_i)] of an extrapolated estimate and the shot budget it requires.

  • Model readout errors by a column-stochastic confusion matrix, invert it in closed form and for tensor products of qubits, and repair negative quasi-probabilities by clipping or by Euclidean projection onto the probability simplex.

  • Construct the quasi-probability decomposition of the inverse depolarizing channel and derive the sampling overhead γ2G\gamma^{2G} of probabilistic error cancellation.

  • Run noise-scaled circuits on the platform's density-matrix engine and mitigate expectation values and measured distributions by hand and in code.

formula · Richardson extrapolation to zero noise
E0≈∑i=1mγiE(λi),γi=∏j≠iλjλj−λi,{1,3,5}: E0≈158E(1)−54E(3)+38E(5)E_0\approx\sum_{i=1}^m\gamma_iE(\lambda_i),\qquad\gamma_i=\prod_{j\ne i}\frac{\lambda_j}{\lambda_j-\lambda_i},\qquad\{1,3,5\}:\ E_0\approx\tfrac{15}8E(1)-\tfrac54E(3)+\tfrac38E(5)
theorem · Cancellation of the noise expansion
∑i=1mγiλik=δk0(0≤k≤m−1),∑i=1mγiλim=(−1)m−1∏i=1mλi\sum_{i=1}^m\gamma_i\lambda_i^k=\delta_{k0}\quad(0\le k\le m-1),\qquad\sum_{i=1}^m\gamma_i\lambda_i^m=(-1)^{m-1}\prod_{i=1}^m\lambda_i
identity · Variance amplification
Var[E^0]=∑iγi2 Var[E^(λi)],∑iγi2=33464=5.21875 for {1,3,5}\mathrm{Var}\big[\hat E_0\big]=\sum_i\gamma_i^2\,\mathrm{Var}\big[\hat E(\lambda_i)\big],\qquad\sum_i\gamma_i^2=\tfrac{334}{64}=5.21875\ \text{for}\ \{1,3,5\}
formula · Inverse of a single-qubit confusion matrix
A=(1−p01p10p011−p10),A−1=11−p01−p10(1−p10−p10−p011−p01),(⨂qAq)−1=⨂qAq−1A=\begin{pmatrix}1-p_{01}&p_{10}\\p_{01}&1-p_{10}\end{pmatrix},\qquad A^{-1}=\frac1{1-p_{01}-p_{10}}\begin{pmatrix}1-p_{10}&-p_{10}\\-p_{01}&1-p_{01}\end{pmatrix},\qquad\Big(\bigotimes_qA_q\Big)^{-1}=\bigotimes_qA_q^{-1}
formula · Probabilistic error cancellation of depolarizing noise
Dp−1=qI I+qP(X+Y+Z),qI=1+3/f4, qP=1−1/f4,γ=3/f−12,f=1−4p3,overhead γ2G\mathcal D_p^{-1}=q_I\,\mathcal I+q_P\big(\mathcal X+\mathcal Y+\mathcal Z\big),\quad q_I=\frac{1+3/f}4,\ q_P=\frac{1-1/f}4,\quad\gamma=\frac{3/f-1}2,\quad f=1-\tfrac{4p}3,\quad\text{overhead }\gamma^{2G}

Mitigation instead of correction#

The previous lesson modelled decoherence and gate errors as quantum channels and showed how quickly they degrade a computation: local depolarizing noise of strength pp on both qubits of a Bell state lowers its fidelity to 14(1+3f2)\tfrac14(1+3f^2) with f=1−4p3f=1-\tfrac{4p}3, and every additional gate compounds the damage. Quantum error correction removes such errors by encoding each logical qubit into many physical qubits and measuring syndromes continuously, but its overhead of hundreds to thousands of physical qubits per logical qubit is beyond today's noisy intermediate-scale (NISQ) processors.

Variational algorithms and quantum machine learning models, however, rarely need the full output state. They need expectation values ⟨O⟩=Tr(Oρ)\langle O\rangle=\mathrm{Tr}(O\rho) of a few observables, estimated from many repetitions of a circuit. Error mitigation exploits this: it runs additional or modified noisy circuits and combines their measured averages classically so that the combination estimates the noiseless value Tr(Oρideal)\mathrm{Tr}(O\rho_{\text{ideal}}). No qubits are added, but nothing is free either: every mitigation scheme trades a reduction of the bias for an increase of the variance, which must be paid for with more shots. This lesson derives the three most widely used schemes and their costs: zero-noise extrapolation, readout-error mitigation and probabilistic error cancellation.

Definition

Noise-scaled expectation value

Fix a circuit, an input state and an observable OO with ∥O∥≤1\lVert O\rVert\le1. Suppose the strength of all noise processes in the circuit can be multiplied by a factor λ≥1\lambda\ge1 without changing anything else; λ=1\lambda=1 is the native noise of the device. The noise-scaled expectation value E(λ)E(\lambda) is the exact (infinite-shot) expectation of OO at scale λ\lambda, and E0=E(0)E_0=E(0) is the noiseless value we want. Zero-noise extrapolation (ZNE) assumes that EE is smooth near 00 and admits the expansion E(λ)=E0+∑k≥1akλk,E(\lambda)=E_0+\sum_{k\ge1}a_k\lambda^k, measures EE at a few nodes 1≤λ1<⋯<λm1\le\lambda_1<\dots<\lambda_m, and extrapolates to λ=0\lambda=0. If the native noise has a small strength ϵ\epsilon, the coefficients scale as ak=bkϵka_k=b_k\epsilon^k.

Richardson extrapolation#

Given measured values E(λ1),…,E(λm)E(\lambda_1),\dots,E(\lambda_m) at distinct nodes, the most natural estimate of E0E_0 interpolates the data with the unique polynomial of degree at most m−1m-1 and evaluates it at 00. Because interpolation is linear in the data, this estimate is a fixed linear combination ∑iγiE(λi)\sum_i\gamma_iE(\lambda_i) whose weights depend only on the nodes. The weights are designed so that the combination annihilates the low powers of λ\lambda in the noise expansion; this idea goes back to L. F. Richardson's extrapolation of numerical step sizes to zero and was introduced for quantum circuits by Temme, Bravyi and Gambetta.

Theorem

Richardson weights cancel the noise expansion up to order m − 1

Let λ1,…,λm\lambda_1,\dots,\lambda_m be distinct and nonzero, and define γi=∏j≠iλjλj−λi,i=1,…,m.\gamma_i=\prod_{j\ne i}\frac{\lambda_j}{\lambda_j-\lambda_i},\qquad i=1,\dots,m. Then (i) ∑iγi=1\sum_i\gamma_i=1; (ii) ∑iγiλik=0\sum_i\gamma_i\lambda_i^k=0 for 1≤k≤m−11\le k\le m-1; (iii) ∑iγiλim=(−1)m−1∏iλi\sum_i\gamma_i\lambda_i^m=(-1)^{m-1}\prod_i\lambda_i. Consequently, if E(λ)=E0+∑k=1m−1akλk+R(λ)E(\lambda)=E_0+\sum_{k=1}^{m-1}a_k\lambda^k+R(\lambda) with ∣R(λ)∣≤Cλm\lvert R(\lambda)\rvert\le C\lambda^m, the Richardson estimate satisfies ∣∑iγiE(λi)−E0∣≤C∑i∣γi∣λim,\Big\lvert\sum_i\gamma_iE(\lambda_i)-E_0\Big\rvert\le C\sum_i\lvert\gamma_i\rvert\lambda_i^m, and if R(λ)=amλm+O(λm+1)R(\lambda)=a_m\lambda^m+O(\lambda^{m+1}) its leading bias is (−1)m−1am∏iλi(-1)^{m-1}a_m\prod_i\lambda_i. With ak=bkϵka_k=b_k\epsilon^k the bias is O(ϵm)O(\epsilon^m), whereas the unmitigated value E(1)E(1) has bias O(ϵ)O(\epsilon).

Proof (7 steps)
  1. Step 1:
    ℓi(x)=∏j≠ix−λjλi−λj,ℓi(λk)=δik\ell_i(x)=\prod_{j\ne i}\frac{x-\lambda_j}{\lambda_i-\lambda_j},\qquad\ell_i(\lambda_k)=\delta_{ik}
    The Lagrange basis polynomials of the nodes: each has degree m−1m-1, vanishes at every node except λi\lambda_i, and equals 11 there. They exist because the nodes are distinct.
  2. Step 2:
    deg⁡q≤m−1 ⇒ q(x)=∑i=1mq(λi) ℓi(x)for all x\deg q\le m-1\ \Rightarrow\ q(x)=\sum_{i=1}^mq(\lambda_i)\,\ell_i(x)\quad\text{for all }x
    The difference of the two sides is a polynomial of degree at most m−1m-1 with the mm roots λ1,…,λm\lambda_1,\dots,\lambda_m, so it is the zero polynomial.
  3. Step 3:
    ℓi(0)=∏j≠i0−λjλi−λj=∏j≠iλjλj−λi=γi\ell_i(0)=\prod_{j\ne i}\frac{0-\lambda_j}{\lambda_i-\lambda_j}=\prod_{j\ne i}\frac{\lambda_j}{\lambda_j-\lambda_i}=\gamma_i
    Multiply numerator and denominator of every factor by −1-1. The Richardson weights are the Lagrange basis polynomials evaluated at x=0x=0.
  4. Step 4:
    q(x)=xk, 0≤k≤m−1:∑i=1mγiλik=0k=δk0q(x)=x^k,\ 0\le k\le m-1:\qquad\sum_{i=1}^m\gamma_i\lambda_i^k=0^k=\delta_{k0}
    Evaluate the interpolation identity at x=0x=0. For k=0k=0 this is ∑iγi=1\sum_i\gamma_i=1, statement (i); for 1≤k≤m−11\le k\le m-1 it is statement (ii). In matrix form the weights solve the Vandermonde system V⊤γ=e0V^\top\gamma=e_0 with Vik=λikV_{ik}=\lambda_i^k, which is nonsingular because det⁡V=∏i<j(λj−λi)≠0\det V=\prod_{i<j}(\lambda_j-\lambda_i)\ne0.
  5. Step 5:
    xm−∑i=1mλim ℓi(x)=∏i=1m(x−λi) ⟹x=0 −∑iγiλim=(−1)m∏iλix^m-\sum_{i=1}^m\lambda_i^m\,\ell_i(x)=\prod_{i=1}^m(x-\lambda_i)\ \overset{x=0}{\Longrightarrow}\ -\sum_i\gamma_i\lambda_i^m=(-1)^m\prod_i\lambda_i
    The left side is monic of degree mm (the sum has degree at most m−1m-1) and vanishes at all mm nodes, so it equals the monic polynomial with these roots. Multiplying by −1-1 gives statement (iii).
  6. Step 6:
    ∑iγiE(λi)=E0∑iγi+∑k=1m−1ak∑iγiλik+∑iγiR(λi)=E0+∑iγiR(λi)\sum_i\gamma_iE(\lambda_i)=E_0\sum_i\gamma_i+\sum_{k=1}^{m-1}a_k\sum_i\gamma_i\lambda_i^k+\sum_i\gamma_iR(\lambda_i)=E_0+\sum_i\gamma_iR(\lambda_i)
    Insert the expansion and use (i) and (ii): the constant survives with weight one and every term of order 1,…,m−11,\dots,m-1 cancels exactly.
  7. Step 7:
    ∣∑iγiR(λi)∣≤C∑i∣γi∣λim,R=amλm+O(λm+1) ⇒ ∑iγiR(λi)=(−1)m−1am∏iλi+O(am+1)\Big\lvert\sum_i\gamma_iR(\lambda_i)\Big\rvert\le C\sum_i\lvert\gamma_i\rvert\lambda_i^m,\qquad R=a_m\lambda^m+O(\lambda^{m+1})\ \Rightarrow\ \sum_i\gamma_iR(\lambda_i)=(-1)^{m-1}a_m\prod_i\lambda_i+O(a_{m+1})
    Triangle inequality for the bound; statement (iii) for the leading term. With ak=bkϵka_k=b_k\epsilon^k every remaining term carries at least the factor ϵm\epsilon^m.

∎

Derivation

The weights for the nodes {1, 3, 5}

  1. Step 1:
    γ1=33−1⋅55−1=158,γ2=11−3⋅55−3=−54,γ3=11−5⋅33−5=38\gamma_1=\frac{3}{3-1}\cdot\frac{5}{5-1}=\frac{15}8,\qquad\gamma_2=\frac{1}{1-3}\cdot\frac{5}{5-3}=-\frac54,\qquad\gamma_3=\frac{1}{1-5}\cdot\frac{3}{3-5}=\frac38
    Each weight is the product over the two other nodes of λj/(λj−λi)\lambda_j/(\lambda_j-\lambda_i).
  2. Step 2:
    ∑iγi=15−10+38=1,∑iγiλi=15−30+158=0,∑iγiλi2=15−90+758=0\sum_i\gamma_i=\frac{15-10+3}8=1,\qquad\sum_i\gamma_i\lambda_i=\frac{15-30+15}8=0,\qquad\sum_i\gamma_i\lambda_i^2=\frac{15-90+75}8=0
    Statements (i) and (ii) of the theorem with m=3m=3: the constant is reproduced, the linear and quadratic terms cancel.
  3. Step 3:
    ∑iγiλi3=15−270+3758=15=(−1)2⋅1⋅3⋅5,∑iγiλi4=15−810+18758=135\sum_i\gamma_i\lambda_i^3=\frac{15-270+375}8=15=(-1)^2\cdot1\cdot3\cdot5,\qquad\sum_i\gamma_i\lambda_i^4=\frac{15-810+1875}8=135
    Statement (iii): the leading bias of the three-node estimate is 15 a315\,a_3; the next term contributes 135 a4135\,a_4.
  4. Step 4:
    E0≈158E(1)−54E(3)+38E(5)E_0\approx\tfrac{15}8E(1)-\tfrac54E(3)+\tfrac38E(5)
    The Richardson estimate through {1,3,5}\{1,3,5\}, implemented by the engine function richardsonExtrapolate (and, for arbitrary nodes, by richardsonZeroNoise).
  5. Step 5:
    {1,3}: γ=(32,−12), ∑iγiλi2=−3;{1,5}: γ=(54,−14), ∑iγiλi2=−5\{1,3\}:\ \gamma=\big(\tfrac32,-\tfrac12\big),\ \sum_i\gamma_i\lambda_i^2=-3;\qquad\{1,5\}:\ \gamma=\big(\tfrac54,-\tfrac14\big),\ \sum_i\gamma_i\lambda_i^2=-5
    Two-node (linear) extrapolations cancel only the linear term. Their bias is −3a2-3a_2 and −5a2-5a_2, respectively: the farther apart the nodes, the larger the uncancelled curvature.

Result

γ(1,3,5)=(158, −54, 38),bias=15 a3+135 a4+…\boxed{\gamma(1,3,5)=\big(\tfrac{15}8,\,-\tfrac54,\,\tfrac38\big),\qquad\text{bias}=15\,a_3+135\,a_4+\dots}

The weights alternate in sign and exceed one in magnitude: the estimate is an extrapolation, not an average. For the lab data E(1)=0.80E(1)=0.80, E(3)=0.56E(3)=0.56, E(5)=0.40E(5)=0.40 the three points lie on the parabola E(λ)=0.95−0.16λ+0.01λ2E(\lambda)=0.95-0.16\lambda+0.01\lambda^2, and the Richardson estimate 1.5−0.7+0.15=0.951.5-0.7+0.15=0.95 is its value at λ=0\lambda=0. A straight line through the nodes 11 and 33 would give 0.920.92, one through 11 and 55 would give 0.900.90, and the least-squares line through all three points would give 0.88670.8867; all three miss the curvature.

Quick check

An expectation value measured at the noise scales λ=1\lambda=1 and λ=2\lambda=2 gives E(1)=0.90E(1)=0.90 and E(2)=0.82E(2)=0.82. What is the two-node Richardson (linear) estimate of E0E_0?

tolerance ±0.0001

Scaling the noise by global unitary folding#

Pulse stretching requires access to the control electronics. Giurgica-Tiron et al. proposed a purely digital alternative that works on any gate-based device: replace the circuit UU by a longer circuit that implements the same unitary but contains λ\lambda times as many gates. Since U†U=IU^\dagger U=I, appending kk copies of U†UU^\dagger U leaves the ideal output unchanged while every noisy gate is executed 2k+12k+1 times.

Definition

Global unitary folding

Let U=Gd⋯G1U=G_d\cdots G_1 be a circuit of dd gates (applied in the order G1,…,GdG_1,\dots,G_d). For an odd scale factor λ=2k+1\lambda=2k+1, the globally folded circuit is Uλ=U (U†U)k,U_\lambda=U\,(U^\dagger U)^k, executed as the gate sequence G1,…,GdG_1,\dots,G_d followed kk times by the inverse block Gd†,…,G1†G_d^\dagger,\dots,G_1^\dagger and the forward block G1,…,GdG_1,\dots,G_d; it contains λd\lambda d gates. The engine function foldGlobal builds exactly this sequence: it inverts rotations by negating their angles (RP(θ)†=RP(−θ)R_P(\theta)^\dagger=R_P(-\theta)), maps S↔S†S\leftrightarrow S^\dagger and T↔T†T\leftrightarrow T^\dagger, keeps the self-inverse gates X,Y,Z,H,CNOT,SWAPX,Y,Z,H,\mathrm{CNOT},\mathrm{SWAP}, replaces any other gate by its conjugate transpose, repeats noise channels in reverse order instead of inverting them (a channel has no physical inverse), and moves terminal measurements to the end. Only odd scales are possible with global folding; intermediate values require folding a subset of the gates.

Circuit · 2 qubits

Quantum circuit on 2 qubitsH on q0; X on q1 controlled by q0; X on q1 controlled by q0; H on q0; H on q0; X on q1 controlled by q0q0q1HHH

foldGlobal at λ=3\lambda=3 of the Bell circuit U=CNOT01(H⊗I)U=\mathrm{CNOT}_{01}(H\otimes I): the gate sequence H,CNOT∣CNOT,H∣H,CNOTH,\mathrm{CNOT}\mid\mathrm{CNOT},H\mid H,\mathrm{CNOT}. Without noise the folded circuit prepares the same state 12(∣00⟩+∣11⟩)\tfrac1{\sqrt2}(\lvert00\rangle+\lvert11\rangle) and has the same unitary as UU.

∣ψ⟩=12∣00⟩+12∣11⟩\lvert\psi\rangle = \tfrac{1}{\sqrt{2}}\lvert 00\rangle + \tfrac{1}{\sqrt{2}}\lvert 11\rangle
U=(1201200120120120−12120−120)U = \begin{pmatrix} \tfrac{1}{\sqrt{2}} & 0 & \tfrac{1}{\sqrt{2}} & 0 \\ 0 & \tfrac{1}{\sqrt{2}} & 0 & \tfrac{1}{\sqrt{2}} \\ 0 & \tfrac{1}{\sqrt{2}} & 0 & -\tfrac{1}{\sqrt{2}} \\ \tfrac{1}{\sqrt{2}} & 0 & -\tfrac{1}{\sqrt{2}} & 0 \end{pmatrix}
Proposition

Global folding multiplies first-order gate noise by λ = 2k + 1

Write Gj(ρ)=GjρGj†\mathcal G_j(\rho)=G_j\rho G_j^\dagger and compose superoperators from right to left. Let the circuit run as N=EdGd⋯E1G1\mathcal N=\mathcal E_d\mathcal G_d\cdots\mathcal E_1\mathcal G_1, where the noise of gate jj is a channel Ej=I+ϵ Lj+O(ϵ2)\mathcal E_j=\mathcal I+\epsilon\,\mathcal L_j+O(\epsilon^2) on the qubits of GjG_j (weak, Markovian, time-independent noise of strength ϵ\epsilon; Lj\mathcal L_j does not depend on ϵ\epsilon). Let U≤j=Gj⋯G1\mathcal U_{\le j}=\mathcal G_j\cdots\mathcal G_1, U>j=Gd⋯Gj+1\mathcal U_{>j}=\mathcal G_d\cdots\mathcal G_{j+1} and cj=Tr[O U>jLjU≤j(ρ0)]c_j=\mathrm{Tr}\big[O\,\mathcal U_{>j}\mathcal L_j\mathcal U_{\le j}(\rho_0)\big], so that E(1)=E0+ϵ∑jcj+O(ϵ2)E(1)=E_0+\epsilon\sum_jc_j+O(\epsilon^2).

(a) Folding as foldGlobal does, with the inverse block G1†E1⋯Gd†Ed\mathcal G_1^\dagger\mathcal E_1\cdots\mathcal G_d^\dagger\mathcal E_d (each channel repeated, in reverse order), gives for λ=2k+1\lambda=2k+1 E(λ)=E0+λ ϵ∑jcj+O(ϵ2).E(\lambda)=E_0+\lambda\,\epsilon\sum_jc_j+O(\epsilon^2). (b) If every executed inverse gate is followed by its own noise, EjGj†\mathcal E_j\mathcal G_j^\dagger (the usual situation on hardware), then E(λ)=E0+ϵ[(k+1)∑jcj+k∑jcj′]+O(ϵ2)E(\lambda)=E_0+\epsilon\big[(k+1)\sum_jc_j+k\sum_jc_j'\big]+O(\epsilon^2) with cj′=Tr[O U≥jLjU<j(ρ0)]c_j'=\mathrm{Tr}\big[O\,\mathcal U_{\ge j}\mathcal L_j\mathcal U_{<j}(\rho_0)\big]; this equals (a) whenever cj′=cjc_j'=c_j, in particular when Lj\mathcal L_j commutes with Gj\mathcal G_j, as for depolarizing noise after a single-qubit gate.

Proof (7 steps)
  1. Step 1:
    Nseq=Useq+ϵ∑tAt Lt Bt+O(ϵ2)\mathcal N_{\text{seq}}=\mathcal U_{\text{seq}}+\epsilon\sum_t\mathcal A_t\,\mathcal L_t\,\mathcal B_t+O(\epsilon^2)
    Multiply out any sequence of ideal gates and noisy locations tt: a first-order term picks ϵLt\epsilon\mathcal L_t at exactly one location and I\mathcal I at all others; Bt\mathcal B_t is the product of the ideal gates before location tt and At\mathcal A_t the product after it.
  2. Step 2:
    U(U†U)k=U ⇒ Ufold=U ⇒ E(λ)=E0+O(ϵ)U(U^\dagger U)^k=U\ \Rightarrow\ \mathcal U_{\text{fold}}=\mathcal U\ \Rightarrow\ E(\lambda)=E_0+O(\epsilon)
    The ideal gates of the folded sequence multiply to UU because U†U=IU^\dagger U=I, so the zeroth-order term is the noiseless value for every kk.
  3. Step 3:
    forward block r (0≤r≤k), after Gj:Bt=U≤j(U†U)r=U≤j,At=(U U†)k−r U>j=U>j\text{forward block }r\ (0\le r\le k),\ \text{after }G_j:\quad\mathcal B_t=\mathcal U_{\le j}\big(\mathcal U^\dagger\mathcal U\big)^r=\mathcal U_{\le j},\qquad\mathcal A_t=\big(\mathcal U\,\mathcal U^\dagger\big)^{k-r}\,\mathcal U_{>j}=\mathcal U_{>j}
    Before the noise of GjG_j in the rr-th forward block come rr complete pairs U,U†U,U^\dagger and the gates G1,…,GjG_1,\dots,G_j; after it come Gj+1,…,GdG_{j+1},\dots,G_d and k−rk-r pairs U†,UU^\dagger,U. Complete pairs act as the identity, so this location contributes ϵ cj\epsilon\,c_j.
  4. Step 4:
    inverse block, channel of Gj before Gj†:Bt=U>j† U=U≤j,At=U U≤j†=U>j\text{inverse block, channel of }G_j\text{ before }G_j^\dagger:\quad\mathcal B_t=\mathcal U_{>j}^\dagger\,\mathcal U=\mathcal U_{\le j},\qquad\mathcal A_t=\mathcal U\,\mathcal U_{\le j}^\dagger=\mathcal U_{>j}
    In foldGlobal's order the inverse block runs Ed,Gd†,…,Ej,Gj†,…\mathcal E_d,G_d^\dagger,\dots,\mathcal E_j,G_j^\dagger,\dots. Before Ej\mathcal E_j the ideal gates net to UU followed by Gd†,…,Gj+1†G_d^\dagger,\dots,G_{j+1}^\dagger, i.e. U>j†U=U≤jU_{>j}^\dagger U=U_{\le j}; after it come Gj†,…,G1†G_j^\dagger,\dots,G_1^\dagger and gates netting to UU, i.e. U U≤j†=U>jU\,U_{\le j}^\dagger=U_{>j}. This location also contributes ϵ cj\epsilon\,c_j.
  5. Step 5:
    E(λ)=E0+ϵ[(k+1)∑jcj+k∑jcj]+O(ϵ2)=E0+(2k+1) ϵ∑jcj+O(ϵ2)E(\lambda)=E_0+\epsilon\Big[(k+1)\sum_jc_j+k\sum_jc_j\Big]+O(\epsilon^2)=E_0+(2k+1)\,\epsilon\sum_jc_j+O(\epsilon^2)
    There are k+1k+1 forward blocks and kk inverse blocks, each containing the noise of every gate once. This proves (a).
  6. Step 6:
    Ej after Gj†:Bt=Gj† U>j† U=U<j,At=U U<j†=U≥j ⇒ cj′\mathcal E_j\text{ after }G_j^\dagger:\quad\mathcal B_t=\mathcal G_j^\dagger\,\mathcal U_{>j}^\dagger\,\mathcal U=\mathcal U_{<j},\qquad\mathcal A_t=\mathcal U\,\mathcal U_{<j}^\dagger=\mathcal U_{\ge j}\ \Rightarrow\ c_j'
    In hardware order the noise of Gj†G_j^\dagger acts after it, one gate earlier in the ideal circuit's coordinates: the error sits between Gj−1G_{j-1} and GjG_j. Counting blocks as before gives (b).
  7. Step 7:
    LjGj=GjLj ⇒ cj′=Tr[O U>jGjLjU<j(ρ0)]=Tr[O U>jLjGjU<j(ρ0)]=cj\mathcal L_j\mathcal G_j=\mathcal G_j\mathcal L_j\ \Rightarrow\ c_j'=\mathrm{Tr}\big[O\,\mathcal U_{>j}\mathcal G_j\mathcal L_j\mathcal U_{<j}(\rho_0)\big]=\mathrm{Tr}\big[O\,\mathcal U_{>j}\mathcal L_j\mathcal G_j\mathcal U_{<j}(\rho_0)\big]=c_j
    Use U≥j=U>jGj\mathcal U_{\ge j}=\mathcal U_{>j}\mathcal G_j and GjU<j=U≤j\mathcal G_j\mathcal U_{<j}=\mathcal U_{\le j}. The depolarizing channel ρ↦fρ+(1−f)Tr(ρ)I2\rho\mapsto f\rho+(1-f)\mathrm{Tr}(\rho)\tfrac I2 commutes with every single-qubit unitary conjugation, so the condition holds for depolarizing noise after single-qubit gates.

∎

Derivation

Zero-noise extrapolation of the noisy Bell circuit, exactly

  1. Step 1:
    U=CNOT01(H⊗I),noise Dp after H on qubit 0 and after CNOT on qubits 0,1,O=Z⊗Z,E0=⟨Φ+∣Z⊗Z∣Φ+⟩=1U=\mathrm{CNOT}_{01}(H\otimes I),\quad\text{noise }\mathcal D_p\text{ after }H\text{ on qubit }0\text{ and after CNOT on qubits }0,1,\quad O=Z\otimes Z,\quad E_0=\langle\Phi^+\vert Z\otimes Z\vert\Phi^+\rangle=1
    The worked example: the Bell circuit with a depolarizing channel after every gate on each qubit the gate touches, p=0.01p=0.01.
  2. Step 2:
    Tr[O N(ρ0)]=Tr[N†(O) ρ0],Dp†(P)=Dp(P)=(1−p)P+p3(P−2P)=fP  (P∈{X,Y,Z}),Dp(I)=I\mathrm{Tr}\big[O\,\mathcal N(\rho_0)\big]=\mathrm{Tr}\big[\mathcal N^\dagger(O)\,\rho_0\big],\qquad\mathcal D_p^\dagger(P)=\mathcal D_p(P)=(1-p)P+\tfrac p3\big(P-2P\big)=fP\ \ (P\in\{X,Y,Z\}),\quad\mathcal D_p(I)=I
    Heisenberg picture: the adjoint channels act on the observable in reverse order. The Kraus operators of Dp\mathcal D_p are Hermitian, so Dp†=Dp\mathcal D_p^\dagger=\mathcal D_p; a Pauli PP commutes with itself and anticommutes with the two other Paulis, which gives f=1−4p3f=1-\tfrac{4p}3.
  3. Step 3:
    CNOT01(Z⊗Z) CNOT01=I⊗Z,(H⊗I)(I⊗Z)(H⊗I)=I⊗Z\mathrm{CNOT}_{01}(Z\otimes Z)\,\mathrm{CNOT}_{01}=I\otimes Z,\qquad(H\otimes I)(I\otimes Z)(H\otimes I)=I\otimes Z
    CNOT maps Z0↦Z0Z_0\mapsto Z_0 and Z1↦Z0Z1Z_1\mapsto Z_0Z_1 under conjugation; HH on qubit 00 does not touch the second tensor factor.
  4. Step 4:
    λ=1: Z⊗Z → Dp(0)Dp(1)  f2 Z⊗Z → CNOT  f2 I⊗Z → Dp(0), H  f2 I⊗Z ⇒ E(1)=f2⟨00∣I⊗Z∣00⟩=f2\lambda=1:\ Z\otimes Z\ \xrightarrow{\ \mathcal D_p^{(0)}\mathcal D_p^{(1)}\ }\ f^2\,Z\otimes Z\ \xrightarrow{\ \mathrm{CNOT}\ }\ f^2\,I\otimes Z\ \xrightarrow{\ \mathcal D_p^{(0)},\ H\ }\ f^2\,I\otimes Z\ \Rightarrow\ E(1)=f^2\langle00\vert I\otimes Z\vert00\rangle=f^2
    The two channels after the CNOT each meet a ZZ and contribute ff; the channel after HH meets the identity on qubit 00 and contributes nothing. With p=0.01p=0.01: E(1)=(7475)2=0.9735111111111111E(1)=\big(\tfrac{74}{75}\big)^2=0.9735111111111111.
  5. Step 5:
    forward block: c Z⊗Z↦cf2 I⊗Z,inverse block (D(1)D(0),CNOT,D(0),H): c I⊗Z↦cf2 Z⊗Z\text{forward block}:\ c\,Z\otimes Z\mapsto cf^2\,I\otimes Z,\qquad\text{inverse block }(\mathcal D^{(1)}\mathcal D^{(0)},\mathrm{CNOT},\mathcal D^{(0)},H):\ c\,I\otimes Z\mapsto cf^2\,Z\otimes Z
    Propagating backwards through an inverse block of foldGlobal: HH and the channel on qubit 00 leave I⊗ZI\otimes Z unchanged, the CNOT maps it to Z⊗ZZ\otimes Z, and the two channels on qubits 0,10,1 contribute f2f^2. Each of the λ\lambda blocks therefore contributes f2f^2, and the operator reaching ∣00⟩\lvert00\rangle is I⊗ZI\otimes Z.
  6. Step 6:
    E(λ)=f2λ=e−κλ,κ=−2ln⁡f=0.026846…;E(1)=0.9735111111, E(3)=0.9226197308, E(5)=0.8743887542E(\lambda)=f^{2\lambda}=e^{-\kappa\lambda},\qquad\kappa=-2\ln f=0.026846\ldots;\qquad E(1)=0.9735111111,\ E(3)=0.9226197308,\ E(5)=0.8743887542
    The three values measured with the engine (density backend on foldGlobal of the noisy circuit) agree with f2,f6,f10f^2,f^6,f^{10} to 10−1410^{-14}. This noise model is exactly exponential in λ\lambda, not polynomial.
  7. Step 7:
    158E(1)−54E(3)+38E(5)=0.9999544527,bias=−4.555×10−5≈15a3+135a4+870a5=−52κ3+458κ4−294κ5\tfrac{15}8E(1)-\tfrac54E(3)+\tfrac38E(5)=0.9999544527,\qquad\text{bias}=-4.555\times10^{-5}\approx15a_3+135a_4+870a_5=-\tfrac52\kappa^3+\tfrac{45}8\kappa^4-\tfrac{29}4\kappa^5
    With ak=(−κ)k/k!a_k=(-\kappa)^k/k! the theorem's moment sums ∑iγiλik=15,135,870\sum_i\gamma_i\lambda_i^k=15,135,870 for k=3,4,5k=3,4,5 predict the bias. The unmitigated bias E(1)−1=−2.649×10−2E(1)-1=-2.649\times10^{-2} shrinks by a factor of about 580580; the linear estimate through {1,3}\{1,3\}, 0.99895680130.9989568013, keeps a bias of −1.04×10−3-1.04\times10^{-3}.

Result

E(λ)=(1−4p3)2λ,E^0Rich(p=0.01)=0.9999544527\boxed{E(\lambda)=\big(1-\tfrac{4p}3\big)^{2\lambda},\qquad\hat E_0^{\text{Rich}}(p=0.01)=0.9999544527}

The plot above runs the same folded Bell circuit with p=0.02p=0.02, where f=1−0.083f=1-\tfrac{0.08}3 and the noisy values are E(1)=0.94738E(1)=0.94738, E(3)=0.85029E(3)=0.85029, E(5)=0.76316E(5)=0.76316. Richardson extrapolation returns 0.999650.99965, while an exponential fit of ln⁡E\ln E against λ\lambda recovers E0=1E_0=1 exactly, because the model E=f2λE=f^{2\lambda} is itself exponential. The code cell below reproduces the p=0.01p=0.01 numbers of the derivation with the platform's engine: it folds the noisy circuit with foldGlobal, evaluates ⟨Z⊗Z⟩\langle Z\otimes Z\rangle on the density-matrix backend, extrapolates, and then mitigates readout errors with the functions of the next sections.

TypeScriptrunnable
import { foldGlobal, mitigateReadout, noisyDistribution, richardsonExtrapolate, richardsonZeroNoise, runCircuit } from '@/lib/quantum-simulator';

// H(0) then CNOT(0,1), with a depolarizing channel (p = 0.01) after every gate on each qubit the gate touches.
const p = 0.01;
const dep = (q: number) => ({ kind: 'channel', channel: 'depolarizing', targets: [q], params: [p] });
const bell = {
  version: 1, numQubits: 2, numClbits: 0,
  ops: [
    { kind: 'gate', gate: 'H', targets: [0] }, dep(0),
    { kind: 'gate', gate: 'CNOT', targets: [0, 1] }, dep(0), dep(1),
  ],
};
const ZZ = [{ coeff: 1, ops: 'ZZ' }];
const f = 1 - (4 * p) / 3;
const fmt = (v: number) => v.toFixed(10);

// Global folding U (U^dagger U)^k gives the noise scale 2k + 1; channels are repeated in reverse order.
const E: number[] = [];
for (const scale of [1, 3, 5]) {
  const folded = foldGlobal(bell, scale);
  const gates = folded.ops.filter((op) => op.kind === 'gate').length;
  const channels = folded.ops.filter((op) => op.kind === 'channel').length;
  const value = runCircuit(folded, { backend: 'density', observables: [ZZ] }).expectations![0]!;
  E.push(value);
  console.log('scale ' + scale + ': ' + gates + ' gates, ' + channels + ' channels, <ZZ> = ' + fmt(value) + '   f^(2 scale) = ' + fmt(f ** (2 * scale)));
}
const e0 = richardsonExtrapolate(E[0]!, E[1]!, E[2]!);
const e0General = richardsonZeroNoise([{ scale: 1, value: E[0]! }, { scale: 3, value: E[1]! }, { scale: 5, value: E[2]! }]);
console.log('Richardson {1,3,5}: ' + fmt(e0) + ' (general nodes: ' + fmt(e0General) + '), error ' + (e0 - 1).toExponential(3));
console.log('linear {1,3}: ' + fmt(1.5 * E[0]! - 0.5 * E[1]!) + ', error ' + (1.5 * E[0]! - 0.5 * E[1]! - 1).toExponential(3) + '; unmitigated error ' + (E[0]! - 1).toExponential(3));

// Readout error p01 = 0.05, p10 = 0.10: forward model, then inversion.
const one = { p01: [0.05], p10: [0.1] };
const measured = noisyDistribution(Float64Array.from([0.8, 0.2]), one);
const fixed = mitigateReadout({ '0': measured[0]!, '1': measured[1]! }, one);
console.log('one qubit: true (0.8, 0.2) -> measured (' + fmt(measured[0]!) + ', ' + fmt(measured[1]!) + ') -> mitigated (' + fmt(fixed['0'] ?? 0) + ', ' + fmt(fixed['1'] ?? 0) + ')');

// Two qubits with independent readout errors (qubit 0 = leftmost bit).
const two = { p01: [0.05, 0.02], p10: [0.1, 0.08] };
const fixed2 = mitigateReadout({ '00': 0.4695, '01': 0.0555, '10': 0.0605, '11': 0.4145 }, two);
console.log('two qubits: mitigated ' + ['00', '01', '10', '11'].map((k) => k + ' ' + fmt(fixed2[k] ?? 0)).join(', '));

// A measured (0.97, 0.03) inverts to the quasi-probabilities (1.0235..., -0.0235...); the engine clips and renormalises.
const clipped = mitigateReadout({ '0': 0.97, '1': 0.03 }, one);
console.log('from (0.97, 0.03): mitigated (' + fmt(clipped['0'] ?? 0) + ', ' + fmt(clipped['1'] ?? 0) + ')');

Expected output

scale 1: 2 gates, 3 channels, <ZZ> = 0.9735111111   f^(2 scale) = 0.9735111111
scale 3: 6 gates, 9 channels, <ZZ> = 0.9226197308   f^(2 scale) = 0.9226197308
scale 5: 10 gates, 15 channels, <ZZ> = 0.8743887542   f^(2 scale) = 0.8743887542
Richardson {1,3,5}: 0.9999544527 (general nodes: 0.9999544527), error -4.555e-5
linear {1,3}: 0.9989568013, error -1.043e-3; unmitigated error -2.649e-2
one qubit: true (0.8, 0.2) -> measured (0.7800000000, 0.2200000000) -> mitigated (0.8000000000, 0.2000000000)
two qubits: mitigated 00 0.5000000000, 01 0.0000000000, 10 0.0000000000, 11 0.5000000000
from (0.97, 0.03): mitigated (1.0000000000, 0.0000000000)

Quick check

A circuit of 1212 gates is folded globally to the scale factor λ=5\lambda=5. How many gates does the folded circuit U(U†U)2U(U^\dagger U)^2 contain?

tolerance ±0.5

The price of extrapolation: variance amplification#

On hardware each E(λi)E(\lambda_i) is estimated from a finite number of shots, so the extrapolated value is a random variable. The weights that remove the bias have magnitudes above one, and they multiply the statistical fluctuations of every node.

Proposition

Variance of the Richardson estimate and optimal shot allocation

Let E^i\hat E_i be the mean of NiN_i independent single-shot outcomes at node λi\lambda_i, each with variance σi2\sigma_i^2 (for a ±1\pm1 observable σi2=1−E(λi)2≤1\sigma_i^2=1-E(\lambda_i)^2\le1), and let the estimates at different nodes be independent. Then E^0=∑iγiE^i\hat E_0=\sum_i\gamma_i\hat E_i satisfies E[E^0]=∑iγiE(λi),Var[E^0]=∑iγi2 Var[E^i]=∑iγi2σi2Ni.\mathbb E\big[\hat E_0\big]=\sum_i\gamma_iE(\lambda_i),\qquad\mathrm{Var}\big[\hat E_0\big]=\sum_i\gamma_i^2\,\mathrm{Var}\big[\hat E_i\big]=\sum_i\frac{\gamma_i^2\sigma_i^2}{N_i}. With equal Ni=NN_i=N and σi=σ\sigma_i=\sigma the variance is ∑iγi2\sum_i\gamma_i^2 times that of a single unmitigated estimate from NN shots. For a fixed total budget ∑iNi=Ntot\sum_iN_i=N_{\text{tot}} the variance is minimal for Ni∝∣γi∣σiN_i\propto\lvert\gamma_i\rvert\sigma_i, where it equals (∑i∣γi∣σi)2/Ntot\big(\sum_i\lvert\gamma_i\rvert\sigma_i\big)^2/N_{\text{tot}}.

Proof (5 steps)
  1. Step 1:
    E[E^0]=∑iγi E[E^i]=∑iγiE(λi)\mathbb E\big[\hat E_0\big]=\sum_i\gamma_i\,\mathbb E\big[\hat E_i\big]=\sum_i\gamma_iE(\lambda_i)
    Linearity of expectation; each sample mean is unbiased for its node. The Richardson estimate inherits only the extrapolation bias, not a statistical one.
  2. Step 2:
    Var[∑iγiE^i]=∑i,jγiγj Cov[E^i,E^j]=∑iγi2 Var[E^i]\mathrm{Var}\Big[\sum_i\gamma_i\hat E_i\Big]=\sum_{i,j}\gamma_i\gamma_j\,\mathrm{Cov}\big[\hat E_i,\hat E_j\big]=\sum_i\gamma_i^2\,\mathrm{Var}\big[\hat E_i\big]
    Bilinearity of the covariance; estimates from different circuits are independent, so the off-diagonal covariances vanish.
  3. Step 3:
    Var[E^i]=Var[1Ni∑s=1Nios]=σi2Ni,os∈{±1}: σi2=E[o2]−E[o]2=1−E(λi)2\mathrm{Var}\big[\hat E_i\big]=\mathrm{Var}\Big[\frac1{N_i}\sum_{s=1}^{N_i}o_s\Big]=\frac{\sigma_i^2}{N_i},\qquad o_s\in\{\pm1\}:\ \sigma_i^2=\mathbb E[o^2]-\mathbb E[o]^2=1-E(\lambda_i)^2
    The variance of a mean of NiN_i independent, identically distributed outcomes.
  4. Step 4:
    ∑i∣γi∣σi=∑i∣γi∣σiNiNi≤(∑iγi2σi2Ni)1/2(∑iNi)1/2\sum_i\lvert\gamma_i\rvert\sigma_i=\sum_i\frac{\lvert\gamma_i\rvert\sigma_i}{\sqrt{N_i}}\sqrt{N_i}\le\Big(\sum_i\frac{\gamma_i^2\sigma_i^2}{N_i}\Big)^{1/2}\Big(\sum_iN_i\Big)^{1/2}
    Cauchy–Schwarz inequality for the vectors (∣γi∣σi/Ni)i\big(\lvert\gamma_i\rvert\sigma_i/\sqrt{N_i}\big)_i and (Ni)i\big(\sqrt{N_i}\big)_i.
  5. Step 5:
    Var[E^0]≥(∑i∣γi∣σi)2Ntot,equality  ⟺  ∣γi∣σiNi∝Ni  ⟺  Ni∝∣γi∣σi\mathrm{Var}\big[\hat E_0\big]\ge\frac{\big(\sum_i\lvert\gamma_i\rvert\sigma_i\big)^2}{N_{\text{tot}}},\qquad\text{equality}\iff\frac{\lvert\gamma_i\rvert\sigma_i}{\sqrt{N_i}}\propto\sqrt{N_i}\iff N_i\propto\lvert\gamma_i\rvert\sigma_i
    Square the inequality and divide by Ntot=∑iNiN_{\text{tot}}=\sum_iN_i; Cauchy–Schwarz is an equality exactly when the two vectors are parallel.

∎

Derivation

The amplification factor for the nodes {1, 3, 5}

  1. Step 1:
    ∑iγi2=(158)2+(54)2+(38)2=225+100+964=33464=5.21875\sum_i\gamma_i^2=\Big(\frac{15}8\Big)^2+\Big(\frac54\Big)^2+\Big(\frac38\Big)^2=\frac{225+100+9}{64}=\frac{334}{64}=5.21875
    Square the weights over the common denominator 6464.
  2. Step 2:
    5.21875≈2.2845 ⇒ Ni=5.21875 N per node for the standard error of N unmitigated shots\sqrt{5.21875}\approx2.2845\ \Rightarrow\ N_i=5.21875\,N\ \text{per node for the standard error of }N\text{ unmitigated shots}
    With equal shots per node and equal σ\sigma, the standard deviation of E^0\hat E_0 is 2.282.28 times that of E^(1)\hat E(1). Matching the unmitigated standard error therefore requires about 5.25.2 times as many shots at each node, 3⋅5.21875≈15.73\cdot5.21875\approx15.7 times in total.
  3. Step 3:
    Ni∝∣γi∣=(1528,1028,328)Ntot ⇒ Var[E^0]=(158+54+38)2σ2Ntot=12.25 σ2NtotN_i\propto\lvert\gamma_i\rvert=\big(\tfrac{15}{28},\tfrac{10}{28},\tfrac3{28}\big)N_{\text{tot}}\ \Rightarrow\ \mathrm{Var}\big[\hat E_0\big]=\frac{\big(\frac{15}8+\frac54+\frac38\big)^2\sigma^2}{N_{\text{tot}}}=\frac{12.25\,\sigma^2}{N_{\text{tot}}}
    The optimal allocation of the proposition with equal σ\sigma: ∑i∣γi∣=72\sum_i\lvert\gamma_i\rvert=\tfrac72, so the total budget grows by 12.2512.25 instead of 15.6615.66.
  4. Step 4:
    {1,3,5,7}: γ=(3516,−3516,2116,−516),∑iγi2=1225+1225+441+25256=11.390625\{1,3,5,7\}:\ \gamma=\Big(\frac{35}{16},-\frac{35}{16},\frac{21}{16},-\frac5{16}\Big),\qquad\sum_i\gamma_i^2=\frac{1225+1225+441+25}{256}=11.390625
    Adding a fourth node cancels the cubic term too but more than doubles the variance factor: higher-order extrapolation trades bias for variance.

Result

∑iγi2=5.21875,std factor 5.21875≈2.2845\boxed{\sum_i\gamma_i^2=5.21875,\qquad\text{std factor }\sqrt{5.21875}\approx2.2845}

The plot shows the lab data with the Richardson parabola through the three points, the least-squares line and an exponential fit, together with the weights γi\gamma_i and the factor ∑iγi2\sum_i\gamma_i^2. The default plot below uses a synthetic exponential decay E(λ)=e−0.15λE(\lambda)=e^{-0.15\lambda}. Here Richardson extrapolation through {1,3,5}\{1,3,5\} gives 0.993930.99393, a residual bias of −0.006-0.006 that comes from the cubic and higher terms of the exponential, while the exponential fit is exact. Which model to trust is a physical question: depolarizing noise on Clifford circuits produces sums of exponentials, gate-dependent coherent errors do not. Polynomial extrapolation is agnostic but amplifies variance; exponential extrapolation has lower variance but is biased when the decay is not exponential.

Quick check

By what factor ∑iγi2\sum_i\gamma_i^2 does linear Richardson extrapolation through the two nodes {1,3}\{1,3\} amplify the variance, for equal shots and equal single-shot variance at both nodes?

tolerance ±0.0001

Readout-error mitigation#

Measurement is often the least accurate operation of a superconducting processor: a qubit in ∣1⟩\lvert1\rangle can relax during the readout pulse and be reported as 00, and thermal excitation or overlapping signal distributions can report a ∣0⟩\lvert0\rangle as 11. These errors act after the quantum state has been converted into classical bits, so they can be described by a classical stochastic matrix and undone by linear algebra on the measured histogram. The error rates are calibrated by preparing the basis states and recording how often each is misread.

Definition

Confusion matrix of a readout

For one qubit let p01=P(read 1∣true 0)p_{01}=P(\text{read }1\mid\text{true }0) and p10=P(read 0∣true 1)p_{10}=P(\text{read }0\mid\text{true }1). The confusion matrix has entries Art=P(read r∣true t)A_{rt}=P(\text{read }r\mid\text{true }t), columns labelled by the true bit and rows by the read bit: A=(1−p01p10p011−p10).A=\begin{pmatrix}1-p_{01}&p_{10}\\p_{01}&1-p_{10}\end{pmatrix}. It is column-stochastic: its entries are non-negative and each column sums to 11. If p\mathbf p is the distribution of the true outcomes, the law of total probability gives the distribution of the reported outcomes, p~=Ap\tilde{\mathbf p}=A\mathbf p. The engine implements this convention in confusionMatrix, noisyDistribution and mitigateReadout.

Proposition

Inverse of the single-qubit confusion matrix

det⁡A=1−p01−p10\det A=1-p_{01}-p_{10}, so AA is invertible if and only if p01+p10≠1p_{01}+p_{10}\ne1, and then A−1=11−p01−p10(1−p10−p10−p011−p01).A^{-1}=\frac1{1-p_{01}-p_{10}}\begin{pmatrix}1-p_{10}&-p_{10}\\-p_{01}&1-p_{01}\end{pmatrix}. The columns of A−1A^{-1} sum to 11, so p^=A−1p~\hat{\mathbf p}=A^{-1}\tilde{\mathbf p} sums to 11 whenever p~\tilde{\mathbf p} does, but its entries can be negative. If p~\tilde{\mathbf p} is estimated by measured frequencies, p^\hat{\mathbf p} is an unbiased estimate of p\mathbf p.

Proof (5 steps)
  1. Step 1:
    det⁡A=(1−p01)(1−p10)−p10 p01=1−p01−p10+p01p10−p01p10=1−p01−p10\det A=(1-p_{01})(1-p_{10})-p_{10}\,p_{01}=1-p_{01}-p_{10}+p_{01}p_{10}-p_{01}p_{10}=1-p_{01}-p_{10}
    The determinant of a 2×22\times2 matrix is ad−bcad-bc; the products p01p10p_{01}p_{10} cancel.
  2. Step 2:
    (abcd)−1=1ad−bc(d−b−ca) ⇒ A−1=11−p01−p10(1−p10−p10−p011−p01)\begin{pmatrix}a&b\\c&d\end{pmatrix}^{-1}=\frac1{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}\ \Rightarrow\ A^{-1}=\frac1{1-p_{01}-p_{10}}\begin{pmatrix}1-p_{10}&-p_{10}\\-p_{01}&1-p_{01}\end{pmatrix}
    The adjugate formula with a=1−p01a=1-p_{01}, b=p10b=p_{10}, c=p01c=p_{01}, d=1−p10d=1-p_{10}; it exists exactly when det⁡A≠0\det A\ne0.
  3. Step 3:
    A A−1=1det⁡A((1−p01)(1−p10)−p10p01−(1−p01)p10+p10(1−p01)p01(1−p10)−(1−p10)p01−p01p10+(1−p10)(1−p01))=IA\,A^{-1}=\frac1{\det A}\begin{pmatrix}(1-p_{01})(1-p_{10})-p_{10}p_{01}&-(1-p_{01})p_{10}+p_{10}(1-p_{01})\\p_{01}(1-p_{10})-(1-p_{10})p_{01}&-p_{01}p_{10}+(1-p_{10})(1-p_{01})\end{pmatrix}=I
    Direct verification: the diagonal entries equal det⁡A\det A and the off-diagonal entries cancel.
  4. Step 4:
    1⊤A=1⊤ ⇒ 1⊤=1⊤A−1 ⇒ 1⊤p^=1⊤A−1p~=1⊤p~=1\mathbf 1^\top A=\mathbf 1^\top\ \Rightarrow\ \mathbf 1^\top=\mathbf 1^\top A^{-1}\ \Rightarrow\ \mathbf 1^\top\hat{\mathbf p}=\mathbf 1^\top A^{-1}\tilde{\mathbf p}=\mathbf 1^\top\tilde{\mathbf p}=1
    Column-stochasticity is 1⊤A=1⊤\mathbf 1^\top A=\mathbf 1^\top; multiply from the right by A−1A^{-1}. Explicitly, the first column of A−1A^{-1} sums to (1−p10−p01)/det⁡A=1(1-p_{10}-p_{01})/\det A=1, and so does the second.
  5. Step 5:
    E[p^]=A−1 E[p~^]=A−1A p=p,p~=(0.97,0.03) ⇒ p^=(1.0235294117647058, −0.02352941176470588)\mathbb E\big[\hat{\mathbf p}\big]=A^{-1}\,\mathbb E\big[\hat{\tilde{\mathbf p}}\big]=A^{-1}A\,\mathbf p=\mathbf p,\qquad\tilde{\mathbf p}=(0.97,0.03)\ \Rightarrow\ \hat{\mathbf p}=(1.0235294117647058,\,-0.02352941176470588)
    Linearity of expectation and unbiasedness of measured frequencies. For an individual finite sample, however, A−1A^{-1} can produce negative entries, as the example with p01=0.05p_{01}=0.05, p10=0.10p_{10}=0.10 shows: a nearly pure 00 histogram is over-corrected.

∎

Proposition

Independent readout errors: tensored confusion matrices

If mm qubits are misread independently, with confusion matrices A0,…,Am−1A_0,\dots,A_{m-1}, then with the platform's bit ordering (qubit 00 is the most significant bit) the 2m×2m2^m\times2^m confusion matrix is A=A0⊗A1⊗⋯⊗Am−1,A−1=A0−1⊗A1−1⊗⋯⊗Am−1−1,A=A_0\otimes A_1\otimes\cdots\otimes A_{m-1},\qquad A^{-1}=A_0^{-1}\otimes A_1^{-1}\otimes\cdots\otimes A_{m-1}^{-1}, and A−1p~A^{-1}\tilde{\mathbf p} can be computed by applying each 2×22\times2 inverse to its own bit, in O(m2m)O(m2^m) operations instead of the O(4m)O(4^m) of a dense matrix–vector product.

Proof (4 steps)
  1. Step 1:
    P(r∣t)=∏q=0m−1P(rq∣tq)=∏q=0m−1(Aq)rqtqP(r\mid t)=\prod_{q=0}^{m-1}P(r_q\mid t_q)=\prod_{q=0}^{m-1}(A_q)_{r_qt_q}
    Independence of the bit flips given the true bitstring t=t0t1⋯tm−1t=t_0t_1\cdots t_{m-1}.
  2. Step 2:
    (A0⊗A1)(2r0+r1),(2t0+t1)=(A0)r0t0(A1)r1t1(A_0\otimes A_1)_{(2r_0+r_1),(2t_0+t_1)}=(A_0)_{r_0t_0}(A_1)_{r_1t_1}
    Definition of the Kronecker product: the block (r0,t0)(r_0,t_0) of A0⊗A1A_0\otimes A_1 is (A0)r0t0A1(A_0)_{r_0t_0}A_1. Row and column indices 2r0+r12r_0+r_1 put qubit 00 in the most significant position, matching the index ∑qrq2m−1−q\sum_qr_q2^{m-1-q} of the statevector; induction on mm gives the general case.
  3. Step 3:
    (A0⊗A1)(A0−1⊗A1−1)=(A0A0−1)⊗(A1A1−1)=I⊗I=I(A_0\otimes A_1)(A_0^{-1}\otimes A_1^{-1})=(A_0A_0^{-1})\otimes(A_1A_1^{-1})=I\otimes I=I
    The mixed-product property (A⊗B)(C⊗D)=AC⊗BD(A\otimes B)(C\otimes D)=AC\otimes BD; the same holds for any number of factors.
  4. Step 4:
    A0−1⊗A1−1=(A0−1⊗I)(I⊗A1−1)A_0^{-1}\otimes A_1^{-1}=(A_0^{-1}\otimes I)(I\otimes A_1^{-1})
    Mixed-product property again: the tensored inverse factors into one 2×22\times2 operation per bit, each applied to pairs of entries whose indices differ in that bit, as in the strided single-qubit gate kernel of the simulator.

∎

A0⊗A1=(0.950.100.050.90)⊗(0.980.080.020.92)=(0.9310.0760.0980.0080.0190.8740.0020.0920.0490.0040.8820.0720.0010.0460.0180.828)A_0\otimes A_1=\begin{pmatrix}0.95&0.10\\0.05&0.90\end{pmatrix}\otimes\begin{pmatrix}0.98&0.08\\0.02&0.92\end{pmatrix}=\begin{pmatrix}0.931&0.076&0.098&0.008\\0.019&0.874&0.002&0.092\\0.049&0.004&0.882&0.072\\0.001&0.046&0.018&0.828\end{pmatrix}
A_0 ⊗ A_1 (p01 = 0.05, 0.02; p10 = 0.10, 0.08)4×4
Derivation

Mitigating one and two measured qubits

  1. Step 1:
    A=(0.950.100.050.90),det⁡A=0.85,A−1=10.85(0.90−0.10−0.050.95)A=\begin{pmatrix}0.95&0.10\\0.05&0.90\end{pmatrix},\quad\det A=0.85,\quad A^{-1}=\frac1{0.85}\begin{pmatrix}0.90&-0.10\\-0.05&0.95\end{pmatrix}
    The lab's qubit, p01=0.05p_{01}=0.05 and p10=0.10p_{10}=0.10.
  2. Step 2:
    A−1(0.780.22)=10.85(0.702−0.022−0.039+0.209)=10.85(0.680.17)=(0.80.2)A^{-1}\begin{pmatrix}0.78\\0.22\end{pmatrix}=\frac1{0.85}\begin{pmatrix}0.702-0.022\\-0.039+0.209\end{pmatrix}=\frac1{0.85}\begin{pmatrix}0.68\\0.17\end{pmatrix}=\begin{pmatrix}0.8\\0.2\end{pmatrix}
    The measured p~=(0.78,0.22)\tilde{\mathbf p}=(0.78,0.22) came from the true (0.8,0.2)(0.8,0.2): A(0.8,0.2)⊤=(0.76+0.02, 0.04+0.18)⊤A(0.8,0.2)^\top=(0.76+0.02,\,0.04+0.18)^\top.
  3. Step 3:
    (A0⊗A1)(0.5000.5)=12(0.931+0.0080.019+0.0920.049+0.0720.001+0.828)=(0.46950.05550.06050.4145)(A_0\otimes A_1)\begin{pmatrix}0.5\\0\\0\\0.5\end{pmatrix}=\frac12\begin{pmatrix}0.931+0.008\\0.019+0.092\\0.049+0.072\\0.001+0.828\end{pmatrix}=\begin{pmatrix}0.4695\\0.0555\\0.0605\\0.4145\end{pmatrix}
    A Bell state measured with p01=(0.05,0.02)p_{01}=(0.05,0.02) and p10=(0.10,0.08)p_{10}=(0.10,0.08): the first and last columns of the matrix above, averaged. About 11.6%11.6\% of the shots land on the impossible outcomes 0101 and 1010.
  4. Step 4:
    (A0−1⊗A1−1)(0.4695,0.0555,0.0605,0.4145)⊤=(0.5, 0, 0, 0.5)⊤\big(A_0^{-1}\otimes A_1^{-1}\big)\big(0.4695,0.0555,0.0605,0.4145\big)^\top=\big(0.5,\,0,\,0,\,0.5\big)^\top
    Applying the two single-qubit inverses bit by bit restores the Bell-state statistics exactly, because these measured frequencies carry no sampling noise.

Real histograms contain shot noise, and A−1A^{-1} then often returns small negative quasi-probabilities, as in the example p~=(0.97,0.03)↦(1.0235,−0.0235)\tilde{\mathbf p}=(0.97,0.03)\mapsto(1.0235,-0.0235) above. Expectation values computed linearly from a quasi-probability vector remain unbiased, but a vector with negative entries is not a distribution, cannot be sampled, and can produce expectation values outside [−1,1][-1,1]. Two repairs are common. Clip and renormalise sets negative entries to zero and rescales the rest; the engine's mitigateReadout does this. The Euclidean projection onto the probability simplex returns the closest distribution in the 22-norm. Smolin, Gambetta and Smith showed that the same projection, applied to eigenvalues, yields the maximum-likelihood density matrix under Gaussian noise.

Proposition

Euclidean projection onto the probability simplex

Let q∈Rnq\in\mathbb R^n and Δ={x∈Rn:xi≥0, ∑ixi=1}\Delta=\{x\in\mathbb R^n:x_i\ge0,\ \sum_ix_i=1\}. The unique minimiser of ∥x−q∥2\lVert x-q\rVert_2 over Δ\Delta is xi⋆=max⁡(qi−τ,0),x_i^\star=\max(q_i-\tau,0), where τ\tau is the unique number with ∑imax⁡(qi−τ,0)=1\sum_i\max(q_i-\tau,0)=1. Sorting qq decreasingly as u1≥⋯≥unu_1\ge\dots\ge u_n, τ=(∑j≤ρuj−1)/ρ\tau=\big(\sum_{j\le\rho}u_j-1\big)/\rho with ρ=max⁡{k:uk−(∑j≤kuj−1)/k>0}\rho=\max\big\{k:u_k-\big(\sum_{j\le k}u_j-1\big)/k>0\big\}.

Proof (5 steps)
  1. Step 1:
    min⁡x12∥x−q∥2 s.t. 1⊤x=1, x≥0;L=12∥x−q∥2−μ(1⊤x−1)−ν⊤x\min_x\tfrac12\lVert x-q\rVert^2\ \text{s.t.}\ \mathbf 1^\top x=1,\ x\ge0;\qquad\mathcal L=\tfrac12\lVert x-q\rVert^2-\mu\big(\mathbf 1^\top x-1\big)-\nu^\top x
    A strictly convex objective on a nonempty compact convex set has exactly one minimiser, and with affine constraints the Karush–Kuhn–Tucker conditions are necessary and sufficient.
  2. Step 2:
    xi−qi−μ−νi=0,νi≥0,νixi=0x_i-q_i-\mu-\nu_i=0,\qquad\nu_i\ge0,\qquad\nu_ix_i=0
    Stationarity in xix_i, dual feasibility and complementary slackness.
  3. Step 3:
    xi>0⇒νi=0, xi=qi+μ;xi=0⇒νi=−(qi+μ)≥0 ⇒ xi=max⁡(qi−τ,0), τ=−μx_i>0\Rightarrow\nu_i=0,\ x_i=q_i+\mu;\qquad x_i=0\Rightarrow\nu_i=-(q_i+\mu)\ge0\ \Rightarrow\ x_i=\max(q_i-\tau,0),\ \tau=-\mu
    The two cases of complementary slackness combine into one formula: a coordinate is shifted down by τ\tau and cut at zero.
  4. Step 4:
    s(τ)=∑imax⁡(qi−τ,0):s continuous, non-increasing, s(τ)→∞ (τ→−∞), s(max⁡iqi)=0s(\tau)=\sum_i\max(q_i-\tau,0):\quad s\ \text{continuous, non-increasing},\ s(\tau)\to\infty\ (\tau\to-\infty),\ s(\max_iq_i)=0
    ss is strictly decreasing wherever it is positive, so it takes the value 11 exactly once; this fixes τ\tau by primal feasibility 1⊤x=1\mathbf 1^\top x=1.
  5. Step 5:
    q=(0.6,0.45,−0.1,0.05): ρ=3, τ=0.6+0.45+0.05−13=130 ⇒ x⋆=(0.56‾, 0.416‾, 0, 0.016‾)q=(0.6,0.45,-0.1,0.05):\ \rho=3,\ \tau=\frac{0.6+0.45+0.05-1}3=\frac1{30}\ \Rightarrow\ x^\star=\big(0.5\overline6,\,0.41\overline6,\,0,\,0.01\overline6\big)
    The sorted entries 0.6,0.45,0.05,−0.10.6,0.45,0.05,-0.1 give the candidates τk=(∑j≤kuj−1)/k=−0.4, 0.025, 130, 0\tau_k=(\sum_{j\le k}u_j-1)/k=-0.4,\ 0.025,\ \tfrac1{30},\ 0, and uk>τku_k>\tau_k holds for k≤3k\le3 only. Clip-and-renormalise gives instead (0.5455,0.4091,0,0.0455)(0.5455,0.4091,0,0.0455), at Euclidean distance 0.12110.1211 from qq versus 0.11550.1155 for the projection.

∎

Quick check

A qubit has p01=0.02p_{01}=0.02 and p10=0.06p_{10}=0.06, and the measured frequencies are p~=(0.30,0.70)\tilde{\mathbf p}=(0.30,0.70). What is the mitigated probability p(0)p(0)?

tolerance ±0.001

Probabilistic error cancellation#

Zero-noise extrapolation reduces the bias but never removes it, because the extrapolation model is only approximate. Probabilistic error cancellation (PEC), proposed by Temme, Bravyi and Gambetta and developed by Endo, Benjamin and Li, is unbiased under a fully characterised noise model: it inverts the noise channel of every gate on average, by sampling from a signed mixture of operations that the device can implement.

Definition

Quasi-probability decomposition

Let G\mathcal G be an ideal operation and {Bi}\{\mathcal B_i\} a set of operations the noisy device can implement. A quasi-probability decomposition of G\mathcal G is an identity G=∑iqi Bi,qi∈R,\mathcal G=\sum_iq_i\,\mathcal B_i,\qquad q_i\in\mathbb R, between linear maps on density matrices. If all Bi\mathcal B_i and G\mathcal G are trace preserving, then ∑iqi=1\sum_iq_i=1, but individual qiq_i may be negative. The cost of the decomposition is γ=∑i∣qi∣≥1\gamma=\sum_i\lvert q_i\rvert\ge1, with γ=1\gamma=1 exactly when all qi≥0q_i\ge0, i.e. when G\mathcal G is itself a probabilistic mixture of implementable operations.

Derivation

The inverse of the depolarizing channel as a quasi-probability mixture

  1. Step 1:
    Dp(ρ)=(1−p)ρ+p3(XρX+YρY+ZρZ):Dp(I)=I,Dp(P)=fP (P∈{X,Y,Z}),f=1−4p3\mathcal D_p(\rho)=(1-p)\rho+\tfrac p3\big(X\rho X+Y\rho Y+Z\rho Z\big):\qquad\mathcal D_p(I)=I,\quad\mathcal D_p(P)=fP\ (P\in\{X,Y,Z\}),\quad f=1-\tfrac{4p}3
    The PennyLane convention of the previous lesson; on a Pauli PP, the conjugations by the two anticommuting Paulis give −P-P.
  2. Step 2:
    Dp−1(I)=I,Dp−1(P)=1fP\mathcal D_p^{-1}(I)=I,\qquad\mathcal D_p^{-1}(P)=\tfrac1fP
    Every density matrix is 12(I+rxX+ryY+rzZ)\tfrac12(I+r_xX+r_yY+r_zZ); the inverse map divides the Bloch vector by ff. It exists for f≠0f\ne0, i.e. p≠34p\ne\tfrac34, and is not completely positive for p>0p>0 because it lengthens Bloch vectors.
  3. Step 3:
    P(ρ)=PρP:P(Q)=±Q ⇒ (∑PqPP)(Q)=(∑P: [P,Q]=0qP−∑P: {P,Q}=0qP)Q\mathcal P(\rho)=P\rho P:\quad\mathcal P(Q)=\pm Q\ \Rightarrow\ \Big(\sum_{P}q_P\mathcal P\Big)(Q)=\Big(\sum_{P:\,[P,Q]=0}q_P-\sum_{P:\,\{P,Q\}=0}q_P\Big)Q
    Each Pauli channel P\mathcal P, P∈{I,X,Y,Z}P\in\{I,X,Y,Z\}, maps a Pauli QQ to +Q+Q if PP and QQ commute and to −Q-Q if they anticommute.
  4. Step 4:
    qI+qX+qY+qZ=1,qI+qX−qY−qZ=qI−qX+qY−qZ=qI−qX−qY+qZ=1fq_I+q_X+q_Y+q_Z=1,\qquad q_I+q_X-q_Y-q_Z=q_I-q_X+q_Y-q_Z=q_I-q_X-q_Y+q_Z=\tfrac1f
    Match Dp−1\mathcal D_p^{-1} on I,X,Y,ZI,X,Y,Z: the identity commutes with all four Paulis, and XX commutes with II and XX only.
  5. Step 5:
    qX=qY=qZ=1−1/f4,qI=1+3/f4q_X=q_Y=q_Z=\frac{1-1/f}4,\qquad q_I=\frac{1+3/f}4
    Subtracting the equations pairwise gives qX=qY=qZq_X=q_Y=q_Z; then qI+3qX=1q_I+3q_X=1 and qI−qX=1/fq_I-q_X=1/f, so 4qX=1−1/f4q_X=1-1/f. Since f<1f<1 for p>0p>0, the three Pauli weights are negative.
  6. Step 6:
    γ=∣qI∣+3∣qX∣=1+3/f4+3(1/f−1)4=6/f−24=3/f−12\gamma=\lvert q_I\rvert+3\lvert q_X\rvert=\frac{1+3/f}4+\frac{3(1/f-1)}4=\frac{6/f-2}4=\frac{3/f-1}2
    qI>0q_I>0 and qX<0q_X<0. At p=0.1p=0.1: f=1315f=\tfrac{13}{15}, qI=2926≈1.1154q_I=\tfrac{29}{26}\approx1.1154, qX=−126≈−0.0385q_X=-\tfrac1{26}\approx-0.0385, and γ=1613=1.2307692307692306\gamma=\tfrac{16}{13}=1.2307692307692306.

Result

Dp−1=1+3/f4 I+1−1/f4(X+Y+Z),γ=3/f−12\boxed{\mathcal D_p^{-1}=\frac{1+3/f}4\,\mathcal I+\frac{1-1/f}4\big(\mathcal X+\mathcal Y+\mathcal Z\big),\qquad\gamma=\frac{3/f-1}2}
Theorem

The PEC estimator is unbiased, with sampling overhead γ² per gate

Let G=∑iqiBi\mathcal G=\sum_iq_i\mathcal B_i with cost γ\gamma, and let OO satisfy ∥O∥≤1\lVert O\rVert\le1. Draw ii with probability ∣qi∣/γ\lvert q_i\rvert/\gamma, run the circuit with Bi\mathcal B_i in place of G\mathcal G, measure a single-shot outcome o∈[−1,1]o\in[-1,1] of OO, and output X=γ sgn(qi) oX=\gamma\,\mathrm{sgn}(q_i)\,o. Then E[X]=Tr[O G(ρ)]\mathbb E[X]=\mathrm{Tr}\big[O\,\mathcal G(\rho)\big] and Var[X]≤γ2−E[X]2\mathrm{Var}[X]\le\gamma^2-\mathbb E[X]^2. For a circuit of GG gates, each decomposed with cost γg\gamma_g, the product decomposition has cost γtot=∏gγg\gamma_{\text{tot}}=\prod_g\gamma_g, which is γG\gamma^G for equal costs, and N=O(γtot2/ε2)N=O\big(\gamma_{\text{tot}}^2/\varepsilon^2\big) samples reach precision ε\varepsilon: the overhead relative to a noiseless device is γ2G\gamma^{2G}.

Proof (5 steps)
  1. Step 1:
    E[X]=∑i∣qi∣γ γ sgn(qi) E[o∣i]=∑iqi Tr[O Bi(ρ)]=Tr[O∑iqiBi(ρ)]=Tr[O G(ρ)]\mathbb E[X]=\sum_i\frac{\lvert q_i\rvert}\gamma\,\gamma\,\mathrm{sgn}(q_i)\,\mathbb E[o\mid i]=\sum_iq_i\,\mathrm{Tr}\big[O\,\mathcal B_i(\rho)\big]=\mathrm{Tr}\Big[O\sum_iq_i\mathcal B_i(\rho)\Big]=\mathrm{Tr}\big[O\,\mathcal G(\rho)\big]
    Law of total expectation; ∣qi∣ sgn(qi)=qi\lvert q_i\rvert\,\mathrm{sgn}(q_i)=q_i; the trace is linear.
  2. Step 2:
    ∣X∣=γ∣o∣≤γ ⇒ Var[X]=E[X2]−E[X]2≤γ2−E[X]2\lvert X\rvert=\gamma\lvert o\rvert\le\gamma\ \Rightarrow\ \mathrm{Var}[X]=\mathbb E[X^2]-\mathbb E[X]^2\le\gamma^2-\mathbb E[X]^2
    The estimator is bounded by γ\gamma instead of 11: the signs make the samples cancel on average, which inflates their spread.
  3. Step 3:
    ∏g=1G(∑igqig(g)Big(g))=∑i1,…,iG(∏gqig(g))BiG(G)⋯Bi1(1)\prod_{g=1}^G\Big(\sum_{i_g}q^{(g)}_{i_g}\mathcal B^{(g)}_{i_g}\Big)=\sum_{i_1,\dots,i_G}\Big(\prod_gq^{(g)}_{i_g}\Big)\mathcal B^{(G)}_{i_G}\cdots\mathcal B^{(1)}_{i_1}
    Composition of linear maps distributes over sums: the circuit is a quasi-probability mixture of circuit variants with weights ∏gqig(g)\prod_gq^{(g)}_{i_g}.
  4. Step 4:
    γtot=∑i1,…,iG∏g∣qig(g)∣=∏g=1G∑ig∣qig(g)∣=∏gγg\gamma_{\text{tot}}=\sum_{i_1,\dots,i_G}\prod_g\big\lvert q^{(g)}_{i_g}\big\rvert=\prod_{g=1}^G\sum_{i_g}\big\lvert q^{(g)}_{i_g}\big\rvert=\prod_g\gamma_g
    The sum of a product over independent indices factorises. Sampling each gate's variant independently samples the product decomposition.
  5. Step 5:
    P(∣XˉN−E[X]∣≥ε)≤2exp⁡(−Nε22γtot2) ⇒ N≥2γtot2ε2ln⁡2δP\Big(\big\lvert\bar X_N-\mathbb E[X]\big\rvert\ge\varepsilon\Big)\le2\exp\Big(-\frac{N\varepsilon^2}{2\gamma_{\text{tot}}^2}\Big)\ \Rightarrow\ N\ge\frac{2\gamma_{\text{tot}}^2}{\varepsilon^2}\ln\frac2\delta
    Hoeffding's inequality for NN independent samples in [−γtot,γtot][-\gamma_{\text{tot}},\gamma_{\text{tot}}]; without mitigation the range is [−1,1][-1,1], so the number of shots grows by the factor γtot2=γ2G\gamma_{\text{tot}}^2=\gamma^{2G}.

∎

To cancel the depolarizing noise Dp\mathcal D_p that follows a gate G\mathcal G, one implements G=Dp−1(DpG)\mathcal G=\mathcal D_p^{-1}(\mathcal D_p\mathcal G): run the noisy gate and then, with probability ∣qP∣/γ\lvert q_P\rvert/\gamma, an extra Pauli PP, recording the sign of qPq_P. The derivation assumes that the inserted Pauli is itself noiseless; in practice it is merged into the next layer of single-qubit gates. At p=0.1p=0.1 the overhead per gate is γ2=(1613)2≈1.515\gamma^2=\big(\tfrac{16}{13}\big)^2\approx1.515. At the more realistic p=0.01p=0.01, f=7475f=\tfrac{74}{75} and the cost is γ=12(22574−1)=151148≈1.0203\gamma=\tfrac12\big(\tfrac{225}{74}-1\big)=\tfrac{151}{148}\approx1.0203 per gate, so 100100 noisy gates multiply the required number of shots by γ200≈55.3\gamma^{200}\approx55.3, and 10001000 gates by about 2.7×10172.7\times10^{17}. PEC is therefore exact but exponentially expensive in the circuit volume, while ZNE has a polynomial cost and a residual bias.

Quick check

What is the PEC cost γ=∑∣q∣\gamma=\sum\lvert q\rvert of inverting a single-qubit depolarizing channel with p=0.03p=0.03?

tolerance ±0.0001

Numerical checks and the labs#

The NumPy cell below re-derives the lesson's numbers independently of the platform's engine: the Richardson weights from the Lagrange formula and from a Vandermonde solve, their moments ∑iγiλik=1,0,0,15,135\sum_i\gamma_i\lambda_i^k=1,0,0,15,135, the variance factors 5.218755.21875 and 12.2512.25, the lab extrapolations, the exact Bell-circuit decay f2λf^{2\lambda} with its Richardson bias, the single-qubit and tensored readout inversions, both repairs of a quasi-probability vector, and the quasi-probability decomposition of the inverse depolarizing channel, checked on a random density matrix.

Pythonrunnable
import numpy as np

def fmt(v, d=10):
    v = np.atleast_1d(np.asarray(v, dtype=float))
    v = np.where(np.abs(v) < 5e-11, 0.0, v)
    return "(" + ", ".join(f"{x:.{d}f}" for x in v) + ")"

# (1) Richardson weights: Lagrange basis polynomials at lambda = 0, and the same weights from a Vandermonde solve
def richardson_weights(nodes):
    nodes = np.asarray(nodes, dtype=float)
    m = len(nodes)
    return np.array([np.prod([nodes[j] / (nodes[j] - nodes[i]) for j in range(m) if j != i]) for i in range(m)])

nodes = np.array([1.0, 3.0, 5.0])
g = richardson_weights(nodes)
V = np.vander(nodes, increasing=True).T          # row k holds lambda_i^k, k = 0, 1, 2
print("gamma =", fmt(g), "| Vandermonde solve =", fmt(np.linalg.solve(V, [1.0, 0.0, 0.0])))
print("moments sum gamma_i lambda_i^k, k = 0..4:", fmt([g @ nodes**k for k in range(5)], 6))
print("sum gamma^2 =", f"{g @ g:.5f}", "| std factor sqrt =", f"{np.sqrt(g @ g):.4f}", "| (sum |gamma|)^2 =", f"{np.abs(g).sum()**2:.4f}")

# the lab data
E = np.array([0.80, 0.56, 0.40])
slope, intercept = np.polyfit(nodes, E, 1)
print("Richardson E0 =", f"{g @ E:.10f}", "| quadratic through the data:", fmt(np.polyfit(nodes, E, 2)[::-1], 6))
print("linear {1,3} =", f"{richardson_weights([1, 3]) @ E[:2]:.10f}", "| linear {1,5} =", f"{richardson_weights([1, 5]) @ E[[0, 2]]:.10f}",
      "| least-squares intercept =", f"{intercept:.10f}")

# exponential decay E = exp(-kappa lambda) from the folded Bell circuit with p = 0.01: E(lambda) = f^(2 lambda)
f = 1 - 4 * 0.01 / 3
Eb = f ** (2 * nodes)
print("Bell <ZZ> at 1,3,5:", fmt(Eb), "| Richardson:", f"{g @ Eb:.10f}", "| error:", f"{g @ Eb - 1:.4e}")

# (4) readout: A = [[1 - p01, p10], [p01, 1 - p10]], column = true bit
def confusion(p01, p10):
    return np.array([[1 - p01, p10], [p01, 1 - p10]])

A = confusion(0.05, 0.10)
Ainv_formula = np.array([[0.90, -0.10], [-0.05, 0.95]]) / (1 - 0.05 - 0.10)
print("det A =", f"{np.linalg.det(A):.10f}", "| formula inverse matches:", np.allclose(Ainv_formula, np.linalg.inv(A), atol=1e-14, rtol=0))
print("A^-1 (0.78, 0.22) =", fmt(Ainv_formula @ [0.78, 0.22]), "| A (0.8, 0.2) =", fmt(A @ [0.8, 0.2]))

# two qubits, qubit 0 = most significant bit: A = A_0 kron A_1 and (A_0 kron A_1)^-1 = A_0^-1 kron A_1^-1
A0, A1 = confusion(0.05, 0.10), confusion(0.02, 0.08)
A01 = np.kron(A0, A1)
print("kron inverse rule:", np.allclose(np.linalg.inv(A01), np.kron(np.linalg.inv(A0), np.linalg.inv(A1)), atol=1e-14, rtol=0),
      "| columns sum to 1:", np.allclose(A01.sum(axis=0), 1, atol=1e-15, rtol=0))
measured = np.array([0.4695, 0.0555, 0.0605, 0.4145])
print("A (0.5, 0, 0, 0.5) =", fmt(A01 @ [0.5, 0, 0, 0.5], 4), "| mitigated:", fmt(np.linalg.solve(A01, measured)))

# repairing negative quasi-probabilities
def clip_renormalise(q):
    c = np.clip(q, 0, None)
    return c / c.sum()

def project_simplex(q):
    u = np.sort(q)[::-1]
    css = np.cumsum(u)
    k = np.arange(1, len(q) + 1)
    rho = k[u - (css - 1) / k > 0][-1]
    tau = (css[rho - 1] - 1) / rho
    return np.maximum(q - tau, 0)

q = Ainv_formula @ [0.97, 0.03]
print("A^-1 (0.97, 0.03) =", fmt(q), "-> clip:", fmt(clip_renormalise(q)), "| simplex:", fmt(project_simplex(q)))
q4 = np.array([0.60, 0.45, -0.10, 0.05])
c4, s4 = clip_renormalise(q4), project_simplex(q4)
print("q =", fmt(q4, 2), "-> clip:", fmt(c4, 6), "dist", f"{np.linalg.norm(c4 - q4):.6f}", "| simplex:", fmt(s4, 6), "dist", f"{np.linalg.norm(s4 - q4):.6f}")

# (5) probabilistic error cancellation for the depolarizing channel E(rho) = (1-p) rho + p/3 (X rho X + Y rho Y + Z rho Z)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]])
Z = np.diag([1.0 + 0j, -1.0])

def depolarize(rho, p):
    return (1 - p) * rho + p / 3 * (X @ rho @ X + Y @ rho @ Y + Z @ rho @ Z)

p = 0.1
fp = 1 - 4 * p / 3
qI, qP = (1 + 3 / fp) / 4, (1 - 1 / fp) / 4
rng = np.random.default_rng(7)
M = rng.normal(size=(2, 2)) + 1j * rng.normal(size=(2, 2))
rho = M @ M.conj().T
rho /= np.trace(rho)
noisy = depolarize(rho, p)
undone = qI * noisy + qP * (X @ noisy @ X + Y @ noisy @ Y + Z @ noisy @ Z)
print("q_I =", f"{qI:.10f}", "| q_X = q_Y = q_Z =", f"{qP:.10f}", "| sum q =", f"{qI + 3 * qP:.10f}")
print("sum_P q_P P E(rho) P = rho:", np.allclose(undone, rho, atol=1e-14, rtol=0),
      "| gamma = sum |q| =", f"{abs(qI) + 3 * abs(qP):.10f}", "= (3/f - 1)/2 =", f"{(3 / fp - 1) / 2:.10f}")
gam = lambda pp: (3 / (1 - 4 * pp / 3) - 1) / 2
print("sampling overhead gamma^(2G): p = 0.1, G = 1:", f"{gam(0.1) ** 2:.4f}", "| p = 0.01, G = 100:", f"{gam(0.01) ** 200:.2f}")

Expected output

gamma = (1.8750000000, -1.2500000000, 0.3750000000) | Vandermonde solve = (1.8750000000, -1.2500000000, 0.3750000000)
moments sum gamma_i lambda_i^k, k = 0..4: (1.000000, 0.000000, 0.000000, 15.000000, 135.000000)
sum gamma^2 = 5.21875 | std factor sqrt = 2.2845 | (sum |gamma|)^2 = 12.2500
Richardson E0 = 0.9500000000 | quadratic through the data: (0.950000, -0.160000, 0.010000)
linear {1,3} = 0.9200000000 | linear {1,5} = 0.9000000000 | least-squares intercept = 0.8866666667
Bell <ZZ> at 1,3,5: (0.9735111111, 0.9226197308, 0.8743887542) | Richardson: 0.9999544527 | error: -4.5547e-05
det A = 0.8500000000 | formula inverse matches: True
A^-1 (0.78, 0.22) = (0.8000000000, 0.2000000000) | A (0.8, 0.2) = (0.7800000000, 0.2200000000)
kron inverse rule: True | columns sum to 1: True
A (0.5, 0, 0, 0.5) = (0.4695, 0.0555, 0.0605, 0.4145) | mitigated: (0.5000000000, 0.0000000000, 0.0000000000, 0.5000000000)
A^-1 (0.97, 0.03) = (1.0235294118, -0.0235294118) -> clip: (1.0000000000, 0.0000000000) | simplex: (1.0000000000, 0.0000000000)
q = (0.60, 0.45, -0.10, 0.05) -> clip: (0.545455, 0.409091, 0.000000, 0.045455) dist 0.121117 | simplex: (0.566667, 0.416667, 0.000000, 0.016667) dist 0.115470
q_I = 1.1153846154 | q_X = q_Y = q_Z = -0.0384615385 | sum q = 1.0000000000
sum_P q_P P E(rho) P = rho: True | gamma = sum |q| = 1.2307692308 = (3/f - 1)/2 = 1.2307692308
sampling overhead gamma^(2G): p = 0.1, G = 1: 1.5148 | p = 0.01, G = 100: 55.34

The first lab gives three noise-scaled measurements and asks for the Richardson estimate through all three nodes; the second gives readout error rates and a measured distribution and asks for the mitigated distribution.

References

  1. K. Temme, S. Bravyi and J. M. Gambetta, Error mitigation for short-depth quantum circuits, Physical Review Letters 119, 180509 (2017).doi:10.1103/PhysRevLett.119.180509
  2. A. Kandala, K. Temme, A. D. Córcoles, A. Mezzacapo, J. M. Chow and J. M. Gambetta, Error mitigation extends the computational reach of a noisy quantum processor, Nature 567, 491–495 (2019).doi:10.1038/s41586-019-1040-7
  3. T. Giurgica-Tiron, Y. Hindy, R. LaRose, A. Mari and W. J. Zeng, Digital zero noise extrapolation for quantum error mitigation, 2020 IEEE International Conference on Quantum Computing and Engineering (QCE), 306–316 (2020); arXiv:2005.10921.doi:10.1109/QCE49297.2020.00045
  4. S. Endo, S. C. Benjamin and Y. Li, Practical quantum error mitigation for near-future applications, Physical Review X 8, 031027 (2018).doi:10.1103/PhysRevX.8.031027
  5. S. Bravyi, S. Sheldon, A. Kandala, D. C. Mckay and J. M. Gambetta, Mitigating measurement errors in multiqubit experiments, Physical Review A 103, 042605 (2021).doi:10.1103/PhysRevA.103.042605
  6. J. A. Smolin, J. M. Gambetta and G. Smith, Efficient method for computing the maximum-likelihood quantum state from measurements with additive Gaussian noise, Physical Review Letters 108, 070502 (2012).doi:10.1103/PhysRevLett.108.070502
  7. W. Wang and M. Á. Carreira-Perpiñán, Projection onto the probability simplex: an efficient algorithm with a simple proof, and an application, arXiv:1309.1541 (2013).arxiv.org
  8. E. van den Berg, Z. K. Minev, A. Kandala and K. Temme, Probabilistic error cancellation with sparse Pauli–Lindblad models on noisy quantum processors, Nature Physics 19, 1116–1121 (2023).doi:10.1038/s41567-023-02042-2

Hands-on labs

  • Zero-noise extrapolation with Richardson weights

    1 step · auto-graded

    An expectation value was measured at the noise scale factors λ=1,3,5\lambda=1,3,5 produced by global unitary folding. Combine the three measurements with the Richardson (Lagrange) weights into an estimate of the noiseless value E0E_0.

    Open lab
  • Readout-error mitigation by confusion-matrix inversion

    1 step · auto-graded

    A qubit's readout flips 0→10\to1 with probability p01=0.05p_{01}=0.05 and 1→01\to0 with probability p10=0.10p_{10}=0.10. Undo this classical noise on a measured distribution by inverting the 2×22\times2 confusion matrix.

    Open lab