Skip to content

Commit 8594f89

Browse files
committed
StabMps/StabVec: stabilizer+MPS simulator, Python bindings, Selene plugins
Comprehensive stabilizer tensor network simulation crate (exp/pecos-stab-tn) plus Python/Selene integration and repo-wide naming cleanup. ## Naming (Stab{Variant} convention) - CliffordRz → StabVec (sum of stabilizer states) - Stn/CliffordMps → StabMps (stabilizer tableau + MPS) - S/Sdg → SZ/SZdg in enums - Selene plugins: pecos-selene-stab-vec, pecos-selene-stab-mps, pecos-selene-mast ## StabMps simulator (exp/pecos-stab-tn) - Hybrid stabilizer-tableau + MPS for Clifford+rotation circuits - MAST magic state injection (deferred ancilla projection) - Lazy virtual-frame measurement with DeferredOp queue - Pauli frame tracking (Y-direct rep, exact decomposition-based flush) - merge_rz: same-qubit RZ batching with Clifford commutation - QEC API: reset_qubit, pz/px, extract_syndromes, inject_paulis_in_frame - Builder: for_qec() preset, auto_grow_bond_dim, pauli_frame_tracking - Diagnostics: pragmatic_drift_count, is_state_exact, StabMpsStats, OFD nullity - 238 lib tests + 81 verification tests (tiered: quick + ignored deep fuzz) ## Python bindings (python/pecos-rslib-exp) - PyO3/maturin: StabMps and Mast classes - Gate dispatch (run_gate/run_1q_gate/run_2q_gate), QEC helpers - Qubit bounds checking on all methods ## Selene plugins - pecos-selene-stab-mps, pecos-selene-mast: SimulatorInterface impls - Conformance tests pass - Added to CI workflow matrix, Justfile, workspace configs ## Merge reconciliation - QuantumSimulator::num_qubits() added to all impls across repo - StabilizerTableauSimulator stale num_qubits removed - ForeignSimulator/PyForeignSimulator: num_qubits threaded through FFI ## Code quality - Zero clippy warnings, zero rustc warnings - All .unwrap() in production code replaced with .expect() - design/ docs stubbed (moved to pecos-docs vault) - Python backward-compat aliases: CliffordRz = StabVec
1 parent f01e083 commit 8594f89

File tree

162 files changed

+24696
-5298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+24696
-5298
lines changed

.github/workflows/selene-plugins.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- 'python/selene-plugins/**'
1212
- 'crates/pecos-simulators/**'
1313
- 'crates/pecos-core/**'
14+
- 'exp/pecos-stab-tn/**'
1415
- '.github/workflows/selene-plugins.yml'
1516
pull_request:
1617
branches: [master, development, dev]
1718
paths:
1819
- 'python/selene-plugins/**'
1920
- 'crates/pecos-simulators/**'
2021
- 'crates/pecos-core/**'
22+
- 'exp/pecos-stab-tn/**'
2123
- '.github/workflows/selene-plugins.yml'
2224
workflow_dispatch:
2325

@@ -120,8 +122,12 @@ jobs:
120122
package: pecos_selene_stabilizer
121123
- name: pecos-selene-statevec
122124
package: pecos_selene_statevec
123-
- name: pecos-selene-clifford-rz
124-
package: pecos_selene_clifford_rz
125+
- name: pecos-selene-stab-vec
126+
package: pecos_selene_stab_vec
127+
- name: pecos-selene-stab-mps
128+
package: pecos_selene_stab_mps
129+
- name: pecos-selene-mast
130+
package: pecos_selene_mast
125131

126132
steps:
127133
- uses: actions/checkout@v6

Cargo.lock

Lines changed: 54 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
resolver = "2"
33
members = [
44
"python/pecos-rslib",
5+
"python/pecos-rslib-exp",
56
"python/pecos-rslib-cuda",
67
"python/pecos-rslib-llvm",
7-
"python/selene-plugins/pecos-selene-clifford-rz",
8+
"python/selene-plugins/pecos-selene-mast",
9+
"python/selene-plugins/pecos-selene-stab-mps",
10+
"python/selene-plugins/pecos-selene-stab-vec",
811
"python/selene-plugins/pecos-selene-stabilizer",
912
"python/selene-plugins/pecos-selene-statevec",
1013
"julia/pecos-julia-ffi",

Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ sync-deps:
504504
set -euo pipefail
505505
# Quick check: ensure the packages used by the default dev/test lane are importable.
506506
# This catches newly added workspace members that an older .venv may be missing.
507-
if uv run --frozen python -c "import importlib.util, sys; required = ('pecos', 'pecos_rslib', 'pecos_selene_clifford_rz', 'pecos_selene_stabilizer', 'pecos_selene_statevec'); missing = [name for name in required if importlib.util.find_spec(name) is None]; sys.exit(1 if missing else 0)" 2>/dev/null; then
507+
if uv run --frozen python -c "import importlib.util, sys; required = ('pecos', 'pecos_rslib', 'pecos_selene_stab_vec', 'pecos_selene_stabilizer', 'pecos_selene_statevec', 'pecos_selene_stab_mps', 'pecos_selene_mast'); missing = [name for name in required if importlib.util.find_spec(name) is None]; sys.exit(1 if missing else 0)" 2>/dev/null; then
508508
exit 0
509509
fi
510510
echo "Python deps incomplete, running uv sync..."

crates/benchmarks/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ parallel = ["pecos-simulators/parallel"]
1818
gpu-sims = ["dep:pecos-gpu-sims"]
1919
cuquantum = ["dep:pecos-cuquantum"]
2020
cppsparsestab = ["dep:pecos-cppsparsestab"]
21+
stab-tn = ["dep:pecos-stab-tn"]
2122
all-sims = ["gpu-sims", "cuquantum", "cppsparsestab"]
2223

2324
[dependencies]
@@ -27,6 +28,9 @@ pecos-cuquantum = { workspace = true, optional = true }
2728
pecos-cppsparsestab = { workspace = true, optional = true }
2829
pecos-core.workspace = true
2930
pecos-simulators.workspace = true
31+
pecos-stab-tn = { path = "../../exp/pecos-stab-tn", optional = true }
32+
nalgebra.workspace = true
33+
num-complex.workspace = true
3034

3135
[dev-dependencies]
3236
criterion.workspace = true

crates/benchmarks/benches/benchmarks.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ use criterion::{Criterion, criterion_group, criterion_main};
1717

1818
mod modules {
1919
pub mod allocation_overhead;
20-
pub mod clifford_rz;
2120
pub mod cpu_stabilizer_comparison;
2221
pub mod dem_builder;
2322
pub mod dem_sampler;
2423
pub mod dod_statevec;
2524
pub mod quizx_eval;
25+
pub mod stab_vec;
2626
// TODO: pub mod hadamard_ops;
2727
#[cfg(feature = "cuquantum")]
2828
pub mod cuquantum;
@@ -34,6 +34,8 @@ mod modules {
3434
#[cfg(feature = "cppsparsestab")]
3535
pub mod sparse_stab_vs_cpp;
3636
pub mod sparse_stab_w_vs_y;
37+
#[cfg(feature = "stab-tn")]
38+
pub mod stab_mps_vs_stab_vec;
3739
// TODO: pub mod pauli_ops;
3840
pub mod pecos_neo_comparison;
3941
pub mod rng;
@@ -51,16 +53,18 @@ use modules::cuquantum;
5153
use modules::gpu_influence_sampler;
5254
#[cfg(feature = "cppsparsestab")]
5355
use modules::sparse_stab_vs_cpp;
56+
#[cfg(feature = "stab-tn")]
57+
use modules::stab_mps_vs_stab_vec;
5458
use modules::{
55-
allocation_overhead, clifford_rz, cpu_stabilizer_comparison, dem_builder, dem_sampler,
56-
dod_statevec, measurement_sampling, native_statevec_comparison, noise_models,
57-
pecos_neo_comparison, quizx_eval, rng, set_ops, sparse_stab_w_vs_y, sparse_state_vec,
58-
stabilizer_sims, state_vec_sims, surface_code, trig,
59+
allocation_overhead, cpu_stabilizer_comparison, dem_builder, dem_sampler, dod_statevec,
60+
measurement_sampling, native_statevec_comparison, noise_models, pecos_neo_comparison,
61+
quizx_eval, rng, set_ops, sparse_stab_w_vs_y, sparse_state_vec, stab_vec, stabilizer_sims,
62+
state_vec_sims, surface_code, trig,
5963
};
6064

6165
fn all_benchmarks(c: &mut Criterion) {
6266
allocation_overhead::benchmarks(c);
63-
clifford_rz::benchmarks(c);
67+
stab_vec::benchmarks(c);
6468
cpu_stabilizer_comparison::benchmarks(c);
6569
quizx_eval::benchmarks(c);
6670
#[cfg(feature = "cuquantum")]
@@ -83,6 +87,8 @@ fn all_benchmarks(c: &mut Criterion) {
8387
sparse_stab_vs_cpp::benchmarks(c);
8488
sparse_stab_w_vs_y::benchmarks(c);
8589
surface_code::benchmarks(c);
90+
#[cfg(feature = "stab-tn")]
91+
stab_mps_vs_stab_vec::benchmarks(c);
8692
trig::benchmarks(c);
8793
// TODO: pauli_ops::benchmarks(c);
8894
// TODO: hadamard_ops::benchmarks(c);

crates/benchmarks/benches/modules/quizx_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! Evaluate `QuiZX` circuit simplification for T-count reduction.
1414
//!
1515
//! Tests whether ZX-calculus simplification meaningfully reduces the number
16-
//! of non-Clifford gates in circuits relevant to the `CliffordRz` simulator.
16+
//! of non-Clifford gates in circuits relevant to the `StabVec` simulator.
1717
1818
use criterion::{BenchmarkId, Criterion, measurement::Measurement};
1919
use quizx::circuit::Circuit;

0 commit comments

Comments
 (0)