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.dev20250809020229-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.dev20250809020229-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.dev20250809020229-py312-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.12macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20250809020229-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.dev20250809020229-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.dev20250809020229-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.dev20250809020229-py311-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.11macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20250809020229-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.dev20250809020229-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.dev20250809020229-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.dev20250809020229-py310-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3.10macOS 11.0+ ARM64

tesseract_decoder-0.1.1.dev20250809020229-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.dev20250809020229-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py312-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d4232e7599d940f5a1abe2fc31b6c837016fc837828007f1b604c34ce61e020e
MD5 fb9233f0c8eced438213928ec1195e04
BLAKE2b-256 a5f190a20f6ef9c4b7c08fe40a6fdd5e63e92a8ac7515caa7e6775b86745add7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py312-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 892a94cfdafc2d1dcf28a268bf7c1310173a5444948c933206f0547925067a8f
MD5 865b196128fa467c94846a7f58245a3f
BLAKE2b-256 64803c025cb0f36a95248a6c6b813ac50d76aed1027a46e8924a467fdbdda9c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py312-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a87fc4e49bccb35e8db8e003cbbe04afde1d980210a638994bb779c708bcca46
MD5 ca702a953031c25271fbd52adb03dffd
BLAKE2b-256 a951a22a9a9201244ec8841d725caa771d736fba5ab26d7c7cca243c5af872c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py312-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8649d1a5d889e51fdfa0dce90bdae48abd1d9658d4a5923ad9b5532e4cfdb2ac
MD5 53767c0159d5fbb2335fe39ed0d8e6c6
BLAKE2b-256 168de43c8d300a7e8e108a1e53e2d9a78c85869f0c11c63a5354e1c0d4b0a6ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py311-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0bd59ef14d30b4dcbd51188983c1eeca9d3d4ef2562b6240ea76bfa87c1328c
MD5 bf06da688032b440d874be9b0f8ea1d9
BLAKE2b-256 7550b5d2a714a0597a784028f909be57ee247e036afb43972beda1e79001d77e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py311-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89764e5e7cc1fef878552da75837fd1a84b5479ff2458d2376f6a5facd8792e7
MD5 9a697192c7f2e6637783b80a5fb97dcd
BLAKE2b-256 889229528a6306bb3e16ad2dbf6e9083fdabd0a5f1876ff66f13ff0271b9fd63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py311-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6701eb763bce45cec3d1c482ff81996057e1d472c1f4f04dd79b8056a072807
MD5 b531ebd08db5eea598471af9e3d7024f
BLAKE2b-256 4b389deb4753a10c51eb4ec34e2b103eb6c17c6646f3717213fa8ef00272eafb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py311-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a1a218a5b90286ebaabe1bd9eef83866c1d6efe59096ac1232fb2249b28e699e
MD5 f48350a562f4a53cc77e6866e9f61b4e
BLAKE2b-256 824416a45d326e7cea45d9a5d5e0ba964b2b5e2744e0221649f9c3ed8eaec0d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py310-none-manylinux_2_39_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9a17fbeed3af4b3411c0494f2281a3ceeebc768103f8a4e993ef35610b7b505
MD5 fd296dfd3e043ce20b072ab8745002be
BLAKE2b-256 c071598fdd8f1542665ff4a0854600b5d7783dfbf893d0a75969298bb0a84b65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py310-none-manylinux_2_35_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4fecd3a6f0e716cadb7c5a2ade5cd9ef4c0c1bab1a0bcb19b250ab652e4ea8d
MD5 03a94bdf3c6a497f9025b548061e2afc
BLAKE2b-256 fc9e7d895f33bb4df4433b915ff31faf5daa8134a46f73cd3809da38ebde8f2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py310-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e727aececf342415ca6f4edcb9b59c5e0c4e98551e4d8f1a7e3a8da4f7701de
MD5 8d6ff64ec441d2e94ee6051633d6ea14
BLAKE2b-256 7c988ad3ab5d34aa394645a3d32d03a6b5673333af10829dbf64a12e36211519

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tesseract_decoder-0.1.1.dev20250809020229-py310-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 83d9d74c2bcb2c0d71741751f6e8d9f2b47cdc364c599113ee464353522a1712
MD5 fe2d542d593dbeb242174315715d9b33
BLAKE2b-256 d05bd0ccdccb196dbc9abf7d2a3d5cd167ecc329dae59ad8707a4570f4cef399

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