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.dev1702554066.tar.gz (53.5 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromobius-1.0.dev1702554066-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.dev1702554066.tar.gz.

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066.tar.gz
Algorithm Hash digest
SHA256 83b356cc01d0c288346961f565b9b055e5584277e2449089f9bf48c51286c62f
MD5 17f23be765bf51999d5fa074bd0a446c
BLAKE2b-256 4de8482a7ace1b355b046117db96a66337bfeb00e691a0468aa9442b06fbcce1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5493213820a6a6a86bc6cf41b9f354e174150b113497685984776ece3bb1518b
MD5 4020d3e461cf7c9dda98de50c1180c2b
BLAKE2b-256 99c1a13102b5ba92f55eec48095575be5853c9c880e538f6140d03fe1034373a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 688d1ca0b2aea3e2b56e7006792e27ce3a98ef64078d75f20221d279cdefc4b0
MD5 6c8a26a169fc5bde157f7cfcbc741d6e
BLAKE2b-256 029c8cd032e8c23f31267e43a08fc83d28095d8df24676146d2882e3cd3d315e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5c0a3f292db386cf005d05827bca16f98927d7058f0c65a11673a4e7bd6c0921
MD5 cf00728d50bdf4860bba391423d6bebc
BLAKE2b-256 12392057fc08741d50ffc8e4f32c6979724a51f0f3b75a205af3cfff95ae6cd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa766d54a39a234f472f26d07d249a826f1291abadeee3041479d119a9ba4ed0
MD5 1675a6610410759a31b2fa2983693ee3
BLAKE2b-256 6dee178ef5a84fe5c9b86d653584fb791256b1fa0a840e97841e02f85979f9aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe711efb7e82defdc1d1f36ff22d73b8fa052e9a8f1ac11b86b0512ea0e8ea93
MD5 23d6a7c46f265b5283595e5ed94aa744
BLAKE2b-256 430218389f8eeb8650027b1460fc46370555de0c8d6a4b6619eeaa454ec0d4bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 885ffbdcc5bc9c71de3ca97e707aa1a4ae2f659cc7b1a2cd041c054595834c31
MD5 c36aaa86b310c5f538d00e0b85d73228
BLAKE2b-256 8608e8a647abb4b0d52616e13252e733bf517e9d3271a129ec8df7574cd4ef62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 04c06186510399319025d52ef919ed6ce157bbf3c8982e2182c91f4159c8e357
MD5 216f382ac5ac7adee57c27d67e889eff
BLAKE2b-256 0b2a77ceb453aac9fc9aa7e8404fa74452648da1195161cd128985c385c1b480

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a968a658b7ba32637419a3457e2746a90ea042af413e9ea6256ac65e59dce17e
MD5 300abf614afd892feee8fb0277723edd
BLAKE2b-256 542e56feb493b1aac1731ab4728f1cdfa2661be6947a7182ab030e37f861b993

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chromobius-1.0.dev1702554066-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8e1d80abe4133c3265bad9a2e284dea68815acc09121dce7f8653607fea67e84
MD5 adccd2923141eb5a61dc3b9c96efd253
BLAKE2b-256 107eee357f8ef630fb7ce0956fc0349ac28ff047f33fe66ff6371e001420e9ed

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