Skip to main content

A fast implementation of the mobius color code decoder.

Project description

Chromobius: color code decoder

Chromobius is an implementation of a "mobius decoder", which approximates the color code decoding problem as a minimum weight matching problem. Chromobius uses PyMatching to solve the minimum weight matching problem.

See ((((the paper "New circuits and an open source decoder for the color code")))) for more details on how Chromobius works.

How to use Chromobius

See the getting started notebook.

Also see the python api reference.

Programmers who want to edit and build Chromobius can check the developer documentation.

Example Snippets

Decoding a shot with Chromobius

From python:

import stim
import chromobius
import numpy as np

def count_mistakes(circuit: stim.Circuit, shots: int) -> int:
    # Sample the circuit.    
    dets, actual_obs_flips = circuit.compile_detector_sampler().sample(
        shots=shots,
        separate_observables=True,
        bit_packed=True,
    )

    # Decode with Chromobius.
    decoder = chromobius.compile_decoder_for_dem(circuit.detector_error_model())
    predicted_obs_flips = decoder.predict_obs_flips_from_dets_bit_packed(dets)

    # Count mistakes.
    return np.count_nonzero(np.any(predicted_obs_flips != actual_obs_flips, axis=1))

From the command line:

# Sample shots of detectors and observable flips.
stim detect \
    --shots 100000 \
    --in "example_circuit.stim" \
    --out "dets.b8" \
    --out_format "b8" \
    --obs_out "obs_actual.txt" \
    --obs_out_format "01"
    
# Extract a detector error model used to configure Chromobius.
stim analyze_errors \
    --in "example_circuit.stim" \
    --fold_loops \
    --out "dem.dem"

# Decode the shots.
chromobius predict \
    --dem "dem.dem" \
    --in "dets.b8" \
    --in_format "b8" \
    --out "obs_predicted.txt" \
    --out_format "01"

# Count the number of shots with a prediction mistake.
paste obs_actual.txt obs_predicted.txt \
    | grep -Pv "^([01]*)\\s*\\1$" \
    | wc -l

From python using sinter:

import sinter
import chromobius
import os

tasks: list[sinter.Task] = ...
stats: list[sinter.TaskStats] = sinter.collect(
    decoders=["chromobius"], 
    custom_decoders=chromobius.sinter_decoders(),
    tasks=tasks,
    num_workers=os.cpu_count(),
    max_shots=100_000,
    max_errors=100,
)

From the command line using sinter:

sinter collect \
    --circuits "example_circuit.stim" \
    --decoders chromobius \ 
    --custom_decoders_module_function "chromobius:sinter_decoders" \
    --max_shots 100_000 \
    --max_errors 100
    --processes auto \
    --save_resume_filepath "stats.csv" \

Project details


Download files

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

Source Distribution

chromobius-0.0.dev1702544746.tar.gz (53.3 kB view details)

Uploaded Source

Built Distributions

chromobius-0.0.dev1702544746-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

chromobius-0.0.dev1702544746-cp312-cp312-macosx_11_0_arm64.whl (838.0 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromobius-0.0.dev1702544746-cp312-cp312-macosx_10_15_x86_64.whl (887.5 kB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

chromobius-0.0.dev1702544746-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

chromobius-0.0.dev1702544746-cp311-cp311-macosx_11_0_arm64.whl (837.4 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromobius-0.0.dev1702544746-cp311-cp311-macosx_10_15_x86_64.whl (885.9 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

chromobius-0.0.dev1702544746-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

chromobius-0.0.dev1702544746-cp310-cp310-macosx_11_0_arm64.whl (837.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromobius-0.0.dev1702544746-cp310-cp310-macosx_10_15_x86_64.whl (885.8 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

File details

Details for the file chromobius-0.0.dev1702544746.tar.gz.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746.tar.gz
Algorithm Hash digest
SHA256 d2a8c05403363f380e585e10a15a4a28ebc65b286342c96f0f7501b9dbe57296
MD5 df0ec12f8cc40f84596bec4a3128aec4
BLAKE2b-256 220aec8bbbf53e1e062a830b3b4e3e5f7a5631af7a479de1f171e55a7cceda32

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79a43e875bf48a23f8dabfd3e5a6c18b8b940a474b0b66ce6862ae349f10abd5
MD5 16a2dcf3520249ed8aa7b2da8b0d54f6
BLAKE2b-256 39e025e55de537fb8ae32c2ab0ee99a37d7a5a0f05b4c8f3ad3760aaf88da88c

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d955a58a23ebed54e7a8e8b6cda912b7d48f6a542ba3fba10e30e3a50bdde294
MD5 1ba5fadb0cef6043a7eb9f81992bd46d
BLAKE2b-256 947b1904df3eb1045476d3f9c9ffebf630e34176abfe5d9a004c23e0b88991e2

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 0a07138cbde12959d09529b92d9ca8afe7082b305e2be302dbc71f4100dcdfbf
MD5 a48ce7b71124ce9aa4ca34fa2bc4eb02
BLAKE2b-256 ba8d24200c832cc76822956d111e632545fa47c839901ae86bba5a4887163f25

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7617e0c71cd55ee60bddf56459e469d14bfd5bf1f1026bc50bcedb4642e1349
MD5 1dfb2b4aa76b6c0c05e66bce16464f95
BLAKE2b-256 6e0ad100a55e69c91dcf5f27cb0732c7cabe0ee9e0abab7b3234343f18128f8c

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90e204caeb185fe41ef016a5afae0e1a25a4f6979bc5a1dfab6d1c00d10f9867
MD5 17902ad8c0438884d05d1aa5c30eaa4a
BLAKE2b-256 debb32fbd62b2736fa2a69a77a9e899f317acd8b7ecce204d58222a5f2a4babb

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5a0c3e236339dce782fb5a253629144b472daddf77d6e77d414f59e10dcdd5df
MD5 e861baed8cecb1d4629b6dca28c877df
BLAKE2b-256 bed514f6b38532e6caa34aec6fda89ed6697379ec4eb027bfad74a777cc47a01

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 07cd52f6caf36b1575b6b6237608bf1157d8788b2dad92642b370f7698b33b90
MD5 aa4892a97260e291316d5f05b1686efb
BLAKE2b-256 b51090fa76df3b4da0a6e77e8d2c6535e995567f91cc0c1bca56b63e833e64d6

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d9ffef2510c6076029052e15348db4d5003366673c8b71648d63074aa293677
MD5 9853e990c1bcc8967c7fb7be834aadb1
BLAKE2b-256 acdb2a0c90be93378299865c1c8c977c175623112a570b8f59853f7b4b774c85

See more details on using hashes here.

File details

Details for the file chromobius-0.0.dev1702544746-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-0.0.dev1702544746-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 23b90fea80e75cc08943c2efc2209aa1044bbab6722df313950b931d0b3575da
MD5 cdeeb9aae65e23f92e9ec485a6065d80
BLAKE2b-256 0c75e57cd8fa9d517d674cfb558cb44f19f7511c3cb815c870a33977feb45281

See more details on using hashes here.

Supported by

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