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.0.dev1702552176.tar.gz (53.3 kB view details)

Uploaded Source

Built Distributions

chromobius-1.0.dev1702552176-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-1.0.dev1702552176-cp312-cp312-macosx_11_0_arm64.whl (838.0 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromobius-1.0.dev1702552176-cp312-cp312-macosx_10_15_x86_64.whl (887.5 kB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

chromobius-1.0.dev1702552176-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-1.0.dev1702552176-cp311-cp311-macosx_11_0_arm64.whl (837.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromobius-1.0.dev1702552176-cp311-cp311-macosx_10_15_x86_64.whl (885.9 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

chromobius-1.0.dev1702552176-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-1.0.dev1702552176-cp310-cp310-macosx_11_0_arm64.whl (837.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromobius-1.0.dev1702552176-cp310-cp310-macosx_10_15_x86_64.whl (885.9 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

File details

Details for the file chromobius-1.0.dev1702552176.tar.gz.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176.tar.gz
Algorithm Hash digest
SHA256 e9bf6fe6ff52e8a2f0ff2f6c0a0530ac9baea26cec88c0bc4538e6a1cff0d3be
MD5 75a6c6ee44e21047c85605b91ef0c999
BLAKE2b-256 813863893d22b5b14676557d56356bd1e44b24fec71cafe996a40ca06681271c

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4655ecc4c71cc82769cc551a1a7b44f9c60c322e999c92969736bb58ff51e67
MD5 26a70524843efde2369d058b49cf0d90
BLAKE2b-256 e3a0c10bcc23ca338203d77a2ffdd9a58445e440df704c538b8a72e40156df7f

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fbad3c3f607a75be82bcdae74a2ce6b93ecb0d65230319516d9589d3fea08151
MD5 56525409b4fb60ade8cbfbb37bf3cc60
BLAKE2b-256 9d3eacb774dfbfe920676d68ea206210147a9a53442cb6ed69f2f575762a76d5

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d14e2b4403e277f324a6e7a6ae68190221523ef26651a0d5f73a8a0fea87a0b6
MD5 8a9ec179e4608767ffdcfd9e41e0fe7e
BLAKE2b-256 64656b653ef52db9fed250122a3af1a0bad377327fafa0382716ae5bb851f06e

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc7ba4482b009293964788400af2add60f2a396880cba753e2cecc9c0d557c06
MD5 4d44153d82d95e4988ad50c30af49982
BLAKE2b-256 279b73fb7e83ae63ced80626ccf3a9ca46a587c7578c1dd5aa6741ebf39ca74b

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78ee3724923ac5f67a4a245c122893d31d872102082edf7248ad2d588cd08219
MD5 c6803f72697ac133794828be76cbcb02
BLAKE2b-256 49c3f6527a4b76c4a322d6a60c2bd5d5d6f06080c8f448899279810d163901b8

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5ee7923a46866d5dbd65cc09667ef3d235230197ad50058b69b0bd742c088bed
MD5 b90137842f87885ce14f0816deeb97cd
BLAKE2b-256 5742e47d437787e70a688cc58dca4b946a0e1935a6a413bfc3f790c975ff03f5

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6d017d49cee8a62f1f43bf18649e5639efdc7b3375184818d71f886954881ba2
MD5 b64edc6b22a31edfcc3e265050743b3d
BLAKE2b-256 25d669891d50d96f8895dc69a12528b9781823a4e29754ae24b2ceba8db63f9c

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cc169ea6ec9ae4dd1e6890c677d4d1bb80f8d9043afb79d7d70e7162e4ad3f6
MD5 5d789be47d0ff1649a8c7e076fba4e4c
BLAKE2b-256 9f8de1c0eefeac3053b4ac1b2ae19a34697497cf69c3ad44c657ad7729fafc99

See more details on using hashes here.

File details

Details for the file chromobius-1.0.dev1702552176-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702552176-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7b9dec545b03a1452fd2a386a125c1c8fb4cd46a87d9c89624a90d88c734faf5
MD5 c99ab0330278bd582cdca4773f458278
BLAKE2b-256 5c6ba78a6721b53380df8a5aa8ad797d8182c9d8a4b5e4ea1be4b954b13e0598

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