Skip to main content

Suface code simulations package

Project description

Surface-sim

example workflow Code style: black Documentation Status PyPI

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.

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.setups 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.setups 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 documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

surface_sim-0.10.0.tar.gz (82.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

surface_sim-0.10.0-py3-none-any.whl (107.3 kB view details)

Uploaded Python 3

File details

Details for the file surface_sim-0.10.0.tar.gz.

File metadata

  • Download URL: surface_sim-0.10.0.tar.gz
  • Upload date:
  • Size: 82.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for surface_sim-0.10.0.tar.gz
Algorithm Hash digest
SHA256 9186a6d567ba6583d7418e4b1f66f765e851ffad5af80619f96ad8308cd5d1b5
MD5 c1db6d93a442929ff57a1a1e582cabcb
BLAKE2b-256 730eea54f37d312e20aed9d4c4176aa40f8d6f8eb89027862622ee59b2fc29db

See more details on using hashes here.

File details

Details for the file surface_sim-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: surface_sim-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 107.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for surface_sim-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91d6e78c935056d64afc405f1ad7f5f33a96b55f4e6f480b4bc1402b0fbaa29e
MD5 ae741583f38a48b8c2158dedfaf0f515
BLAKE2b-256 b0d020910701bbec53110f0fefe06b039152d35ec714616cb7bfb10bf894c137

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page