Skip to main content

An implementation of ILP decoders for quantum error correction.

Project description

ILP Decoder

An implementation of the ILP decoder for circuit-level noise.

Included is a ilp_decoder.ILPDecoder class that is configured using a stim.DetectorErrorModel and decodes shot data, directly outputting predicted observables (without sinter), as well as a ilp_decoder.ILPSinterDecoder class, which subclasses sinter.Decoder, for interfacing with sinter.

Installation

To install from pypi, run:

pip install ilp_decoder

To install from source, run:

pip install -e .

from the root directory.

Usage

Here is an example of how the decoder can be used directly with Stim:

import stim
import numpy as np
from ilp_decoder import ILPDecoder

num_shots = 100
d = 3
p = 0.001
circuit = stim.Circuit.generated(
    "surface_code:rotated_memory_x",
    rounds=d,
    distance=d,
    before_round_data_depolarization=p,
    before_measure_flip_probability=p,
    after_reset_flip_probability=p,
    after_clifford_depolarization=p
)

sampler = circuit.compile_detector_sampler()
shots, observables = sampler.sample(num_shots, separate_observables=True)

decoder = ILPDecoder(circuit)

predicted_observables = decoder.decode_batch(shots)
num_mistakes = np.sum(np.any(predicted_observables != observables, axis=1))

print(f"{num_mistakes}/{num_shots}")

Sinter integration

To integrate with sinter, you can use the ilp_decoder.ILPSinterDecoder class, which inherits from sinter.Decoder. To use it, you can use the custom_decoders argument when using sinter.collect:

import sinter
from ilp_decoder import ILPSinterDecoder, sinter_decoders

samples = sinter.collect(
    num_workers=4,
    max_shots=1_000_000,
    max_errors=1000,
    tasks=generate_example_tasks(),
    decoders=['ilp'],
    custom_decoders=sinter_decoders()
    print_progress=True,
)

Advanced ILP solvers

You can use whatever ILP solver supported by cvxpy instead of the default one highs, though highs should be one of the fastest open-source solver available. If you have access to gurobi, you may gain some extra speed boost (not tested).

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

ilp_decoder-0.1.0.tar.gz (71.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ilp_decoder-0.1.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file ilp_decoder-0.1.0.tar.gz.

File metadata

  • Download URL: ilp_decoder-0.1.0.tar.gz
  • Upload date:
  • Size: 71.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for ilp_decoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b9b6bf65c79976ce6b379e39aec042f49db0b85d4f1fd905e6c9ca8b89bf5f8c
MD5 ce451da05638146295a7d3fb9859c8cd
BLAKE2b-256 ce19366fec5a5c745e9251e0cf8b1167a0b75e9de8d2eebd14e6b9c1e439ed23

See more details on using hashes here.

File details

Details for the file ilp_decoder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ilp_decoder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47ddb96ee269ba5c154decbe588a077b951568660fe88cb24523084a385a6f95
MD5 1b1e1ee149db557432804e5a3b12d68f
BLAKE2b-256 7a8e45ff1d8c27a55e5b09319a84268257204c39ca5b5429a3d2b2b71c8db1aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page