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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 macOS 11.0+ ARM64

chromobius-1.1.0-cp312-cp312-macosx_10_15_x86_64.whl (928.9 kB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

chromobius-1.1.0-cp311-cp311-macosx_10_15_x86_64.whl (927.8 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

chromobius-1.1.0-cp310-cp310-macosx_10_15_x86_64.whl (927.7 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

File details

Details for the file chromobius-1.1.0.tar.gz.

File metadata

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

File hashes

Hashes for chromobius-1.1.0.tar.gz
Algorithm Hash digest
SHA256 085ebd50bf897df63076e6dfe89cde20afc412260d7462c0415735ee0a8eb338
MD5 661dbeb6957aedb0262bf815ace04f64
BLAKE2b-256 aba1e10b3af5027163bcfee7351f596025fbeb246def21f843c02596d24f95b8

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58d947cc3a11e072ab36e2f0053d69e41a83231954ea5f38ef1c8c6f5eedd5c2
MD5 67399082745edaa27ecb4e425c8d8a50
BLAKE2b-256 a9b543c260d3bcd04a27d87ad197a2d342dcd720614f473f13055787f96c9e09

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f9bc1594100420f43cfa9ee7f904cd931b84a99e999074bcfddc4c797d5ada8
MD5 d2c240bd66967645c4e245a6fa8a8223
BLAKE2b-256 d9120f6119e8a9a77244b9be0fb02848b6f08f31d80fe1ebe0b21fe32412115d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9db402694e1ffc813dddb37fddd74c74dc15b68fa1813860f4e2b3b170253995
MD5 af4956f84ebb1d15873b23e2930bd6d7
BLAKE2b-256 10bf6258e3e23ebce4f611239330caeaea7370601fd8dbcf7ffa0d1a559ab6fd

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 029898b0e9caf878fc01d64cd08972df180334643f4f6f3263129cb0ba1e1bf9
MD5 ae8b7a5acae42e50f81783ef25d950f2
BLAKE2b-256 0a5e97785ca9b02a7c577cb2e5aa2d93077aadc06fc39dfc07a67e1882225f56

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02739e862b15ff908c5ac2379cfb2431c277c60c271094713f488143ed55cbbb
MD5 f748bc47ec260d12e62cabc1202133d2
BLAKE2b-256 48f756248b552d741d824059be7eae9f7eabb23e6004e5834f16469897535c99

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a789e17a8e2c4ed2c59137f2818a22bd5451993581fca7e7eb9ff52aa92aaf8d
MD5 ba9537588ed9917379267907672270b1
BLAKE2b-256 846a1e0ed815cebfb195f22ee0f7022e31061739432cedb862e40734019c095d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d5800d0b7c2d97ea943481ca741a7bd60dcaddc01dc1984aa6e29b1f07ad6c4
MD5 173f4cce7947a530bf867ddb8d41c81a
BLAKE2b-256 0cae25459673ca074fff4ac082ff0214d1cdb41a310b0319694eededd500585f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25009231fe0425e6cc45051742abdaca7d012d470b1b813becdaeb08e1671de9
MD5 ab430e0d363c60d9a2312b5cd81145ea
BLAKE2b-256 4e2139a91d17172da331cc2b031c0517364d3c224d2aa2bfcd57ed1df57fceee

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for chromobius-1.1.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7c1b24ce858bedac9c42b3088b6514dce39adbc739c53ead49d7433345a260c4
MD5 7050862a3bb206cdb4f8d1a7c7208e84
BLAKE2b-256 cd395b9a7cd01cc265e918ebac79df684a196e18c09921bf1424ecf7ff4ad17f

See more details on using hashes here.

Provenance

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