mimiqcircuits.backends.fidelity¶
Typed fidelity values returned by Backend.evolve().
Different simulators report fidelity with different semantics: a state-vector backend can claim exactness, an MPS backend can only return a truncation lower bound, and a randomised-benchmarking backend can return a sample-based estimate with a standard error.
A plain float return would silently lose those distinctions.
The tagged variants below preserve them:
Reduce to plain numbers via as_lower_bound() (conservative),
as_expected() (central), or as_interval() ((lo, hi)).
Functions
|
Reduce |
|
|
Reduce |
Classes
|
Sample-based fidelity estimate with a standard error. |
The simulator believes the state is exact. |
|
|
Base class for typed fidelity values. |
|
Per-step lower-bound contributions. |
|
A single scalar lower bound on the whole-circuit fidelity. |
The backend does not track fidelity. |
- class mimiqcircuits.backends.fidelity.Fidelity[source]¶
Bases:
objectBase class for typed fidelity values. See the module docstring for the list of variants and the reducer functions.
- class mimiqcircuits.backends.fidelity.ExactFidelity[source]¶
Bases:
FidelityThe simulator believes the state is exact.
BLAS and SIMD round-off are not tracked; this is a structural claim about the algorithm, not a bit-perfect guarantee.
- __init__()¶
- class mimiqcircuits.backends.fidelity.UnknownFidelity[source]¶
Bases:
FidelityThe backend does not track fidelity.
Reducers return
nan. Prefer this variant over inventing a placeholder value when you genuinely do not know.- __init__()¶
- class mimiqcircuits.backends.fidelity.TruncationLowerBound(value)[source]¶
Bases:
FidelityA single scalar lower bound on the whole-circuit fidelity.
Typical for MPS / MPO simulators, where
valueis the product of singular-value tails discarded during compression.- __init__(value)¶
- class mimiqcircuits.backends.fidelity.LowerBoundPerStep(values)[source]¶
Bases:
FidelityPer-step lower-bound contributions.
as_lower_boundreturnsprod(clip(values, 0, 1)), which is a lower bound on the circuit fidelity only when successive truncation errors are uncorrelated. If your backend cannot make that assumption, collapse to a singleTruncationLowerBoundat construction time.- __init__(values)¶
- class mimiqcircuits.backends.fidelity.EstimatedFidelity(mean, stderr)[source]¶
Bases:
FidelitySample-based fidelity estimate with a standard error.
Use for randomised benchmarking, direct fidelity estimation, or cross-entropy benchmarking.
as_lower_boundreturnsmax(0, mean − 3·stderr);as_intervalreturns the ±1σ band.- __init__(mean, stderr)¶
- mimiqcircuits.backends.fidelity.as_lower_bound(f)[source]¶
Reduce
fto a conservative scalar lower bound.Returns
nanwhenfisUnknownFidelityso that statistics over mixed-type fidelities do not silently treat “unknown” as “good”.
- mimiqcircuits.backends.fidelity.as_expected(f)[source]¶
Reduce
fto a central / expected scalar.For
TruncationLowerBoundthe lower bound is the estimate; forEstimatedFidelityit is the sample mean. ReturnsnanforUnknownFidelity.
- mimiqcircuits.backends.fidelity.as_interval(f)[source]¶
(lo, hi)band. ±1σ forEstimatedFidelity; otherwise(as_lower_bound, as_expected).