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.

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

import tesseract_decoder.tesseract as tesseract
import stim

# 1. Define a detector error model (DEM)
dem = stim.DetectorErrorModel("""
    error(0.1) D0 D1
    error(0.2) D1 D2 L0
    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. Configure and create a decoder instance
decoder = tesseract.TesseractDecoder(config)

# 4. Simulate detection events and decode it
detections = [1, 2]
flipped_observables = decoder.decode(detections)

print(f"Detections: {detections}")
print(f"Flipped observables: {flipped_observables}")

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.dev20250810143737-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded Python 3.12manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py312-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.12manylinux: glibc 2.35+ x86-64

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

Uploaded Python 3.12macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20250810143737-py312-none-macosx_10_13_x86_64.whl (3.0 MB view details)

Uploaded Python 3.12macOS 10.13+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py311-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded Python 3.11manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py311-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.11manylinux: glibc 2.35+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py311-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.11macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20250810143737-py311-none-macosx_10_13_x86_64.whl (3.0 MB view details)

Uploaded Python 3.11macOS 10.13+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py310-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded Python 3.10manylinux: glibc 2.39+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py310-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded Python 3.10manylinux: glibc 2.35+ x86-64

tesseract_decoder-0.1.1.dev20250810143737-py310-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.10macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20250810143737-py310-none-macosx_10_13_x86_64.whl (3.0 MB view details)

Uploaded Python 3.10macOS 10.13+ x86-64

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7dcd8ff0ccf757f164124f59c9e753f189188d5378e6e20cd1eb2382dee9dbf
MD5 7b2d7e4d857cc3ebb7782d0c91c5c495
BLAKE2b-256 31ed7c76b73a5176755e3d5afd0ba3b1d3b2466959355c6f5d636e216348d280

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py312-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ded3419f0cd29ba9127423e479119256db85621cecbe776a9a5eb40922d5168e
MD5 d922246ccefb5f4ec05bc00c82e3d46a
BLAKE2b-256 9d06be0b59529e1dff026cebfd6ba4db16b3171c9cc6db6f3f1a613814c8f650

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py312-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4a7f77df032a570f162bed61b0874624d5d75a054d93c010b5f71777e019b88
MD5 58265e9edbae39decfba8424ea651ee5
BLAKE2b-256 09f984bba39f8d039d06a75f833d69a8d78c02e87d520580362f952b504809d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py312-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5a974bba9b7b10db8396ff7accba57ca2324b02e82b3e7b23b2ab28e848e6749
MD5 5682d362211a33a97c54218d9219d5ab
BLAKE2b-256 1e2e07cb8a6764438d41216c2a78a8b29c8cac16e345ee0110e27e983290fdff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py311-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8cd9750f3bca0a87d194cfeaf423cc0f65fe5b723637fc40e7216e00eb0209b7
MD5 de8ccf2caab0e0c0e7b5f0772eef1cde
BLAKE2b-256 478c43d8aa3280b15baef1a481aed6a30244ce2e67188fc82af8c47269e9fcd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py311-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f10b45290a3bbe799679c16389d6e459867b79588c395135df8ccf692a8f66d7
MD5 6985aceb4c0362a80c9af26167a5576d
BLAKE2b-256 8b1a5a297dd24b31e0113ddcbbd8c9a1e3a087f798340ed33e03e0c781315e1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py311-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 22b698a14d1c30eb03384c6d136cd79476d625137735bb947c2538d864788c1c
MD5 1e526a39f25082c2eaf464782554f4b7
BLAKE2b-256 a2c5a6b95e0dfc78908f47c8e2627ebc02a91bc473ce7eb17dcad76e419a957e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py311-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ff576a384fa876d15dc1ff36f4c99dccdd3a706d9c5cde3bb6b1384e56c98f20
MD5 83ba1c674a38a4b314caa4c9e46e6341
BLAKE2b-256 73588e318c38f5d8086f094cb7747919e3124073895c64e6ccda0e2df8945243

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py310-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da83e13768dd67c4e4d4c976ff52c5b3010ad4333f2926313a9d8200094ca9a0
MD5 609bfabc6f8717f25a56aaf1b6bc1dbe
BLAKE2b-256 0ed2149343dbecf457eafc5c47392e3727973e539a9542fed224a7efab34b8fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py310-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88b112d73a7b2592b3748a49eea81966177f329f4708b0437337c2a200474bbd
MD5 c96bb57256c32fa4e9eaf19d661be92f
BLAKE2b-256 1e231f77df65bb2976cbada5909c1d25f55a4f99972443f3d667b62d20f08048

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py310-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b395e98cf3da18ec0b40326d59c1c6a6ea054a801b1a3ab72ad64b8aafbcb66
MD5 90687e6041dfa4ab164c547b2e1d5fde
BLAKE2b-256 1a0aa90f891d23ebbcae60bede5cc662734b2cbc8721a4fed5e84836fdc2629e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250810143737-py310-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 57a25e4e406d4d0715eb190714fbaf55ce5af74dab70dfb85ca0373039641aae
MD5 bb79d94f6f562e0db1e56e857d6e5de8
BLAKE2b-256 ddd4e57116237b0f8bfd701269f96c524bf46905feb93a4b99890f33208eadc0

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