Skip to main content
KetQat

Appearance

Surface-code memory experiment (Stim + PyMatching)

Estimate the logical error rate of a rotated surface-code memory with Stim sampling, PyMatching decoding and a Wilson interval.

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 locally. Stim generates the noisy syndrome-extraction circuit for the chosen distance, number of rounds and memory basis, samples detector outcomes, and PyMatching decodes them with minimum-weight perfect matching. The product reports logical failures, the logical error rate and its 95% Wilson score interval; zero observed failures is reported as an upper bound, never as a rate of zero.

For QEC students and researchers who want a correct, seeded baseline for a surface-code memory without assembling Stim and PyMatching themselves. The sampling seed is derived exactly as in the SDK's existing surface-code-memory-mwpm benchmark, so the same inputs reproduce the same samples.

Use cases

  • Measure the logical error rate at one distance and physical error rate, with a confidence interval
  • Compare distances below threshold to see the logical error rate fall
  • Produce a reproducible MWPM baseline to compare a new decoder against on identical settings

Use it on your computer

This page never runs anything. Copy the commands into your own terminal; the product runs locally with no account and no telemetry.
  1. Install

    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[qec] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"
  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=2026, distance=3, physical_error_rate=0.005, shots=2000)
    result = record.result
    interval = result["confidence_interval"]
    print(json.dumps({
        "status": record.status,
        "distance": result["distance"],
        "rounds": result["rounds"],
        "decoder": result["decoder"],
        "observed_failures": result["logical_failures"] > 0,
        "interval_brackets_rate": interval["lower"] <= result["logical_error_rate"] <= interval["upper"],
    }))
    
    Expected output (fields the example must print)
    {
      "rounds": 3,
      "status": "succeeded",
      "decoder": "pymatching",
      "distance": 3,
      "observed_failures": true,
      "interval_brackets_rate": true
    }

    Verified with

    SDK
    0.3.0
    Python
    3.12.12
    Platform
    macOS-27.0.1-arm64 Python 3.12.12 (maintainer run) and Ubuntu 26.04 x86_64 Python 3.12.15 (GitHub Actions python-package.yml catalog job, run 40815046070: example executed verbatim in a clean virtualenv)
    Date
    29 Oct 2026
  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.

Inputs and outputs

Inputs

Inputs of Surface-code memory experiment (Stim + PyMatching)
NameTypeDefaultAllowed valuesDescription
distanceinteger3maximum: 25; minimum: 3Code distance d (odd).
roundsintegernullmaximum: 100; minimum: 1Syndrome-extraction rounds. null uses d rounds.
physical_error_ratenumber0.001maximum: 0.5; minimum: 0Depolarizing probability p applied after every Clifford gate.
basisstringxenum: x, zMemory basis: x prepares and measures the logical X observable, z the logical Z observable.
shotsinteger10000maximum: 10000000; minimum: 1Number of sampled experiments.
decoderstringpymatchingenum: pymatchingDecoder. Version 1.0.0 offers PyMatching (MWPM) only.

Outputs

Outputs of Surface-code memory experiment (Stim + PyMatching)
NameTypeDescription
logical_failuresintegerShots whose decoded logical observable was wrong.
logical_error_ratenumberlogical_failures / shots (per memory experiment of the given rounds, not per round).
confidence_intervalobject95% Wilson score interval: lower, upper, level, method.
is_upper_bound_onlybooleantrue when no failure was observed; then only the upper bound is meaningful.
decoder_versionstringInstalled PyMatching version that produced the result.

Sample result

d=5, 5 rounds, memory Z at p=0.003: 74 logical failures in 100000 shots, rate 0.00074 with 95% Wilson interval [0.00059, 0.00093].

Generated with

Product version
1.0.0
Seed
2026
Parameters
{"basis":"z","shots":100000,"rounds":null,"decoder":"pymatching","distance":5,"physical_error_rate":0.003}
SDK
0.3.0
Python
3.12.12
Platform
macOS-27.0.1-arm64-arm-64bit
Result data (JSON)
{
  "shots": 100000,
  "rounds": 5,
  "decoder": "pymatching",
  "distance": 5,
  "memory_basis": "z",
  "decoder_version": "2.4.0",
  "logical_failures": 74,
  "logical_error_rate": 0.00074,
  "confidence_interval": {
    "level": 0.95,
    "lower": 0.000589553636531904,
    "upper": 0.0009288026246445128,
    "method": "wilson_score"
  },
  "is_upper_bound_only": false,
  "physical_error_rate": 0.003
}

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).

Scope

  • Rotated surface code, memory in the X or Z basis, odd distance 3 to 25, 1 to 100 rounds.
  • Logical error rate per memory experiment with a 95% Wilson score interval.

Limitations

  • One noise model only; real devices have measurement, leakage, crosstalk and coherent errors that this does not include. A rate here is not a hardware prediction.
  • No threshold is estimated by a single run; sweep distances and rates and compare intervals yourself.
  • Rates are per experiment of the given number of rounds, not per round.
  • Exact counts are reproducible for the same seed with the same Stim and PyMatching versions; other versions may sample or decode differently.
  • Large distances with many shots take minutes; time grows with d^3 x shots, and runs needing more than 2 GiB of detector samples are refused rather than started.
  • 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
d=7 with 10^5 shots at p=0.001: ~0.3 s on a 2024 Apple-silicon laptop (measured). Time grows roughly as d^3 x shots; memory holds one byte per detector per shot, and runs needing more than 2 GiB of samples are refused.
SDK extras
qec
Minimum SDK
0.3.0

Validation

Verified: the example was executed by CI, validation tests exist and limitations are recorded.

Versions and changelog

  1. 1.0.029 Oct 2026currentShown on this page

    • First catalog release, wrapping the SDK's existing Stim + PyMatching surface-code memory experiment.

    Needs SDK 0.3.0 or later with extras: qec.

All product changelogs

Origin, license and credits

KetQat integration of open-source software

The surface code memory and its decoding by matching follow Dennis, Kitaev, Landahl and Preskill (2002) and Fowler et al. (2012). Circuits are generated and sampled by Stim (Craig Gidney) and decoded by PyMatching (Oscar Higgott and Craig Gidney); both are used unmodified as dependencies. KetQat wrote the integration: parameter handling, seed derivation, Wilson-interval reporting, validation tests and this catalog entry. KetQat did not invent the code, the noise model or the decoder.

Upstream software

License of what you receive

Apache-2.0 — 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. Craig Gidney (2021). Stim: a fast stabilizer circuit simulator. Quantum 5, 497.DOI 10.22331/q-2021-07-06-497
  4. Oscar Higgott (2022). PyMatching: A Python package for decoding quantum codes with minimum-weight perfect matching. ACM Transactions on Quantum Computing.arXiv:2105.13082
  5. Oscar Higgott, Craig Gidney (2023). Sparse Blossom: correcting a million errors per core second with minimum-weight matching. arXiv preprint.arXiv:2303.15933
  6. 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.

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.