loqs.tools.noisesweeptools¶
Generic, codepack-agnostic continuous noise-strength sweep tooling.
Unlike loqs.tools.fttools, which answers "is this circuit FT against every possible discrete
single/weight-2 Pauli fault," this module answers "how does the logical failure rate scale with a
continuous physical error rate." Both share the same underlying philosophy of owning only the
generic bookkeeping (sweep loop, RNG seeding, shot-running, result extraction) while leaving the
noise model and instruction stack entirely up to the caller.
Classes¶
Functions¶
compare_noise_sweeps ¶
compare_noise_sweeps(results: Mapping[str, NoiseSweepResult], strict: bool = False) -> Mapping[str, NoiseSweepResult]
Validate a set of named NoiseSweepResults for joint analysis/plotting, then return them
unchanged. This does not run anything itself -- callers run each named series via
NoiseSweepRunner.run first.
Always raises ValueError if the named results don't all share the same strengths and
num_shots (mismatched series can never be fairly compared; strict doesn't affect this).
Separately, checks each result's is_complete (a result can be legitimately partial/in-progress
from an interrupted sweep resumed by constructing a new runner with the same item_checkpoint_dir):
if strict is False (default), an incomplete result only emits a UserWarning naming which
series are incomplete and how many of their points are missing, and is still returned like any
other; if strict is True, the same condition raises ValueError instead.
plot_noise_sweep ¶
plot_noise_sweep(results: NoiseSweepResult | Mapping[str, NoiseSweepResult], ax: Axes | None = None, reference_slope: float | None = None, **kwargs) -> matplotlib.axes.Axes
Log-log plot of failure rate vs. noise strength, one series per NoiseSweepResult, reading
directly from its stored failure_rates/stderrs. Points with zero observed failures are
drawn as open markers at the 1 / (2 * num_shots) statistical upper limit (since a failure
rate of exactly zero can't be shown on a log scale).
reference_slope, if given (e.g. 2 for an ideal p^2 guide line at distance d=3), draws a
dashed guide line of that slope through the first available non-zero data point across all
series, for visual comparison.
Requires matplotlib (pip install loqs[visualization]); the import happens inside this
function body, not at module level, so the rest of this module (and all of fttools.py) has
no hard plotting dependency.