Skip to main content

A search-based decoder for quantum error correction (QEC).

Project description

Tesseract Decoder

A Search-Based Decoder for Quantum Error Correction.

Licensed under the Apache 2.0 open-source license C++

InstallationUsagePython InterfacePaperHelpCitationContact

Tesseract is a Most Likely Error decoder designed for Low Density Parity Check (LDPC) quantum error-correcting codes. It applies pruning heuristics and manifold orientation techniques during a search over the error subsets to identify the most likely error configuration consistent with the observed syndrome. Tesseract achieves significant speed improvements over traditional integer programming-based decoders while maintaining comparable accuracy at moderate physical error rates.

We tested the Tesseract decoder for:

  • Surface codes
  • Color codes
  • Bivariate-bicycle codes
  • Transversal CNOT protocols for surface codes

Features

  • A* search: deploys A* search while running a Dijkstra algorithm with early stop for high performance.
  • Stim and DEM Support: processes Stim circuit files and Detector Error Model (DEM) files with arbitrary error models. Zero-probability error instructions are automatically removed when a DEM is loaded.
  • Parallel Decoding: uses multithreading to accelerate the decoding process, making it suitable for large-scale simulations.
  • Efficient Beam Search: implements a beam search algorithm to minimize decoding cost and enhance efficiency. Sampling and Shot Range Processing: supports sampling shots from circuits. When a detection error model is provided without an accompanying circuit, Tesseract requires detection events from files using --in. The decoder can also process specific shot ranges for flexible experiment setups.
  • Detailed Statistics: provides comprehensive statistics output, including shot counts, error counts, and processing times.
  • Heuristics: includes flexible heuristic options: --beam, --det-penalty, --beam-climbing, --no-revisit-dets, --at-most-two-errors-per-detector, and --pqlimit to improve performance while maintaining a low logical error rate. To learn more about these options, use ./bazel-bin/src/tesseract --help
  • Visualization tool: open the viz directory in your browser to view decoding results. See viz/README.md for instructions on generating the visualization JSON.

Installation

Tesseract relies on the following external libraries:

  • argparse: For command-line argument parsing.
  • nlohmann/json: For JSON handling (used for statistics output).
  • Stim: For quantum circuit simulation and error model handling.

Build Instructions

Tesseract uses Bazel as its build system. To build the decoder:

bazel build src:all

Running Tests

Unit tests are executed with Bazel. Run the quick test suite using:

bazel test //src:all

By default the tests use reduced parameters and finish in under 30 seconds. To run a more exhaustive suite with additional shots and larger distances, set:

TESSERACT_LONG_TESTS=1 bazel test //src:all

Usage

The file tesseract_main.cc provides the main entry point for Tesseract Decoder. It can decode error events from Stim circuits, DEM files, and pre-existing detection event files.

Basic Usage:

./tesseract --circuit CIRCUIT_FILE.stim --sample-num-shots N --print-stats

To decode pre-generated detection events, provide the input file using --in SHOTS_FILE --in-format FORMAT.

Example with Advanced Options:

./tesseract \
        --pqlimit 1000000 \
        --at-most-two-errors-per-detector \
        --det-order-seed 232852747 \
        --circuit circuit_file.stim \
        --sample-seed 232856747 \
        --sample-num-shots 10000 \
        --threads 32 \
        --print-stats \
        --beam 23 \
        --num-det-orders 1 \
        --shot-range-begin 582 \
        --shot-range-end 583

Example Usage

Sampling Shots from a Circuit:

./tesseract --circuit surface_code.stim --sample-num-shots 1000 --out predictions.01 --out-format 01

Using a Detection Event File:

./tesseract --in events.01 --in-format 01 --dem surface_code.dem --out decoded.txt

Using a Detection Event File and Observable Flips:

./tesseract --in events.01 --in-format 01 --obs_in obs.01 --obs-in-format 01 --dem surface_code.dem --out decoded.txt

Tesseract supports reading and writing from all of Stim's standard output formats.

Performance Optimization

Here are some tips for improving performance:

  • Parallelism over shots: increase --threads to leverage multicore processors for faster decoding.
  • Beam Search: use --beam to control the trade-off between accuracy and speed. Smaller beam sizes result in faster decoding but potentially lower accuracy.
  • Beam Climbing: enable --beam-climbing for enhanced cost-based decoding.
  • At most two errors per detector: enable --at-most-two-errors-per-detector to improve performance.
  • Priority Queue limit: use --pqlimit to limit the size of the priority queue.

Output Formats

  • Observable flips output: predictions of logical errors.
  • DEM usage frequency output: if --dem-out is specified, outputs estimated error frequencies.
  • Statistics output: includes number of shots, errors, low confidence shots, and processing time.

Python Interface

Full Python wrapper documentation

This repository contains the C++ implementation of the Tesseract quantum error correction decoder, along with a Python wrapper. The Python wrapper/interface exposes the decoding algorithms and helper utilities, allowing Python users to leverage this high-performance decoding algorithm.

For installation:

pip install tesseract-decoder

The following example demonstrates how to create and use the Tesseract decoder using the Python interface.

from tesseract_decoder import tesseract
import stim
import numpy as np


# 1. Define a detector error model (DEM)
dem = stim.DetectorErrorModel("""
    error(0.1) D0 D1 L0
    error(0.2) D1 D2 L1
    detector(0, 0, 0) D0
    detector(1, 0, 0) D1
    detector(2, 0, 0) D2
""")

# 2. Create the decoder configuration
config = tesseract.TesseractConfig(dem=dem, det_beam=50)

# 3. Create a decoder instance
decoder = config.compile_decoder()

# 4. Simulate detector outcomes
syndrome = np.array([0, 1, 1], dtype=bool)

# 5a. Decode to observables
flipped_observables = decoder.decode(syndrome)
print(f"Flipped observables: {flipped_observables}")

# 5b. Alternatively, decode to errors
decoder.decode_to_errors(syndrome)
predicted_errors = decoder.predicted_errors_buffer
# Indices of predicted errors
print(f"Predicted errors indices: {predicted_errors}")
# Print properties of predicted errors
for i in predicted_errors:
    print(f"    {i}: {decoder.errors[i]}")

Good Starting Points for Tesseract Configurations:

The Tesseract paper recommends two setup for starting your exploration with tesseract:

(1) Long-beam setup:

tesseract_config = tesseract.TesseractConfig(
    dem=dem,
    pqlimit=1_000_000,
    det_beam=20,
    beam_climbing=True,
    num_det_orders=21,
    det_order=tesseract_decoder.utils.DetOrder.DetIndex,
    no_revisit_dets=True,
)

(2) Short-beam setup:

tesseract_config = tesseract.TesseractConfig(
    dem=dem,
    pqlimit=200_000,
    det_beam=15,
    beam_climbing=True,
    num_det_orders=16,
    det_order=tesseract_decoder.utils.DetOrder.DetIndex,
    no_revisit_dets=True,
)

For det_order, you can use two other options of DetIndex and DetCoordinate as well. These values balance decoding speed and accuracy across the benchmarks reported in the paper and can be adjusted for specific use cases.

Help

We are committed to providing a friendly, safe, and welcoming environment for all. Please read and respect our Code of Conduct.

Citation

When publishing articles or otherwise writing about Tesseract Decoder, please cite the following:

@misc{beni2025tesseractdecoder,
    title={Tesseract: A Search-Based Decoder for Quantum Error Correction},
    author = {Aghababaie Beni, Laleh and Higgott, Oscar and Shutty, Noah},
    year={2025},
    eprint={2503.10988},
    archivePrefix={arXiv},
    primaryClass={quant-ph},
    doi = {10.48550/arXiv.2503.10988},
    url={https://arxiv.org/abs/2503.10988},
}

Contact

For any questions or concerns not addressed here, please email tesseract-decoder-dev@google.com.

Disclaimer

Tesseract Decoder is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.

Copyright 2025 Google LLC.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tesseract_decoder-0.1.1.dev20251013180524-py313-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.13manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py313-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded Python 3.13manylinux: glibc 2.35+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py313-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.13macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20251013180524-py313-none-macosx_10_13_x86_64.whl (3.1 MB view details)

Uploaded Python 3.13macOS 10.13+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.12manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py312-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded Python 3.12manylinux: glibc 2.35+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py312-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.12macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20251013180524-py312-none-macosx_10_13_x86_64.whl (3.1 MB view details)

Uploaded Python 3.12macOS 10.13+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py311-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.11manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py311-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded Python 3.11manylinux: glibc 2.35+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py311-none-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded Python 3.11macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20251013180524-py311-none-macosx_10_13_x86_64.whl (3.1 MB view details)

Uploaded Python 3.11macOS 10.13+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py310-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.10manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py310-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded Python 3.10manylinux: glibc 2.35+ x86-64

tesseract_decoder-0.1.1.dev20251013180524-py310-none-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded Python 3.10macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20251013180524-py310-none-macosx_10_13_x86_64.whl (3.1 MB view details)

Uploaded Python 3.10macOS 10.13+ x86-64

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py313-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py313-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0840a6fb0e108121751cd828671ecd738740aae564b012d11698151460a16926
MD5 8b0643c64a704ca2681ee8734e101869
BLAKE2b-256 ebbe1594e655675c277ddc27cb490f78bf3cd723df4f96e7a7cb27ab38223422

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py313-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py313-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e21151689d7b9ed1447da81da9e1420ab88df2b7dc4e7a0cd89da7f46609b0f
MD5 8fab5b8b04b9d1894544f1b49b0d286a
BLAKE2b-256 113754f3e7b380e07c1972d3ec6df4e73f0d75cc64cede8947bdee6fe033045d

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py313-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py313-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a90d9314ead58c8b286e886a58b4324c627f17a4ec03aea25a06113eee835faf
MD5 ae359aeb55c45de1beb985881a52f4ce
BLAKE2b-256 69d16dad1568a82aeca9807b4d31a5e082682dc20160b2fde643faa35acb2255

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py313-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py313-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1ff730f77a86e843eb99efde9b30b77575be17d6d383ca7be0294c6234983b9b
MD5 72a0627cf9c0046804cd3a773627e337
BLAKE2b-256 f0b5f72da7e52637a2297e469b5263fc6b3d7ff78edba80dd7cfdd271714bb3e

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0a96d2a57d4835b1f6a9c73d72d92856b995dca5c2a88cd529612e1e2b44e38
MD5 9c105af622876eb6bf7992fe02f37117
BLAKE2b-256 a6e9c660e6bc0e1fbfcb17936d2e06b3b0a7508553b32f1c87fdc02244b6f6e1

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py312-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py312-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9876f0c5367bac197b5ba8e160c124c0f8a7e720feb9f2369c48fa39443cb445
MD5 e7d8be0c48a3c8397e3ea45552e24c1e
BLAKE2b-256 29e0c47c0fe988941096bb89f92f9dde0ea43bcab950608271046f405d99c130

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py312-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py312-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11b113adf82cd145e07ab51794701640b8f3aa1131f06e58009394a3243ced5a
MD5 934fe5e12e2dbf8a84869eddd0ef124f
BLAKE2b-256 e40095ee69504f8c906aba3f066cb1aebc891fd89b2d75890af234918bd11d23

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py312-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py312-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c660720814addd5bfc3da551a471cd4fd15e1149b603960aeb8b0554681caeed
MD5 11ad135fed3c9d7e7c682d244c71e2fb
BLAKE2b-256 43601ecce2971007426e60e0f846e7ddb7921ad2a74d773bc7b4f035706d12bc

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py311-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py311-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f149279d392668f4bcc47b8f616cb54dfc44c27dd4287f00d0739102ee196cb0
MD5 96c29c93304360a1547a2e72ea562846
BLAKE2b-256 50731f9bc4db6ffa14e816648a66ba1881c95f0c024bc4fe5bb6acf1e90874b0

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py311-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py311-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d295fae3fae771e1eb6ac79daff09cb3bc65175f15fc27d34e8f38ac141888d
MD5 7d3d7a9631daa984766f2b9f211e18be
BLAKE2b-256 2f64e712e8cd5aac17fe72de14a4686f964f5a2e230aa05ed1aca12a281eee56

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py311-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py311-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e13d6ea8710154492d0a9fa98af26d93b83f6a525cc1f6c5205c371ce769b88c
MD5 64317dc2e1c4d5d652c034fd9b9ccbfa
BLAKE2b-256 34b105079078166b082f53d1f5611d7031cc127269391be5585b2ce4ce8c9220

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py311-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py311-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 90cfd85aaa39d6208b7e3e7385acb1231a6d3d0d93f7c10ca6fa548d58a3beeb
MD5 9a2081fda2b2fab50758823e6136b07c
BLAKE2b-256 0ad04d680ada174ffbb07b1c54209e9afefd75c323fd1c77f80520860ab7d9c9

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py310-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py310-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e6205ac9794b79fa4a5757c22d9c9f8c89d92f6b5147f63691edc190f5b2d0ab
MD5 9f30893ceff2b1daccceb41b06db3f76
BLAKE2b-256 57cedc16f36484feee9d399b7a9ce9c03314cea1d503fe95bb5383b06707b986

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py310-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py310-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea4580d976605084b99f4757641c4ed1ec0956ecaf5093da49d7c2caafd28cc2
MD5 881441d51672720b4c2a89df63e64907
BLAKE2b-256 5af73066a47af7d23d08c0d9df80e19adb6262fe502f88dfc98f809e74d5b79d

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py310-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py310-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a4a1f404114855749b132425d014ab04a507545e6d21e6bfea7f9551593be6f
MD5 8ffbbd02d1a30ebaba04c86ae16e9611
BLAKE2b-256 33d32626605ad79142da82d33f6a6b02eacdc11663dc6dcbfcc233dd1a6245dd

See more details on using hashes here.

File details

Details for the file tesseract_decoder-0.1.1.dev20251013180524-py310-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20251013180524-py310-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 434427f01a4b580435cc92c2730b1536d2894ec6f5b1bbd24dbc3ca1692c0bc1
MD5 848568c7df2ec049e88b1ae7a67ee68f
BLAKE2b-256 f8b8fe76606faa1fc046c30755d986d0ab7ba7367ceb4d364d143365d395b98f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page