Qiskit Topological Codes
Project description
qtcodes
Qiskit Topological Codes
Installation
Conda users, please make sure to conda install pip
before running any pip installation if you want to install qtcodes
into your conda environment.
qtcodes
is published on PyPI. So, to install, simply run:
pip install qtcodes
If you also want to download the dependencies needed to run optional tutorials, please use pip install qtcodes[dev]
or pip install 'qtcodes[dev]'
(for zsh
users).
To check if the installation was successful, run:
>>> import qtcodes as qtc
Building from source
To build qtcodes
from source, pip install using:
git clone https://github.com/yaleqc/qtcodes.git
cd qtcodes
pip install --upgrade .
If you also want to download the dependencies needed to run optional tutorials, please use pip install --upgrade .[dev]
or pip install --upgrade '.[dev]'
(for zsh
users).
Installation for Devs
If you intend to contribute to this project, please install qtcodes
in editable mode as follows:
git clone https://github.com/yaleqc/qtcodes.git
cd qtcodes
pip install -e .[dev]
Please use pip install -e '.[dev]'
if you are a zsh
user.
Building documentation locally
Set yourself up to use the [dev]
dependencies. Then, from the command line run:
mkdocs build
Motivation
Quantum computation is an inherently noisy process. Scalable quantum computers will require fault-tolerance to implement useful computation. There are many proposed approaches to this, but one promising candidate is the family of topological quantum error correcting codes.
Currently, the qiskit.ignis.verification.topological_codes
module provides a general framework for QEC and implements one specific example, the repetition code. Qiskit Topological Codes builds out the qtcodes
module into a diverse family of QEC encoders and decoders, supporting the repetition code, XXXX/ZZZZ (XXZZ) rotated surface code, and the XZZX rotated surface code.
Inspired by the Qiskit Textbook, we've written a full set of jupyter notebook tutorials to demonstrate the circuit encoders, graph decoders, and benchmarking tools that compose Qiskit Topological Codes. These tutorials both demonstrate the elegance of QEC codes as well as the utility of this package -- please check them out!
Codebase
Topological QEC codes disperse, and thus protect, one quantum bit of logical information across many physical qubits. The classical repetition code distributes 1 bit of logical information across multiple imperfect physical bits (e.g. logical 0 is 000...0 and logical 1 is 111...1). In the classical repetition logical 0 bit, for example, a few physical bits may flip to 1, but the majority will very likely stay in 0, thus preserving the logical 0 bit. Similarly, the surface code protects one logical qubit in a grid of imperfect physical qubits against Pauli errors.
The qtcodes
module can be broken down into circuits
(encoders) and fitters
(decoders). Additionally, unittests can be found in tests
and benchmarking tools in qtcodes/tools
.
The rotated surface code is based on the earlier theoretical idea of a toric code, with periodic boundary conditions instead of open boundary conditions. This has been shown to be largely identical, but embedding a surface code on an actual device is much easier.
Circuits
The qtcodes.circuits
sub-module contains classes such as XXZZQubit
, XZZXQubit
, and RepetitionQubit
, which each allow users to construct and manipulate circuits encoding one logical qubit using a particular QEC code.
For example, we can create and apply a logical X onto a RepetitionQubit
as follows
from qtcodes import RepetitionQubit
qubit = RepetitionQubit({"d":3},"t")
qubit.reset_z()
qubit.stabilize()
qubit.x()
qubit.stabilize()
qubit.readout_z()
qubit.draw(output='mpl', fold=150)
qtcodes.circuits.circ
also allows users to create TopologicalRegister
s (treg: a collection of topological qubits) and TopologicalCircuit
s (tcirc: a circuit built using a treg), the analog of QuantumRegister
and QuantumCircuit
.
We can, for example, create a tcirc and treg out of two RepetitionQubit
s.
from qtcodes import TopologicalRegister, TopologicalCircuit
treg = TopologicalRegister(ctypes=[REPETITION, REPETITION], params=[{"d": 3}, {"d": 3}])
circ = TopologicalCircuit(treg)
circ.x(treg[0])
circ.stabilize(treg[1])
circ.x(1)
circ.draw(output='mpl', fold=500)
Learn more about circuits through encoder tutorials such as this one for the XXXX/ZZZZ rotated surface code.
Fitters
Topological codes aim to build better (read: less noisy) logical qubits out of many imperfect physical qubits. This improvement is enabled by decoding schemes that can detect and thus correct for errors on a code's constituent physical qubits.
The Qiskit Topological Codes package leverages Minimum-Weight Perfect Matching Graph Decoding to efficiently correct logical qubit readout.
For example, we can decode the syndrome hits in Fig 1 and fine the most probable error chains (data qubit flips) corresponding to these syndrome hits.
#d: surface code side length, T: number of rounds
decoder = RotatedDecoder({"d":5,"T":1})
all_syndromes = {"X": [(0,1.5,.5),(0,.5,1.5)], "Z": [(0,0.5,0.5),(0,1.5,1.5),(0,1.5,3.5), (0,3.5,3.5)]}
matches = {}
for syndrome_key, syndromes in all_syndromes.items():
print(f"{syndrome_key} Syndrome Graph")
error_graph = decoder._make_error_graph(syndromes,syndrome_key)
print("Error Graph")
decoder.draw(error_graph)
matches[syndrome_key] = decoder._run_mwpm(error_graph)
matched_graph = decoder._run_mwpm_graph(error_graph)
print("Matched Graph")
decoder.draw(matched_graph)
print(f"Matches: {matches[syndrome_key]}")
print("\n===\n")
In this way, Qiskit Topological Codes uses graph decoding to find and correct for the most probable set of errors (error chains).
The careful reader will notice that connecting syndrome hits in the most probable set of "error chains" does not uniquely specify the underlying physical qubits that underwent physical errors (i.e. there are multiple shortest paths between two syndrome hits). It turns out, by the nuances of how topological codes store logical information (i.e. codespace), in most cases the exact path across physical qubits doesn't matter when correcting for an error chain. Read more about this in this tutorial on Decoding for XXZZ Qubits!
Benchmarking
Finally, the efficiency and efficacy of the Qiskit Topological Codes package is demonstrated through benchmark simulations achieving threshold for the Repetition, XXZZ, and XZZX topological codes. Here, threshold is defined as the maximum physical error rate (i.e. imperfection level of physical qubits) below which larger surface codes perform better than smaller surface codes.
Explore the benchmarking tools and simulations to see how the graphs in Fig. 2 were created.
Future Directions
Checkout issues to see what we are working on these days!
Acknowledgements
Core Devs: Shantanu Jha, Amir Ebrahimi, Jeffrey Gong
Thanks to our mentor James Wootton (IBM) for invaluable feedback and support since the inception of this project at the IBM Qiskit - Summer Jam Hackathon 2020.
Thanks also to Matthew Treinish from the retworkx team for helping onboard and support this project.
Alums: Henry Liu, Shraddha Singh, Will Sun, Andy Ding, Jessie Chen, Aaron Householder, Allen Mi
References
Here's some reading material that we found particularly useful:
- Presentation slides and video about this package to the Qiskit Advocate community at the November 2020 Qiskit Advocate Demo Session.
- Surface Codes: Towards Practical Large-Scale Quantum Computation
- Stabilizer Codes and Quantum Error Correction
- Multi-path Summation for Decoding 2D Topological Codes
- Qiskit Textbook - Introduction to Quantum Error Correction using Repetition Codes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file qtcodes-0.2.0.tar.gz
.
File metadata
- Download URL: qtcodes-0.2.0.tar.gz
- Upload date:
- Size: 33.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e76ac6c4db91bc4740f2c0957d1ee60558e33113b396f9c785ccab1f43e3adf7 |
|
MD5 | f459ace24be99a3f5d4c2133e4ebde66 |
|
BLAKE2b-256 | 8ee25121ff9e0fa6e22ffccc47542e883b44fc41ef0f9bd08731fb9c2b345c67 |