Quantum Error Correction · Memory experiments
Repetition code memory (bit-flip)
Monte Carlo logical error rate of the n-qubit bit-flip repetition code under i.i.d. bit flips, beside the exact binomial value.
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.
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.
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.
pip install "ketqat[qec] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].
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"],
}))
{
"rounds": 3,
"status": "succeeded",
"decoder": "pymatching",
"distance": 3,
"observed_failures": true,
"interval_brackets_rate": true
}Verified with
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.
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
| distance | integer | 3 | maximum: 25; minimum: 3 | Code distance d (odd). |
| rounds | integer | null | maximum: 100; minimum: 1 | Syndrome-extraction rounds. null uses d rounds. |
| physical_error_rate | number | 0.001 | maximum: 0.5; minimum: 0 | Depolarizing probability p applied after every Clifford gate. |
| basis | string | x | enum: x, z | Memory basis: x prepares and measures the logical X observable, z the logical Z observable. |
| shots | integer | 10000 | maximum: 10000000; minimum: 1 | Number of sampled experiments. |
| decoder | string | pymatching | enum: pymatching | Decoder. Version 1.0.0 offers PyMatching (MWPM) only. |
| Name | Type | Description |
|---|---|---|
| logical_failures | integer | Shots whose decoded logical observable was wrong. |
| logical_error_rate | number | logical_failures / shots (per memory experiment of the given rounds, not per round). |
| confidence_interval | object | 95% Wilson score interval: lower, upper, level, method. |
| is_upper_bound_only | boolean | true when no failure was observed; then only the upper bound is meaningful. |
| decoder_version | string | Installed PyMatching version that produced the 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
{"basis":"z","shots":100000,"rounds":null,"decoder":"pymatching","distance":5,"physical_error_rate":0.003}{
"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
}noiseless control
At p = 0 no logical failure is observed and the result is reported as an upper bound only.
python/tests/test_catalog_products.py::test_surface_code_has_no_failures_without_noise
distance scaling
Below threshold (memory Z, p = 0.003, 100000 shots, fixed seed) the d = 5 logical error rate is below the d = 3 rate with disjoint 95% Wilson intervals.
python/tests/test_catalog_products.py::test_surface_code_logical_error_rate_falls_with_distance
interval present
Every result carries a 95% Wilson score interval that brackets the point estimate.
python/tests/test_catalog_products.py::test_surface_code_reports_a_wilson_interval
same implementation
The product reproduces the logical failure count of the SDK's surface-code-memory-mwpm 0.1.0 manifest run at the same distance, rate, seed and shots.
python/tests/test_catalog_products.py::test_surface_code_matches_the_manifest_runner
example execution
The example code is executed verbatim in a clean virtual environment with only the qec extra installed.
1.0.029 Oct 2026currentShown on this page
Needs SDK 0.3.0 or later with extras: qec.
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.
Apache-2.0 — see Licensing.
People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.
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.
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.