Skip to main content

No project description provided

Project description

https://github.com/qc-design/plaquette-unionfind/actions/workflows/tests_linux.yml/badge.svg https://github.com/qc-design/plaquette-unionfind/actions/workflows/tests_windows.yml/badge.svg

About

The Plaquette-UnionFind plugin extends the Plaquette error correction software, providing a fast unionfind decoder written in C++. See the Benchmarks section for a comparison to other known decoding packages.

Installation

The basic dependencies for installation are cmake and ninja.

The C++ tests/examples and python bindings can be built independently by

cmake -Bbuild -G Ninja -DPLAQUETTE_UNIONFIND_BUILD_TESTS=On -DPLAQUETTE_UNIONFIND_BUILD_BINDINGS=On
cmake --build ./build

You can run the C++ backend tests with

make test-cpp

You can install just the python interface with (this quietly builds the C++ backend):

pip install -r requirements.txt
pip install .

or get the latest stable release from PyPI

pip install plaquette_unionfind

You can run the python frontend tests with

make test-python

Usage

Python Frontend

import plaquette_unionfind as puf
import plaquette_graph as pg

vertex_boundary = [False] * 12 + [True] * 8
edges = [(0, 12), (0, 1), (1, 2), (2, 13), (0, 3), (1, 4), (2, 5), (3, 14), (3, 4),
         (4, 5), (5, 15), (3, 6), (4, 7), (5, 8), (6, 16), (6, 7), (7, 8), (8, 17),
         (6, 9), (7, 10), (8, 11), (9, 18), (9, 10), (10, 11), (11, 19)]
syndrome = [False, False, True, True, False, True, True, False, True, False, True,
            False, False, False, False, False, False, False, False, False]
dg = pg.DecodingGraph(num_vertices, edges, vertex_boundary)
uf = puf.UnionFindDecoder(dg)
correction = uf.decode(syndrome)

C++ Backend

#include "DecodingGraph.hpp"
#include "UnionFindDecoder.hpp"

int main(int argc, char *argv[]) {

    using namespace Plaquette;
    //a vector storing a flag that is 1 if the vertex is on the boundary
    std::vector<bool> vertex_boundary = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                         0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
    std::vector<std::pair<size_t, size_t>> edges = {
        {0, 12}, {0, 1},  {1, 2},   {2, 13}, {0, 3}, {1, 4},  {2, 5},
        {3, 14}, {3, 4},  {4, 5},   {5, 15}, {3, 6}, {4, 7},  {5, 8},
        {6, 16}, {6, 7},  {7, 8},   {8, 17}, {6, 9}, {7, 10}, {8, 11},
        {9, 18}, {9, 10}, {10, 11}, {11, 19}};

    std::vector<bool> syndrome = {false, false, true,  true,  false, true,  true,
                                  false, true,  false, true,  false, false, false,
                                  false, false, false, false, false, false};

    auto decoding_graph = DecodingGraph(vertex_boundary.size(),
                                      edges, vertex_boundary);
    UnionFindDecoder decoder(decoding_graph);
    auto correction = decoder.Decode(syndrome);
}

Interface to Plaquette

Plaquette is undergoing heavy development, so this interface is likely to change. If you are benchmarking our decoder, please do not use the plaquette interface unless you know what you are doing. You will be timing other computations unrelated to the decoding.

from plaquette.codes import LatticeCode
import plaquette_unionfind

    code = LatticeCode.make_planar(n_rounds=1, size=size)
    qed = {
        "pauli": {q.equbit_idx: {"x": error_rate} for q in code.lattice.dataqubits}
    }
    decoder = plaquette_unionfind.UnionFindDecoderInterface.from_code(code, qed, weighted=False)

Benchmarks

For our benchmarks, we have been careful to only time the intrinsic Pymatching-v2 and FusionBlossom decoding functions. We do not use the decode_batch function for Pymatching-v2 because this does not test the intrinsic speed of the decoder. We also set FusionBlossom to single-threaded mode since we are running both our code and Pymatching-v2 in that mode. All benchmarks are performed on a m6id.4xlarge AWS node. All benchmarks are reproducible (see below) using our scripts on a m6id.4xlarge.

For our first benchmark, we use the 2-D (perfect measurement) Planar Code with p = 0.05 depolarization error. We see around 8-10x speedup over competitors

https://github.com/qc-design/plaquette-unionfind/blob/40fb8fab11ad60e281089e3b0b26865c899749cb/benchmarks/perfect_planar_0.05.png?raw=true

For our second benchmark we use the 3-D (imperfect measurement) Rotated Planar Code with p = 0.01 depolarization error and p = 0.01 measurement error. We see that Pymatching-v2 is much more sensitive to the lattice size.

https://github.com/qc-design/plaquette-unionfind/blob/40fb8fab11ad60e281089e3b0b26865c899749cb/benchmarks/imperfect_rotated_planar_0.01.png?raw=true

Finally we benchmark a 30x30 Rotated Planar Code (29 rounds of measurement) with varying probability. We see that fusion-blossom is heavily sensitive to the error probability.

https://github.com/qc-design/plaquette-unionfind/blob/40fb8fab11ad60e281089e3b0b26865c899749cb/benchmarks/imperfect_rotated_planar_fixed_size.png?raw=true

To run all three benchmarks, use the following bash commands:

source benchmarks/run_perfect_planar_benchmark.sh 0.05
source benchmarks/run_imperfect_rotated_planar_benchmark.sh 0.01
source benchmarks/run_imperfect_rotated_planar_fixed_size_benchmark.sh

python plot_benchmark_1.py perfect_planar_0.05.dat perfect_planar_0.05.png "Surface Code Benchmark #1" 5
python plot_benchmark_2.py imperfect_rotated_planar_0.01.dat imperfect_rotated_planar_0.01.png "Surface Code Benchmark #2" 5
python plot_benchmark_3.py imperfect_rotated_planar_fixed_size.dat imperfect_rotated_planar_fixed_size.png "Surface Code Benchmark #3" 1

Documentation

To generate the documentation you will need to install graphviz and doxygen. Then run

pip install -r doc/requirements.txt
make docs
firefox ./doc/_build/html/index.html

Here is a live link to the documentation: https://docs.plaquette.design/projects/unionfind

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

plaquette_unionfind-0.0.1a1-cp311-cp311-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

plaquette_unionfind-0.0.1a1-cp311-cp311-musllinux_1_1_x86_64.whl (635.9 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

plaquette_unionfind-0.0.1a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (113.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

plaquette_unionfind-0.0.1a1-cp311-cp311-macosx_10_9_x86_64.whl (83.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

plaquette_unionfind-0.0.1a1-cp310-cp310-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

plaquette_unionfind-0.0.1a1-cp310-cp310-musllinux_1_1_x86_64.whl (635.9 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

plaquette_unionfind-0.0.1a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (113.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

plaquette_unionfind-0.0.1a1-cp310-cp310-macosx_13_0_arm64.whl (87.9 kB view hashes)

Uploaded CPython 3.10 macOS 13.0+ ARM64

plaquette_unionfind-0.0.1a1-cp310-cp310-macosx_10_9_x86_64.whl (83.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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