Skip to main content

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.

Metadata

Release files for qec 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qec 0.3.3
File Size Uploaded
qec-0.3.3.tar.gz 37.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qec 0.3.3
File Interpreter ABI Platform
qec-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 80.6 kB

Release files / qec-0.3.3.tar.gz

Download URL qec-0.3.3.tar.gz
Size 37.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3c248989c9fdd297cfcf243b6ce5c0d9bfbe77a52ac251aa4a7bb015c8b14372
BLAKE2b-256 checksum
How to use checksums
f451fcd04da011136d73b12504b664e2627ea4e896e76e409849e372bf243730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / qec-0.3.3-py3-none-any.whl

Download URL qec-0.3.3-py3-none-any.whl
Size 43.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b2efeebeacc0f0a94907002cde19dec3c225931c3b2d8c371410b74dd2d4389
BLAKE2b-256 checksum
How to use checksums
e36706e335cc30019c28bf0513656740e3212a27b34dd2bba1249793024e3d24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

1 release file

0.3.0

1 release file

0.2.9

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1

1 release file

0.0.11

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page