Skip to main content

Python Tools for Quantum Error Correction

Project description

qec_banner

QEC: Python Tools for Quantum Error Correction
Website · Features · Installation · Examples

Features

Base functionality: code constructions and "fundamental" analysis

We currently provide the construction methods for the stabilizer generators of the QEC code families below, along with optimized methods to obtain their fundamental properties. All the classes allow you to:

  • obtain the physical qubit count
  • obtain the logical qubit count
  • calculate the exact code distance
  • estimate the minimum code distance
  • obtain a logical basis

The classes (along with their extra methods) are:

  • Hyperprgarph Product (HGP) codes, with methods:

    • construct the x and z stabiliser matrices from the seed codes
    • obtain the canonical basis (work in progress)
  • Surface codes

    • Unrotated Surface code
    • Periodic Surface XZZX code
    • Rotated Surface XZZX code
  • Toric code

  • Calderbank-Shor-Steane (CSS) codes

    • check that the seed codes satisfy the CSS criteria
  • Stabiliser codes

    • check that the input stabiliser matrix is valid

Circuit compilation

Note: this functionality is still work in progress. The corresponding code is not part of the main branch - you can find it on the circuit_compilation branch to play around.

Currently we only support circuit compilation for memory experiments of:

  • HGP codes with:
    • "coloration circuit" stabilizer schedule (twice the depth of the most optimal "cardinal circuit" method)
    • under development: "cardinal circuit" stabilizer schedule

One can either compile noisy or noisless circuits (for further compilation to one's own needs). To create a nosiy circuit one needs to construct their own noise model, or use one of the available presets:

  • uniform_depolarizing_noise
  • non_uniform_depolarizing_noise under development
  • phenomenological_noise

For a more detailed example please see the demo.ipynb notebook, inside the demo/ folder of the circuit_compilation branch.

Installation

Simply do:

pip install qec

or obtain a local copy of the package by cloning it, then navigate into the created folder:

git clone git@github.com:qec-codes/qec.git
cd qec

Finally, install the package:

pip install -e .

Examples

Base functionality:

In this example we are going to create the Steane code, and obtain its fundamental code properties. We start by initialising its seed matrices (the [7, 4, 3] Hamming code):

In [1]: import numpy as np
In [2]: from qec.code_constructions import CSSCode

In [3]: hamming_code = np.array([[1, 0, 0, 1, 0, 1, 1],
                                 [0, 1, 0, 1, 1, 0, 1],
                                 [0, 0, 1, 0, 1, 1, 1]])

as the Steane code is part of the CSS code family, we can use the CSSCode class:

In [4]: steane_code = CSSCode(x_stabilizer_matrix = hamming_code,
                              z_stabilizer_matrix = hamming_code,
                              name = "Steane")
In [5]: steane_code.compute_exact_code_distance()
In [6]: print(steane_code)

Out [7]: Steane Code: [[N=7, K=1, dx<=3, dz<=3]]

we can see that all the fundamental properties (N - physical qubit number, K - logical qubit number, dx - X distance, dz - Z distance). We can continue our analysis by taking a look at the x and z logical basis of the code:

In [7]: print(steane_code.x_logical_operator_basis.toarray())
Out [8]: [[1 1 0 1 0 0 0]]
In [9]: print(steane_code.z_logical_operator_basis.toarray())
Out [10]: [[1 1 0 1 0 0 0]]

Circuit compilation:

In [10]: from qec.code_constructions import HypergraphProductCode
In [11]: from qec.circuit_compilation import MemoryExperiment

In [12]: hgp_example_code = HypergraphProductCode(hamming_code, hamming_code)

In [12]: hgp_memory_example = MemoryExperiment(hgp_example_code)

In [13]: hgp_X_mem_circuit = hgp_memory_example.circuit(basis = 'X', rounds = 1, noise = False)

To see the output circuit and a more detailed example (including a simulation) see the demo.ipynb notebook, inside the demo/ folder of the circuit_compilation branch.

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

qec-0.3.3.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

qec-0.3.3-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file qec-0.3.3.tar.gz.

File metadata

  • Download URL: qec-0.3.3.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for qec-0.3.3.tar.gz
Algorithm Hash digest
SHA256 3c248989c9fdd297cfcf243b6ce5c0d9bfbe77a52ac251aa4a7bb015c8b14372
MD5 5c3638b9254e7c9b16e1563b3a8b5f70
BLAKE2b-256 f451fcd04da011136d73b12504b664e2627ea4e896e76e409849e372bf243730

See more details on using hashes here.

File details

Details for the file qec-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: qec-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for qec-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b2efeebeacc0f0a94907002cde19dec3c225931c3b2d8c371410b74dd2d4389
MD5 68a1283ea765b922ceb12083fdded220
BLAKE2b-256 e36706e335cc30019c28bf0513656740e3212a27b34dd2bba1249793024e3d24

See more details on using hashes here.

Supported by

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