Skip to content

ppvm_stim (crate)

ppvm_stim

ppvm_stim

Parse and execute Stim circuits against a [`GeneralizedTableau`].

Two-stage pipeline:

  1. parse_extended — `&str` → [`ExtendedProgram`] (re-exported from `stim_parser`).
  2. execute / sample — call validate to validate the [`ExtendedProgram`], then apply it to a [`GeneralizedTableau`].

Multi-shot usage should call parse_extended once and pass the parsed program to sample. The run_string / run_file convenience helpers re-parse on every call and are intended for single-shot demos only.

```ignore use ppvm_stim::{parse_extended, sample}; use ppvm_tableau::prelude::*;

let prog = parse_extended(circuit_src)?; let shots = sample(&prog, 10_000, || { GeneralizedTableau::<, usize, _>::new(n_qubits, 1e-10) })?;

```

run_string / run_file re-parse on every call and exist only for single-shot demos — never call them from a shot loop.

Modules

classErrorsource

ppvm_stim::Error

Bases: Debug, Error, Display, From&lt;Diagnostics&gt;, From&lt;ExecError&gt;

Rust enum.

pub enum Error

Variants

NameTypeDescription
Parse(Diagnostics)A parse/validate/lower failure from `stim_parser`, reported as a [`Diagnostics`] aggregate.
Exec(ExecError)
Io{ ... }
source

functionrun_filesource

ppvm_stim::run_file

Signature
pub fn run_file<T, I, C>(path: &Path, tab: &mut GeneralizedTableau<T, I, C>) -> Result<Vec<Option<bool>>, Error>

Parameters

NameTypeDescription
path&amp;Path
tab&amp;mut GeneralizedTableau&lt;T, I, C&gt;

Returns

Result<Vec<Option<bool>>, Error>

source

functionrun_stringsource

ppvm_stim::run_string

Signature
pub fn run_string<T, I, C>(src: &str, tab: &mut GeneralizedTableau<T, I, C>) -> Result<Vec<Option<bool>>, Error>

Parameters

NameTypeDescription
src&amp;str
tab&amp;mut GeneralizedTableau&lt;T, I, C&gt;

Returns

Result<Vec<Option<bool>>, Error>

Parse → validate → execute in one shot. Re-parses each call; do not use in shot loops — use parse_extended + sample instead.

source