Suface code simulations package
Project description
Surface-sim
This package is a wrapper around Stim to simplify the construction of QEC circuits. Given a circuit, it can implement the logical equivalent under different types of noise, including circuit-level noise. It uses a code layout that helps with qubit labeling, indexing and connectivity. It also defines the detectors automatically for any sequence of logical gates.
For more information see the documentation in docs/.
Installation
This package is available in PyPI, thus it can be installed using
pip install surface-sim
or alternatively, it can be installed from source using
git clone git@github.com:MarcSerraPeralta/surface-sim.git
pip install surface-sim/
Example
Pre-built experiment: memory experiment
from surface_sim.layouts import rot_surface_code
from surface_sim.models import CircuitNoiseModel
from surface_sim.setup import CircuitNoiseSetup
from surface_sim import Detectors
from surface_sim.experiments.rot_surface_code_css import memory_experiment
# prepare the layout, model, and detectors objects
layout = rot_surface_code(distance=3)
setup = CircuitNoiseSetup()
model = CircuitNoiseModel(setup, layout.qubit_inds)
detectors = Detectors(layout.anc_qubits, frame="pre-gate")
# create a memory experiment
NUM_ROUNDS = 10
DATA_INIT = {q: 0 for q in layout.data_qubits}
ROT_BASIS = True # X basis
MEAS_RESET = True # reset after ancilla measurements
PROB = 1e-5
setup.set_var_param("prob", PROB)
stim_circuit = memory_experiment(
model,
layout,
detectors,
num_rounds=NUM_ROUNDS,
data_init=DATA_INIT,
rot_basis=ROT_BASIS,
anc_reset=MEAS_RESET,
)
Arbitrary logical circuit from a given circuit
import stim
from surface_sim.setup import CircuitNoiseSetup
from surface_sim.models import CircuitNoiseModel
from surface_sim import Detectors
from surface_sim.experiments import schedule_from_circuit, experiment_from_schedule
from surface_sim.circuit_blocks.unrot_surface_code_css import gate_to_iterator
from surface_sim.layouts import unrot_surface_codes
circuit = stim.Circuit(
"""
R 0 1
TICK
CNOT 0 1
TICK
S 0
I 1
TICK
S 0
H 1
TICK
M 0
MX 1
"""
)
layouts = unrot_surface_codes(circuit.num_qubits, distance=3)
setup = CircuitNoiseSetup()
model = CircuitNoiseModel.from_layouts(setup, *layouts)
detectors = Detectors.from_layouts("pre-gate", *layouts)
setup.set_var_param("prob", 1e-3)
schedule = schedule_from_circuit(circuit, layouts, gate_to_iterator)
stim_circuit = experiment_from_schedule(
schedule, model, detectors, anc_reset=True
)
For more information and examples about surface-sim, please read the docs/.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file surface_sim-0.9.1.tar.gz.
File metadata
- Download URL: surface_sim-0.9.1.tar.gz
- Upload date:
- Size: 72.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d60abd316ec6707b0529bca855c5b26de070eb107904ded3ce1da24c381f647
|
|
| MD5 |
39f316965bd646bed4635cef4481a6fb
|
|
| BLAKE2b-256 |
5c8c3de29a89ae756fce747b339ec977e0624016c48b7c97c74458ce8d26e3c9
|
File details
Details for the file surface_sim-0.9.1-py3-none-any.whl.
File metadata
- Download URL: surface_sim-0.9.1-py3-none-any.whl
- Upload date:
- Size: 91.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff014f530a63dd8adab19465e8b08b40f8205b1a5032052645151521a859afa7
|
|
| MD5 |
e72615f97b9447edc877756103eacbbc
|
|
| BLAKE2b-256 |
22e9a1579f508cf7e3e32f15108b13907a8058c2ea09f59170a7ec0e28966cef
|