Skip to main content

vsim

Loss-aware sampling for Stim circuits (surface-code workflows).

Install

Note: this package has only been tested with Python 3.14.

uv add vsim
# Or using pip
pip install vsim

Building the native C++ extension requires a C++20 compiler (GCC 10+ / Clang 12+) and CMake ≥ 3.20.

Usage

from stim import Circuit
from vsim import add_noise, FastLossyCircuit

# Generate a surface code circuit with stim
circuit = Circuit.generated(
    "surface_code:rotated_memory_z",
    distance=5,
    rounds=5,
    after_clifford_depolarization=0.01,
    before_measure_flip_probability=0.01,
    after_reset_flip_probability=0.01,
)

# Add loss probabilities after 2 qubit gates, and reset gates
lossy_circuit = FastLossyCircuit.from_text(
    str(add_noise(circuit, p_2q = 0.01, p_reset = 0.01))
)

results = []
shots = 10_000

# this should run in less than 1s
for _ in range(shots):
    results.append(
        lossy_circuit.run()
    )

Typical speedups vs. Python-based sampling on rotated-memory-z surface codes: ~50× at d=3, ~60× at d=5, ~75× at d=7.

Development

Clone the repository with submodules:

git clone --recurse-submodules <repo-url>

Setup the development environment:

uv sync --group dev

Note: On Python 3.14 with GCC 15+, you may need CXXFLAGS="-include cstdint" uv sync --group dev to build stim correctly.

Run tests:

uv run --group dev pytest

Benchmarks

Start with this command to see the help message:

uv run python scripts/benchmark_syndrome_vs_run.py --help

Full benchmark run:

uv run scripts/benchmark_syndrome_vs_run.py -A -B -C -D --shots 1000

Metadata

Release files for vsim 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vsim 0.2.1
File Size Uploaded
vsim-0.2.1.tar.gz 3.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for vsim 0.2.1
File
vsim-0.2.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
vsim-0.2.1-cp314-cp314-win32.whl CPython 3.14 CPython 3.14 Windows x86-32 Details
vsim-0.2.1-cp314-cp314-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ x86-64 Details
vsim-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
vsim-0.2.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details

Total release size: 5.0 MB

Release files / vsim-0.2.1.tar.gz

Download URL vsim-0.2.1.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
1919240a1425f4f5d19d6f53cbac2f1e26714d599d1e83f143ee0769eaed424a
BLAKE2b-256 checksum
How to use checksums
cb8343c4c747f466464b24d214428da69d761ec03007879d19adc8ae79a58d6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 15, 2026.

Transparency log

Release files / vsim-0.2.1-cp314-cp314-win_amd64.whl

Download URL vsim-0.2.1-cp314-cp314-win_amd64.whl
Size 190.2 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
658e35b0b9141794c89b2447d37c79fab3c07dc4534737e562b48b5fcf264131
BLAKE2b-256 checksum
How to use checksums
c4719a065e4bf9d2d26a4e6f33b5561fff1ca8ab965eaa4ca48ac712c3715803
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 15, 2026.

Transparency log

Release files / vsim-0.2.1-cp314-cp314-win32.whl

Download URL vsim-0.2.1-cp314-cp314-win32.whl
Size 162.2 kB
Tags CPython 3.14 Windows x86-32
SHA-256 checksum
How to use checksums
cc516d4ae830199f927f712c7d31bcf40b91327a2bd47cb136e41dfffcfe377d
BLAKE2b-256 checksum
How to use checksums
803615e29245156c55c039a9a62cd505cfdf9f0a040d049cbf110368632e2e79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 15, 2026.

Transparency log

Release files / vsim-0.2.1-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL vsim-0.2.1-cp314-cp314-musllinux_1_2_x86_64.whl
Size 1.2 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
50302f77a0c92d16c4d80da16d2910e063528bff86c0e186dab4c24c86b5b731
BLAKE2b-256 checksum
How to use checksums
a544d128631a98f3bbc1f69862d14d87625f0ebe609281e534143fbd32706aa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 15, 2026.

Transparency log

Release files / vsim-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL vsim-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 211.0 kB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7bd0e2cfd3dba7bf79be4d702b5018cc47f3cef64010e16eaee0a1ccdf289301
BLAKE2b-256 checksum
How to use checksums
61eb6f86866c293d1277d579606958ebf7e9480bfd68907f37579b684ecb93fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 15, 2026.

Transparency log

Release files / vsim-0.2.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL vsim-0.2.1-cp314-cp314-macosx_11_0_arm64.whl
Size 166.5 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4a1effc205f5257de394adeb4923be90ebda0860f5e05ea2a778f3ef08d18ef3
BLAKE2b-256 checksum
How to use checksums
a3ee1eb4d0d2db344de7580d8793720a6922399cd27486315354b769c2ebe0d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page