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-1.2.dev1727169923.tar.gz (55.6 kB view details)

Uploaded Source

Built Distributions

chromobius-1.2.dev1727169923-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

chromobius-1.2.dev1727169923-cp312-cp312-macosx_11_0_arm64.whl (866.5 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromobius-1.2.dev1727169923-cp312-cp312-macosx_10_15_x86_64.whl (929.1 kB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

chromobius-1.2.dev1727169923-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

chromobius-1.2.dev1727169923-cp311-cp311-macosx_11_0_arm64.whl (865.6 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromobius-1.2.dev1727169923-cp311-cp311-macosx_10_15_x86_64.whl (928.0 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

chromobius-1.2.dev1727169923-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

chromobius-1.2.dev1727169923-cp310-cp310-macosx_11_0_arm64.whl (865.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromobius-1.2.dev1727169923-cp310-cp310-macosx_10_15_x86_64.whl (927.9 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

File details

Details for the file chromobius-1.2.dev1727169923.tar.gz.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923.tar.gz
Algorithm Hash digest
SHA256 28b86b4e10ff064862c2f197608e0bcf83708b2c0136cd3b99a95faf6bfa1bca
MD5 06109dce6c37f992090631931745f133
BLAKE2b-256 71b2d4c0fc045c81cb3ce5913a9e2f68f9a2499fcbcf1be8a11a682a5f2c8b4e

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d1de5c32d5087575239e4630c9995ae1b993187c0ebd56994da7b3f00925aeb
MD5 ab3f11bb219afb8acc1f7a6703267c04
BLAKE2b-256 9ba3dd051c69d1af42a2f18503a62db64cda6b9193fcf0bf458af358725ddb5b

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9601565f8c99fe87db79180718f7359655ca09462066df638f052e745ad42647
MD5 916741240ffa11fb3e6b162d7cf3772f
BLAKE2b-256 faa2a7c04b3e75871afa4e14c72608b3ae88ab7e333266e1bc60de08f765ec9b

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 39dcf28c8a1ca55adf4255e0b78e3de87c297199a3a6d98759f88fa6ab145bc3
MD5 5a4c68c22ccb17a86822541d8872dbdd
BLAKE2b-256 456460836df23b666b09732745da26ef39e508d9d9937bb968cf2278aea02aa6

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61e9fd19ed34cc136a0b74d11e2747d7c2939a2198a3ffe5f8df6540fb3bd696
MD5 03a386cfcf4ba9662367294eb5647df3
BLAKE2b-256 769a93b290bb5a36790d2c79f71f3ceb571ce84c8895bf4872465dd36b3635b0

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 94ec5847f0385119ceb0e87c3008d434a510fb4b4c141878c7f18e15d4c38958
MD5 07fa47252097b0be0bdefc68dedb56dd
BLAKE2b-256 5f5eefd9a79c7b4391687ab343e158854af2c820397d91820df398bde9cb2c4e

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e7bcd3f6c91cb5c4e2387d60b9c65fa8dc6943f2b3b01ae7d4385fe1004d7ca1
MD5 632ecfabdbe073183f26749336969393
BLAKE2b-256 c1319b20f6bf384b3b5f2c293e6e1c304686108498684ce7085b511db8b3e706

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e7efcf2d9c0ab120bc3f1872cdacaa0af98fb1556286ca5e5854c732735b764
MD5 569ffe648556e408785be2558322f36a
BLAKE2b-256 f3713c9330c16748c7f0302b8993a67532e6de5df31343462d8de56be108668f

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b057769f9f38c76071a3e56ccf73a3aff9b06db4a3f96a2cb73a23aba553b024
MD5 8d732d873fff37341ee738592beac3cb
BLAKE2b-256 4e1aeb37612e4303d9015c443e14aa9274b27c5594b2118d46091737272bb682

See more details on using hashes here.

File details

Details for the file chromobius-1.2.dev1727169923-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.2.dev1727169923-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7c1f879dde7e7beae948df74397f41d5b58082f6f50073a9d0e6f2de7bcdba72
MD5 c1262ed5311dd2b5782e61853eac0d9e
BLAKE2b-256 dae0ed2f733562ae772e06f0588560818806b42cb72bdde90ca1992e7e764a8a

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