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

Uploaded Source

Built Distributions

chromobius-1.1.dev1702557791-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.1.dev1702557791-cp312-cp312-macosx_11_0_arm64.whl (838.0 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromobius-1.1.dev1702557791-cp312-cp312-macosx_10_15_x86_64.whl (887.3 kB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

chromobius-1.1.dev1702557791-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.1.dev1702557791-cp311-cp311-macosx_11_0_arm64.whl (837.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromobius-1.1.dev1702557791-cp311-cp311-macosx_10_15_x86_64.whl (885.9 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

chromobius-1.1.dev1702557791-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.1.dev1702557791-cp310-cp310-macosx_11_0_arm64.whl (837.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromobius-1.1.dev1702557791-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.1.dev1702557791.tar.gz.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791.tar.gz
Algorithm Hash digest
SHA256 f85a4d3dacbb6ace61244ab83f27497a2ce60f18b0cef693901ff34d06675fd6
MD5 291767d8a6e7db3fd27a45e1249226d7
BLAKE2b-256 2a36b1b67235709da78a097d0d24f411d8fb50cdefa0c6b17489cf6ac0463220

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b5e2aa0d3006e7f2798f2fa007aad070c4804bebe35c3b5af7014353f8f282a
MD5 f797c3d329f89c91af5988043c7dec8f
BLAKE2b-256 defc1684b3c1faa92cffaa4bff804015d99297ce15d22c0bb09c3544c07e942a

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 68e71b5183baf8745a299612cb287ab549ce19003c8ecf0ec80121b7034d2aeb
MD5 b2a4336cbe0e3575364bb16979abc6b8
BLAKE2b-256 82539f47608ae1c702bb6790415b7f863ce936df674601ba52f737724382cc5c

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6b3356621b50355215cb09655ff3a2042bd0bc859ec3b73d1851eb965d7f6838
MD5 42c6096d64b38a599b6ce067295f3e8b
BLAKE2b-256 89d58b9725c38c7b47f7baa2b031c038490f5994a01f6a05e9729a9a52e47902

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ece39e1d329915e9d606947dbab9c62f83609cf6c0db7f45e3dd3e34224813d
MD5 a42c1a58f7462a8e1b569a7a8374242b
BLAKE2b-256 45966e0cb2a7eb78126148ce3a03489178498d41266abc8fcff6ede289ca2501

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0dbff651d767c1af52755f1ae370e8f3b104a8c5aa9810f1e554d52002ee915b
MD5 81e72a9e3a6989a264dd018bf7dab5a8
BLAKE2b-256 0653f861beb9ab39716c6e6e431f60c7ce46525bc82ed8db1a4372d98435d710

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2b97c959171e4ad82f8a8acc1110d51d124dae63370b7957bee15d75d79d0eed
MD5 0afe847c49053b6ffab05b93eb7e83be
BLAKE2b-256 dd79b02f8ae1a04b0c00333e2659c4d5438a6b0f0b21dfb5f6fd31f52868b836

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8aad8e813cece3cd081fac46fafe0c3519d1b24b82a4d09467c0d04e93d998da
MD5 3df25e22fa6368c0a65e8d6b02c96e29
BLAKE2b-256 ee5ea622bc56a243a24bf263fa44e2a60aaec484673275d9004c357097016e7e

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec182b354c03d372a360b5fc0c02048f68cff37e5b36861ed83bb65498a7d60d
MD5 cb0e3d8b5271495efc0a1497000533c9
BLAKE2b-256 cc6004cf0baf46d7b5f7b6a51276eccaef3f13f84044250f56eb06b07dc4960a

See more details on using hashes here.

File details

Details for the file chromobius-1.1.dev1702557791-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.1.dev1702557791-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 47509a8284161a346f6d1205b981e4b4f5bb772f14788de99b49c6d777a248f7
MD5 113c43d16dd2c9b889f57ad7c9b80556
BLAKE2b-256 6888731c3e8094e2e4e3938bd6bc90aa6da7d091fc7a3886c3495bfe82c5929a

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