Graph QEC is a Python package under development that provides tools for implementing Quantum Error Correction Codes (QECC) by constructing their Tanner Graphs, automatically compiling them into Stim circuits, and computing error correction thresholds. This package allows researchers and developers to explore quantum error correction techniques, simulate quantum codes under gate error models, and analyze their performance through error thresholds.
- Tanner Graph Representation: Visualize and analyze quantum error correction codes through Tanner graphs, a graphical representation that simplifies the understanding of code structure and error syndromes.
- Stim Circuit Compilation: Automatically compile Tanner graphs into Stim circuits, enabling easy integration with simulation tools for error correction and noise analysis.
- Threshold Computation: Compute and analyze the error threshold of a quantum code, which indicates the error rate at which the code remains fault-tolerant.
- Repetition Code
- Shor Code (in progress)
- Rotated Surface Code
- Bivariate Bicycle Code (in progress).
Since Graph QEC is not yet available on PyPI, you can install it by cloning the repository directly from GitHub:
-
Clone the repository:
git clone https://github.com/adelshb/graphqec cd graphqec
-
You can then install the package by running:
pip install .
This will install the package in your local environment. Once installed, you can use it to generate Tanner graphs, compile Stim circuits, and compute error thresholds.
from graphqec import RotatedSurfaceCode
# Initializaze the graph
rot = RotatedSurfaceCode(distance = 5)
rot.draw_graph()
from graphqec import RepetitionCode
# Initializaze the graph
rep = RepetitionCode(
distance = 5,
depolarize1_rate = 0.05,
depolarize2_rate = 0.05
)
# At this stage the Stim circuit is built
rep.build_memory_circuit(number_of_rounds=2)
rep.memory_circuit.diagram()
from graphqec import RepetitionCode, ThresholdLAB
# Initialize the Threshold LAB instance
th = ThresholdLAB(
distances= [3, 5, 7, 11],
code=RepetitionCode,
error_rates= np.linspace(0, 0.1, 10)
)
# Sampling and estimating logical error rates via Monte Carlo
th.collect_stats(num_shots=10**4)
# Plotting the collected statistics
th.plot_stats(
x_min = 3e-2,
x_max = 1e-1,
y_min = 1e-3,
y_max = 5e-1
)
Pull requests and issues are more than welcomed. We welcome contributions from anyone. Please visit CONTRIBUTING.md for details.