SurfQ
SurfQ is a Python framework for efficiently simulating surface codes under noise. The aim is to enable detailed investigation of the behavior of surface codes under different physical error models, supporting advanced fault-tolerant protocols such as lattice surgery, state injection, and magic state distillation as future extensions.
License
This project is released under the GNU Affero General Public License v3.0 (AGPL-3.0) or later.
Please see the LICENSE file for the full text of the license.
Features
- Intuitive surface code representation
- Apply quantum operations: X, Z, H, CNOT, and syndrome measurement
- Simulate various noise channels: Pauli noise, depolarizing, bit-flip, phase-flip errors
- Analyse logical error rates and syndrome measurement statistics for error correction
- Modular and extensible framework for surface code simulation and fault-tolerant quantum protocols
Usage
This package is available on PyPi. To use it you can simply install on your environment with pip:
pip install surfq
Alternatively, if you are using uv package manager, you can get started by simply:
uvx juv init notebook.ipynb
uvx juv run notebook.ipynb --with surfq
Then to get started in python:
from surfq import Lattice
l = Lattice(5)
l[1,1:4].X()
l.show()
Examples
This project contains a set of example scripts to experiment with. We recommend using uv for seamless dependency management.
- Decoding Test 1: This script showcases a successful example of the current in-progress work on decoding error syndromes.
uv run examples/decoding_1.py
- Decoding Test 2: This script showcases a wrong example of the current in-progress work on decoding error syndromes.
uv run examples/decoding_2.py
Notebooks
This project contains a set of notebooks to experiment with. We recommend using juv for seamless dependency management.
- Tutorial: This notebook goes through the basics of Quantum Error Correction, Stabilizer Formalism and the Surface Code, while leveraging surq to make the surface code more interactive and more easily illustrated.
uvx juv run notebooks/tutorial/notebook.py
Testing
Run the unit test suite with:
uv run pytest
References
- Improved Simulation of Stabilizer Circuits – Aaronson and Gottesman, 2004
- Stim: a fast stabilizer circuit simulator – Gidney, 2021
- STABSim: A Parallelized Clifford Simulator with Features Beyond Direct Simulation – Garner et al., 2025
- The Heisenberg Representation of Quantum Computers - Gottesman, 1998
Metadata
Release files for surfq 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| surfq-0.1.4.tar.gz | 98.0 kB | Without provenance | Details for surfq-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| surfq-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for surfq-0.1.4-py3-none-any.whl |
Total release size: 195.5 kB
Release files / surfq-0.1.4.tar.gz
| Download URL | surfq-0.1.4.tar.gz |
|---|---|
| Size | 98.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
870c224ac35672e620bb1c772014f3f3d7407fa4876586186c7bb954b6d14233
|
|
BLAKE2b-256 checksum How to use checksums |
76fb5c6af80ef8452e0876f3bb4eeef3e8d0e55b285cdac73b7bef8114c0ab3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / surfq-0.1.4-py3-none-any.whl
| Download URL | surfq-0.1.4-py3-none-any.whl |
|---|---|
| Size | 97.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb7ab8a69b7473d6cdba03e89c7ae2d8946b12dac56c1d5dbacaf9e154f4a8e9
|
|
BLAKE2b-256 checksum How to use checksums |
5baad47b21469aad84d552731ef273e952eaab919f859bd36710d0ec89b03d67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for surfq 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.