跳转到主要内容

Mobius颜色码解码器的快速实现。

项目描述

Chromobius:颜色码解码器

Chromobius是一个"Mobius解码器"的实现,将颜色码解码问题近似为最小权重匹配问题。Chromobius使用PyMatching来求解最小权重匹配问题。

有关Chromobius工作原理的更多详细信息,请参阅((论文《新的电路和开源的颜色码解码器》))。

如何使用Chromobius

请参阅入门笔记本

还可以查看Python API参考

希望编辑和构建Chromobius的程序员可以查看开发者文档

示例片段

使用Chromobius解码一帧

从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))

从命令行

# 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

使用sinter从Python

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,
)

使用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" \

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。

源分布

chromobius-1.1.0.tar.gz (55.6 kB 查看哈希值)

上传于 来源

构建的发行版

chromobius-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB 查看哈希)

上传于 CPython 3.12 manylinux: glibc 2.17+ x86-64

chromobius-1.1.0-cp312-cp312-macosx_11_0_arm64.whl (866.3 kB 查看哈希)

上传于 CPython 3.12 macOS 11.0+ ARM64

chromobius-1.1.0-cp312-cp312-macosx_10_15_x86_64.whl (928.9 kB 查看哈希)

上传于 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 查看哈希)

上传于 CPython 3.11 manylinux: glibc 2.17+ x86-64

chromobius-1.1.0-cp311-cp311-macosx_11_0_arm64.whl (865.4 kB 查看哈希)

上传于 CPython 3.11 macOS 11.0+ ARM64

chromobius-1.1.0-cp311-cp311-macosx_10_15_x86_64.whl (927.8 kB 查看哈希)

上传于 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 查看哈希)

上传于 CPython 3.10 manylinux: glibc 2.17+ x86-64

chromobius-1.1.0-cp310-cp310-macosx_11_0_arm64.whl (865.5 kB 查看哈希)

上传于 CPython 3.10 macOS 11.0+ ARM64

chromobius-1.1.0-cp310-cp310-macosx_10_15_x86_64.whl (927.7 kB 查看哈希)

上传于 CPython 3.10 macOS 10.15+ x86-64

由以下赞助

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面