Surface Code Guide - Noro-Official/OQS GitHub Wiki
Extending with Surface Codes
Surface codes are the flagship model for scalable fault-tolerant quantum computing. OpenQStack is built to support their simulation, decoding, and visualization.
Step 1: Create the SurfaceCode Class
Inside openqstack/surface_code/
, create a new file surface_code.py
:
class SurfaceCode:
def __init__(self, distance=3):
self.distance = distance
self.lattice = self._initialize_lattice()
def _initialize_lattice(self):
# Create qubit/stabilizer map here
pass
def apply_noise(self, channel):
# Inject noise to data qubits
pass
def extract_syndrome(self):
# Simulate parity checks
return syndrome
def decode(self, syndrome):
# Placeholder for MWPM or table-based decoder
pass
def recover(self, correction_ops):
# Apply recovery to lattice
pass
Step 2: Create Visualization Hooks
Add plotting tools under visualize_surface.py
, such as:
plot_syndrome_grid()
highlight_logical_path()
animate_surface_cycle()
Step 3: Build a Demo
Create examples/surface_blink.py
:
from openqstack.surface_code.surface_code import SurfaceCode
code = SurfaceCode(distance=3)
code.apply_noise(channel)
syndrome = code.extract_syndrome()
correction = code.decode(syndrome)
code.recover(correction)
Step 4: Add Decoders
Create decoder/
module with:
mwpm.py
lookup.py
ml_decoder.py
Each decoder should expose a function:
def decode(syndrome, code_distance):
return list_of_pauli_corrections
Contributing Surface Code Modules
We are actively developing the surface code framework.
If you're interested in helping with:
- Syndrome logic
- Visualizations
- Benchmarking tools
- Advanced decoding
Open an issue or join our discussions.