uniqc.calibration.xeb.fitter module

Exponential decay fitter for cross-entropy benchmarking results.

Fits the model F(m) = A * r^m + B to a sequence of circuit fidelities measured at different depths m, where r is the per-layer fidelity.

uniqc.calibration.xeb.fitter.compute_hellinger_fidelity(p_theory, p_noisy)[source]

Compute the Hellinger fidelity between two probability distributions.

F = (sum_i sqrt(p_i * q_i))^2

This is the Sørensen-Dice coefficient applied to probability vectors. It equals 1 when the distributions are identical and approaches 0 for orthogonal distributions.

Parameters:
  • p_theory (ndarray) – Ideal (noiseless) probability vector.

  • p_noisy (ndarray) – Noisy (measured) probability vector.

Returns:

A float in [0, 1]. Higher is more similar.

Return type:

float

uniqc.calibration.xeb.fitter.compute_linear_xeb(p_ideal, p_observed, *, normalized=True, eps=1e-12)[source]

Compute the standard linear XEB estimator.

Unnormalized linear XEB is N * sum_x p_observed(x) p_ideal(x) - 1. For small-qubit calibration circuits, the Porter-Thomas assumption is often weak, so the default uses the normalized estimator:

(dot(p_observed, p_ideal) - 1/N) / (dot(p_ideal, p_ideal) - 1/N).

The normalized form has baseline 0 for uniform/random output and 1 for exactly ideal output. If the ideal distribution is uniform, the normalized estimator is undefined and nan is returned.

Parameters:
Return type:

float

uniqc.calibration.xeb.fitter.fit_exponential(depths, fidelities, *, shots=None, baseline=0.0)[source]

Fit the exponential decay model F(m) = A * r^m + B.

The model describes how the fidelity decays with circuit depth m. The parameter r (0 < r <= 1) is the per-layer fidelity. F = 1 at m=0 (perfect fidelity) and decays exponentially.

Parameters:
  • depths (list[int]) – List of circuit depths (m values).

  • fidelities (list[float]) – List of XEB values measured at each depth. Average over multiple circuits at the same depth before passing.

  • shots (int | None)

  • baseline (float | None)

Returns:

  • r: per-layer fidelity (0 < r <= 1)

  • A: amplitude coefficient

  • B: asymptotic offset

  • r_stderr: standard error on r

  • n_points: number of (depth, fidelity) data points used

Return type:

dict with keys