Skip to main content

deq: dynamic and generic QEC decoding system

deq is a quantum error correction (QEC) decoding system that provides an automated workflow from declarative definitions of QEC codes and logical instructions to a runtime decoder for arbitrary dynamic logical circuits.

Key features:

  • Declarative .deq language — define QEC codes and their physical gate realizations using a stim-compatible DSL; deq automatically discovers checks (detectors) from the Clifford circuit
  • Dynamic circuit decoding — decode logical circuits whose instructions stream in at runtime, not just static offline-known circuits
  • Simulation & deployment — run logical error rate simulations, latency benchmarks, and deploy on real hardware with the same compiled library
  • Pluggable decoders — use a built-in decoder, or load any decoder from a binary-only shared library at runtime via a stable C ABI (see Decoder plugins)

See the Tutorial for a full introduction, language reference, and worked examples.

Installation

pip install deq

See Install from source below if you want a development build or to hack on the Rust runtime. For vs code user, it's recommended to install the QDK extension, which provides syntax highlight to deq files.

Quick start

Here is an example deq program:

# define a QEC code of [[n,k,d]] (d is optional)
CODE RepetitionCode [[3,1,3]] {
    LOGICAL X0*X1*X2 Z0*Z1*Z2
    STABILIZER Z0*Z1 Z1*Z2
}

GADGET PrepareZ {
    R 0 1 2
    X_ERROR(0.03) 0 1 2
    OUTPUT RepetitionCode 0 1 2
}

GADGET Idle {
    INPUT RepetitionCode 0 2 4
    X_ERROR(0.03) 0 2 4  # data qubit error
    R 1 3
    CX 0 1 2 3
    CX 2 1 4 3
    M(0.03) 1 3  # measurement error
    OUTPUT RepetitionCode 0 2 4
}

GADGET MeasureZ {
    INPUT RepetitionCode 0 1 2
    M(0.03) 0 1 2  # measurement error
    READOUT rec[-1] rec[-2] rec[-3]
}

# a logical circuit with criteria of logical error
PROGRAM Simulation {
    PrepareZ 0
    Idle 0
    MeasureZ 0
    ASSERT_EQ rec[-1] 0
}
# Transpile a .deq definition into a JIT library
deq transpile example.deq --out example.deq.jit --program Simulation

# Run a logical error rate simulation
deq server --decoder relay-bp --coordinator window \
    --controller jit --controller-config '{"filepath":"example.deq.jit"}' \
    --simulator jit-static --simulator-config '{"filepath":"example.stim","jit_library_filepath":"example.deq.jit","shots":100000}'

Decoder plugins

deq ships several built-in decoders, including native graph MWPM (--decoder mwpm), native hypergraph MWPF (--decoder mwpf), graph union-find (--decoder uf), hypergraph union-find (--decoder huf), Relay-BP (--decoder relay-bp), and Tesseract (--decoder tesseract). The legacy black-box-* names remain accepted. deq can also load a decoder from a binary-only shared library at runtime — no recompilation of deq — as long as the library implements deq's stable C ABI. This lets you plug in a decoder written in any language (Rust, C, C++) and distributed as a .so/.dylib/.dll.

Build the runtime with the dylib feature (off by default), then select the plugin by path:

# build deq_runtime with plugin loading enabled
cd deq_runtime && maturin develop --release --features dylib && cd ..

# decode with a plugin. `library` is the path to the shared object and
# `parallel` is deq's worker count; plugin-specific parameters go in the
# nested `decoder_config` object, the only part forwarded to the plugin.
deq server --decoder dyn-lib \
    --decoder-config '{"library":"/path/to/libmy_decoder.so","parallel":0,"decoder_config":{}}' \
    --coordinator window ...

The plugin is loaded once (dlopen), then serves every decode in-process at native speed; there is no per-shot serialization. To write a plugin, implement the DeqDecoder trait and the declare_decoder! macro from the deq-decoder-abi crate (Rust), or export the C ABI directly using its header deq_decoder.h (C/C++). See that crate's documentation for the full contract.

Install from source

Prerequisites

  • Python ≥ 3.10
  • Rust toolchain (for building deq_runtime)
  • maturin (pip install maturin)
  • protobuf compiler (apt install protobuf-compiler on Ubuntu, brew install protobuf on macOS)

Steps

# 1. Build and install the Rust runtime (deq_runtime)
cd deq_runtime
maturin develop --release
cd ..

# 2. Generate protobuf Python bindings
python deq/proto/compile.py

# 3. Install the deq Python package
pip install -e .

Metadata

Release files for deq 0.5.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deq 0.5.17
File Size Uploaded Provenance Actions
deq-0.5.17.tar.gz 273.1 kB Without provenance Details for deq-0.5.17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deq 0.5.17
File Interpreter ABI Platform Actions
deq-0.5.17-py3-none-any.whl Python 3 none any Details for deq-0.5.17-py3-none-any.whl

Total release size: 630.4 kB

Release files / deq-0.5.17.tar.gz

Download URL deq-0.5.17.tar.gz
Size 273.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a4c39468675a986b6d85dfda721eac5076b10db836f23137bcf4204437670fcc
BLAKE2b-256 checksum
How to use checksums
843a8cc2dedcf630a752d3ba21f67838c8064decf89a41da58a2ef282727dd17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / deq-0.5.17-py3-none-any.whl

Download URL deq-0.5.17-py3-none-any.whl
Size 357.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4920b8dfa69b58a3999759533d1f2699dd1783ca9102bcd1f987b4871743511
BLAKE2b-256 checksum
How to use checksums
2464e5f42ae251680d544d9fad4d454147f47dd4255d06bddab46eead88d9802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for deq 0.5.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.17 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page