Skip to main content
KetQat

Appearance

Surface-code threshold study (Stim + PyMatching)

Distance x error-rate sweep with Stim + PyMatching: Wilson points, suppression factors, bootstrapped threshold crossing, report.

Officially provided by KetQat — method by Dennis et al. (2002), Fowler et al. (2012) and others. KetQat prepares, verifies and maintains this product; it does not claim to have invented the method. Read the origin statement.

What it does and who it is for

Runs a rotated surface-code memory experiment over a grid of code distances and physical error rates, sampling with Stim and decoding with PyMatching exactly as the free surface-code-memory product does (same circuits, same seed derivation), and turns the grid into a threshold study. Every point carries its logical error rate with a 95% Wilson interval. Between successive distances it reports the suppression factor Lambda = p_L(d) / p_L(d+2) with a delta-method interval. The threshold is estimated from the crossing of neighbouring-distance curves, interpolated in log-log space, with a parametric bootstrap over the per-point failure counts giving a confidence interval and the spread between distance pairs showing finite-size drift. A finite-size scaling collapse (log p_L = A + B x + C x^2, x = (p - p_th) d^(1/nu)) gives a second threshold estimate with a reduced chi-square as the collapse quality. Everything is written to one JSON result and a Markdown report.

For QEC students and researchers who want a reproducible threshold sweep with honest uncertainties rather than a single number, without assembling the sweep, the statistics and the report themselves.

This is a KetQat Pro product: it runs locally like every catalog product, from a signed bundle installed with ketqat pro install under a time-limited entitlement. Its implementation is not part of the open SDK.

Use cases

  • Estimate the MWPM threshold of the rotated surface code under depolarizing circuit noise, with a bootstrap interval
  • Quantify the suppression factor between distances at a fixed physical error rate, with an interval
  • Check whether a sweep collapses onto one finite-size scaling curve before quoting a threshold

Use it on your computer

This page never runs anything. Copy the commands into your own terminal; the product runs locally.
  1. Install and get the Pro bundle

    Installs the KetQat SDK from commit 2cedabbd814f, the exact version whose product definition this page shows. The SDK is not on PyPI yet, so pip install ketqat alone will not work.

    Terminal
    pip install "ketqat[pro,qec] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python" && ketqat pro login && ketqat pro install [email protected]
  2. Run the example

    Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].

    Python
    import json
    from ketqat_runner import catalog
    
    record = catalog.run("[email protected]", seed=1, distances=[3, 5],
                         physical_error_rates=[0.004, 0.008, 0.016, 0.03], shots_per_point=3000)
    result = record.result
    estimate = result["threshold_estimate"]
    print(json.dumps({
        "status": record.status,
        "distances": result["distances"],
        "points": len(result["points"]),
        "threshold_found": not estimate["inconclusive"],
        "interval_brackets_estimate": estimate["bootstrap"]["lower"] <= estimate["value"] <= estimate["bootstrap"]["upper"],
    }))
    
    Expected output (fields the example must print)
    {
      "points": 8,
      "status": "succeeded",
      "distances": [
        3,
        5
      ],
      "threshold_found": true,
      "interval_brackets_estimate": true
    }

    Verified with

    No verification run of this example is recorded in its definition. Pro examples need an entitlement, which the public SDK CI does not have.

  3. Optional: tell us it ran

    ketqat report RUN_ID sends an opt-in usage report: product, version, succeeded/failed, time and SDK version only. It shows you the exact payload first and needs an API token from Settings. Nothing is sent unless you run it.

This is a Pro product

What Pro adds over Free

The open SDK already samples and decodes a rotated surface-code memory at one distance and rate with a Wilson interval (the free surface-code-memory product), computes a suppression factor between two rates (qec_statistics.suppression_factor) and, for manifest sweeps, estimates a threshold as the median of pairwise curve crossings with the spread between pairs as its only uncertainty (threshold.py). Nothing of that moves behind Pro. Pro adds the study as one catalog run: the whole distance x rate sweep with the same open sampler, suppression factors with intervals at every rate, a neighbouring-pair crossing estimator in log-log space with a parametric bootstrap interval over per-point failure counts, a finite-size scaling collapse with its quality number, and a Markdown report.

Steps after you subscribe

  1. Terminal
    ketqat pro login
  2. Terminal
    ketqat pro install [email protected]
  3. Terminal
    ketqat catalog run [email protected]

ketqat pro login stores a signed entitlement valid for up to 7 days; runs start offline while it is valid. Cancelling stops new Pro runs and updates after it expires. Your results are never deleted, and Free products are unaffected. This is not DRM.

See Pro and subscribe

Inputs and outputs

Inputs

Inputs of Surface-code threshold study (Stim + PyMatching)
NameTypeDefaultAllowed valuesDescription
distancesinteger[][3,5,7]maxItems: 5; minItems: 2; itemMaximum: 15; itemMinimum: 3; uniqueItems: trueCode distances (odd, at least two).
physical_error_ratesnumber[][0.003,0.005,0.007,0.009,0.011,0.013]maxItems: 12; minItems: 2; itemMaximum: 0.5; itemMinimum: 0; uniqueItems: trueDepolarizing probabilities p applied after every Clifford gate; the grid should bracket the crossing.
shots_per_pointinteger5000maximum: 1000000; minimum: 1Sampled experiments at every (distance, rate) point.
roundsintegernullmaximum: 50; minimum: 1Syndrome-extraction rounds for every distance. null uses d rounds at distance d.
decoderstringmwpmenum: mwpmDecoder. Version 1.0.0 offers minimum-weight perfect matching (PyMatching) only.

Outputs

Outputs of Surface-code threshold study (Stim + PyMatching)
NameTypeDescription
pointsobject[]One entry per (distance, physical_error_rate): rounds, shots, logical_failures, logical_error_rate, 95% Wilson confidence_interval, is_upper_bound_only, coordinate_seed.
suppression_factorsobject[]Lambda = p_L(d) / p_L(d') between successive distances at every rate, with a delta-method 95% interval; null when the higher distance saw no failure.
threshold_estimateobjectvalue (mean of neighbouring-pair crossings) with a parametric bootstrap interval, every pair's crossing and interval, the pair spread, the method, or inconclusive with a reason.
finite_size_collapseobjectBest (p_th, nu) of the scaling ansatz with the reduced chi-square as collapse quality, or available: false with a reason.
decoder_versionstringInstalled PyMatching version that produced the result.
reportstringMarkdown report with the point table, suppression table, threshold estimate, collapse and caveats.

Sample result

Not generated in the open SDK: running this product needs a Pro entitlement and bundle, which this repository's CI does not have. Maintainer run of the private bundle with the defaults (d = 3, 5, 7; p = 0.003 to 0.013; 5000 shots per point; seed 2026; Stim 1.16.0, PyMatching 2.4.0): threshold estimate p_th = 0.00815 with 95% bootstrap interval [0.00677, 0.00882]; neighbouring-pair crossings 0.00658 (d 3 vs 5) and 0.00972 (d 5 vs 7), pair spread 0.0031; suppression factor at p = 0.005 of 2.05 [1.19, 3.55] for d 3 -> 5 and 1.90 [0.88, 4.08] for d 5 -> 7; finite-size collapse at p_th = 0.00775, nu = 1.0 with reduced chi-square 1.43 over 18 points.

Assumptions, scope and limitations

Assumptions

  • Circuit-level noise: single- and two-qubit depolarizing noise with probability p after every Clifford gate (Stim's after_clifford_depolarization). Measurement, reset and idle errors are not added.
  • Stabilizer simulation: only Pauli noise is representable.
  • The decoder sees the detector error model of the same circuit that generated the samples (matched noise model).
  • The crossing estimator interpolates each distance's curve linearly in (log p, log p_L) between sampled rates; the bootstrap redraws every failure count from Binomial(shots, observed rate).

Scope

  • Rotated surface code, memory in the Z basis, odd distances 3 to 15, 1 to 50 rounds (default d rounds).
  • Logical error rate per point with a 95% Wilson interval; suppression factors between successive distances; threshold from neighbouring-pair crossings with a bootstrap interval; finite-size collapse quality.

Limitations

  • One noise model only; a threshold here is not a hardware prediction.
  • Rates are per memory experiment of the given rounds, not per round; with rounds = d the per-experiment rate of a larger distance includes more rounds.
  • The bootstrap interval carries shot noise only. Finite-size effects are visible as the spread between distance pairs and are not folded into the interval; three distances constrain the scaling exponent nu weakly.
  • Points with fewer than 5 failures at either distance are excluded from the crossing search; points with none are excluded from the collapse fit and reported as upper bounds.
  • Exact counts are reproducible for the same seed with the same Stim and PyMatching versions; other versions may sample or decode differently.
  • The implementation is delivered as a Pro bundle and is not open source; its validation tests live in the private repository, not here.
  • Tested on macOS and Linux only; Windows is untested.

Environment and resources

Runs
Locally, on your computer
Type
Simulation
Python
>=3.10
Operating systems
Linux, macOS
Resources
Defaults (d = 3, 5, 7; six rates; 5000 shots per point; 200 bootstrap resamples): about 3 s on a 2024 Apple-silicon laptop (maintainer measurement). Time grows roughly as d^3 x shots per point; one point needing more than 2 GiB of detector samples, or a sweep needing more than 4 GiB in total, is refused before anything runs.
SDK extras
pro, qec
Minimum SDK
0.3.0

Validation

Implemented: works with validation tests, but not every verification condition is met yet.

No validation tests are recorded for this product

Read the limitations above before relying on its results.

Versions and changelog

  1. 1.0.01 Nov 2026currentShown on this page

    • First catalog release.

    Needs SDK 0.3.0 or later with extras: pro, qec.

All product changelogs

Origin, license and credits

KetQat integration of open-source software

The surface code memory, its threshold and its decoding by matching follow Dennis, Kitaev, Landahl and Preskill (2002) and Fowler et al. (2012); the finite-size scaling ansatz follows Wang, Harrington and Preskill (2003). Circuits are generated and sampled by Stim (Craig Gidney) and decoded by PyMatching (Oscar Higgott and Craig Gidney), both used unmodified through the open SDK's sampler, and the statistics use NumPy. KetQat wrote the study workflow: the sweep orchestration, the suppression and crossing estimators with their bootstrap, the collapse fit, the report and this catalog entry. KetQat did not invent the code, the noise model, the decoder or the threshold method.

Upstream software

License of what you receive

LicenseRef-KetQat-Pro — the KetQat Pro license. See Licensing.

Contributors

People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.

  • dorakingx · KetQat maintainer: implementation, validation and catalog entry

How to contribute

References

  1. Eric Dennis, Alexei Kitaev, Andrew Landahl, John Preskill (2002). Topological quantum memory. Journal of Mathematical Physics 43, 4452.DOI 10.1063/1.1499754arXiv:quant-ph/0110143
  2. Austin G. Fowler, Matteo Mariantoni, John M. Martinis, Andrew N. Cleland (2012). Surface codes: Towards practical large-scale quantum computation. Physical Review A 86, 032324.DOI 10.1103/PhysRevA.86.032324
  3. Chenyang Wang, Jim Harrington, John Preskill (2003). Confinement-Higgs transition in a disordered gauge theory and the accuracy threshold for quantum memory. Annals of Physics 303, 31-58.arXiv:quant-ph/0207088
  4. Craig Gidney (2021). Stim: a fast stabilizer circuit simulator. Quantum 5, 497.DOI 10.22331/q-2021-07-06-497
  5. Oscar Higgott (2022). PyMatching: A Python package for decoding quantum codes with minimum-weight perfect matching. ACM Transactions on Quantum Computing.arXiv:2105.13082
  6. Oscar Higgott, Craig Gidney (2023). Sparse Blossom: correcting a million errors per core second with minimum-weight matching. arXiv preprint.arXiv:2303.15933
  7. Edwin B. Wilson (1927). Binomial confidence intervals: Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association 22, 209-212.
  8. Bradley Efron (1979). Bootstrap methods: Another look at the jackknife. The Annals of Statistics 7, 1-26.

Usage

No usage reports yet

Distinct signed-in accounts that chose to send at least one usage report (ketqat report) for this product in the last 90 days. KetQat staff, test and bot accounts are excluded. Reports are opt-in, so this is not a count of all users.

Computed 10 Nov 2026, 17:34 UTC.

Reviews

Not yet rated

Be the first to rate this product after you run it.

Mean of visible reviews. Hidden reviews and reviews by KetQat staff, test and bot accounts are excluded. Pro status gives no extra weight.

Sign in to review this product. One review per person; you can edit it later.

No reviews yet.