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

Uploaded Source

Built Distributions

chromobius-1.0.0-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.0-cp312-cp312-macosx_11_0_arm64.whl (837.9 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromobius-1.0.0-cp312-cp312-macosx_10_15_x86_64.whl (887.4 kB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

chromobius-1.0.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (837.4 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromobius-1.0.0-cp311-cp311-macosx_10_15_x86_64.whl (885.8 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

chromobius-1.0.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (837.4 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

File metadata

  • Download URL: chromobius-1.0.0.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for chromobius-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e5228c5099dc842a999fb4a0ca2653a43ad00d19ed7c958664c2985ec84793f5
MD5 0d81708bd931772649b582c5446c231d
BLAKE2b-256 49233203de13bde4319e0c702d3b3ebce164f0fa95950d403abcf87f45463299

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64c6d9993d9e10c0fa9979a68b02cd58774382ee41aaa855fa0ccc9cae28fff4
MD5 3277ab64e2ee7cc65e9534bd1396d9ff
BLAKE2b-256 19eb0bdd8e3c2a43da4de16932d4acd4a1b9bd8acec88ba24aa5a46739bf1b5f

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ac121f4d356bd2948db820ad2740282c9fdb60b8c09977d35c0f772d93b9544
MD5 42b741c993b4591e363ef7c5a48ba325
BLAKE2b-256 d15ebed073790ca4904cb75efd8fb550755c78c31b5a0d5ddaeca200f884f0a7

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9653aad5e3733d86fe536b2c8cec3041b1028b1673f492bad8ff48990f39d373
MD5 b9c4a36f242b616766da1a8bd83b00d2
BLAKE2b-256 5d886fd3d2dd2ba3fa236781f3d5a259520ede6f7ce9fc2c4445b9a3f4b42741

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57240ca53d355ca1ee33ce583ad319cc7bd27ce8a21a3625ea5fb4304c98bde2
MD5 8741338de1f6b6303bf543189a1bb034
BLAKE2b-256 1c7e40b0394f366391147dd69b8133a031ff0ea4f6ed3e9de4d20f61c3a43ec5

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e59ed1fb9c7fb3ddfff240f44c515fd8f77fdb657bb86e96efb83f749b94eb5
MD5 e559558f2608b52ef6c13acb011028b9
BLAKE2b-256 400d106a546b826620288c645b426149a483e1aa9a1cfe4dc6c24c661192bd9f

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2201a75439c92427433519445fc53db1029405347356127245d6071954bf7137
MD5 e507fc5f6665e5efd5a37f2aadcb88c9
BLAKE2b-256 676464ec3d5b757abe65325d6552730c731375d69df3d726ed0f6b245e2cd87b

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44d62178f38dc10f87b2c1b52ac0c69ee63ffeba85a523a648f6f755fe5c5f1b
MD5 073427c56184ba08449095b3f0a47a34
BLAKE2b-256 7019bd431e8f4b5b78a14dc94b5bcbf380fd461232103bfb3b1ba65851dd7c42

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 972054fd50bb7a70364a04e4d609cdefa9731ce9d80d2cbc709b0c7fb4485f20
MD5 eb172a9f63410a450f44fe7aea512b9b
BLAKE2b-256 8ec58edd2abc0d98ea387ce116827724a3173f07bf461109541d7eb562465073

See more details on using hashes here.

File details

Details for the file chromobius-1.0.0-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for chromobius-1.0.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9a1d06bf681c0bf4477d2376cc38222795aeed1a41b2f87b2044bd3308707901
MD5 08d8cc0db93a2aa4c2c8b5e9d7c34672
BLAKE2b-256 ee570f7051e74a1095b2bd09ffb73e2de25bdc3916a4fd232b79eeb239a70f66

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