Skip to content

Commit d5aa598

Browse files
committed
stabilizer polish
1 parent a536c12 commit d5aa598

57 files changed

Lines changed: 347 additions & 347 deletions

Some content is hidden

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

crates/benchmarks/benches/modules/cpu_stabilizer_comparison.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! Compares all CPU-based stabilizer simulator implementations on surface code
1616
//! syndrome extraction to determine relative performance. This helps inform
17-
//! which implementation `Stab` should wrap as its default backend.
17+
//! which implementation `Stabilizer` should wrap as its default backend.
1818
//!
1919
//! Simulators compared:
2020
//! - `DenseStab` (row+column dual representation)
@@ -143,7 +143,7 @@ fn bench_cpu_stabilizer_surface_code<M: Measurement>(c: &mut Criterion<M>) {
143143
let ops_per_run = rounds * (params.num_ancillas * 3 + params.num_ancillas);
144144
group.throughput(Throughput::Elements(ops_per_run as u64));
145145

146-
// --- DenseStab (row+col dual, what Stab currently wraps) ---
146+
// --- DenseStab (row+col dual, what Stabilizer currently wraps) ---
147147
group.bench_with_input(BenchmarkId::new("DenseStab", &label), &(), |b, ()| {
148148
b.iter_batched(
149149
|| {

crates/benchmarks/benches/modules/sparse_stab_vs_cpp.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
// or implied. See the License for the specific language governing permissions and limitations under
1111
// the License.
1212

13-
//! Performance comparison: Pure Rust `SparseStab` vs C++ `CppSparseStab` vs `Stab` (`DenseStab`).
13+
//! Performance comparison: Pure Rust `SparseStab` vs C++ `CppSparseStab` vs `Stabilizer` (`DenseStab`).
1414
//!
1515
//! Benchmarks surface code syndrome extraction at various distances and round counts
1616
//! to compare the three stabilizer simulator backends:
1717
//!
1818
//! - `SparseStab` (pure Rust, BitSet-based sparse representation)
1919
//! - `CppSparseStab` (C++ implementation via cxx FFI)
20-
//! - `Stab` (pure Rust, `DenseStab` with row+column bit-matrix layout)
20+
//! - `Stabilizer` (pure Rust, `DenseStab` with row+column bit-matrix layout)
2121
2222
use criterion::{BenchmarkId, Criterion, Throughput, measurement::Measurement};
2323
use pecos::prelude::*;
24-
use pecos::simulators::{SparseStab, Stab};
24+
use pecos::simulators::{SparseStab, Stabilizer};
2525
use pecos_cppsparsesim::CppSparseStab;
2626
use std::hint::black_box;
2727

@@ -148,8 +148,8 @@ fn run_circuit_cpp_sparse_stab(sim: &mut CppSparseStab, params: &SurfaceCodePara
148148
}
149149
}
150150

151-
/// Run surface code syndrome extraction on Stab (`DenseStab`, pure Rust).
152-
fn run_circuit_stab(sim: &mut Stab, params: &SurfaceCodeParams, rounds: usize) {
151+
/// Run surface code syndrome extraction on Stabilizer (`DenseStab`, pure Rust).
152+
fn run_circuit_stab(sim: &mut Stabilizer, params: &SurfaceCodeParams, rounds: usize) {
153153
// Initialize data qubits in |+> state
154154
for i in 0..params.num_data {
155155
sim.h(&[QubitId::from(i)]);
@@ -178,7 +178,7 @@ fn run_circuit_stab(sim: &mut Stab, params: &SurfaceCodeParams, rounds: usize) {
178178
}
179179
}
180180

181-
/// Compare `SparseStab` (Rust) vs `CppSparseStab` (C++) vs Stab (`DenseStab`) on surface code
181+
/// Compare `SparseStab` (Rust) vs `CppSparseStab` (C++) vs Stabilizer (`DenseStab`) on surface code
182182
/// syndrome extraction across distances and round counts.
183183
fn bench_rust_vs_cpp_surface_code<M: Measurement>(c: &mut Criterion<M>) {
184184
use criterion::BatchSize;
@@ -227,11 +227,11 @@ fn bench_rust_vs_cpp_surface_code<M: Measurement>(c: &mut Criterion<M>) {
227227
);
228228
});
229229

230-
// --- DenseStab (Stab, pure Rust) ---
231-
group.bench_with_input(BenchmarkId::new("Stab_DenseRust", &label), &(), |b, ()| {
230+
// --- DenseStab (Stabilizer, pure Rust) ---
231+
group.bench_with_input(BenchmarkId::new("Stabilizer_DenseRust", &label), &(), |b, ()| {
232232
b.iter_batched(
233233
|| {
234-
let mut sim = Stab::new(params.num_qubits);
234+
let mut sim = Stabilizer::new(params.num_qubits);
235235
sim.reset();
236236
sim
237237
},
@@ -264,7 +264,7 @@ mod tests {
264264
cpp_sim.reset();
265265
run_circuit_cpp_sparse_stab(&mut cpp_sim, &params, rounds);
266266

267-
let mut stab_sim = Stab::new(params.num_qubits);
267+
let mut stab_sim = Stabilizer::new(params.num_qubits);
268268
stab_sim.reset();
269269
run_circuit_stab(&mut stab_sim, &params, rounds);
270270
}

crates/benchmarks/benches/modules/stabilizer_sims.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! Compares performance of:
1616
//! - `GpuStabMulti` (GPU via wgpu/Vulkan/Metal/DX12) - multi-shot stabilizer
1717
//! - `CuFrameSimulator` (GPU via NVIDIA cuQuantum/CUDA) - frame-based stabilizer
18-
//! - `SparseSim` (CPU) - baseline stabilizer simulator
18+
//! - `SparseStab` (CPU) - baseline stabilizer simulator
1919
//!
2020
//! Run with specific features:
2121
//! ```

crates/pecos-simulators/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub mod rotation_test_utils;
3737
pub mod sign_algebra;
3838
pub mod sparse_stab;
3939
pub mod sparse_stab_y;
40-
pub mod stab;
40+
pub mod stabilizer;
4141
pub mod stabilizer_tableau;
4242
pub mod stabilizer_test_utils;
4343
pub mod state_vec;
@@ -92,7 +92,7 @@ pub use sparse_stab_y::{
9292
SparseStabY, SparseStabYBitSet, SparseStabYGeneric, SparseStabYUnsortedVecSet,
9393
SparseStabYVecSet,
9494
};
95-
pub use stab::Stab;
95+
pub use stabilizer::Stabilizer;
9696
pub use stabilizer_tableau::StabilizerTableauSimulator;
9797
// StateVec uses the sparse SoA implementation optimized for QEC workloads.
9898
// The dense implementation is available as DenseStateVec / StateVecSoA.
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
//! Default stabilizer simulator with automatic implementation selection.
1414
//!
15-
//! [`Stab`] is the recommended stabilizer simulator for most use cases. It automatically
15+
//! [`Stabilizer`] is the recommended stabilizer simulator for most use cases. It automatically
1616
//! selects the best underlying implementation based on the number of qubits and workload
1717
//! characteristics.
1818
//!
1919
//! # Example
2020
//!
2121
//! ```rust
2222
//! use pecos_core::{QubitId, qid};
23-
//! use pecos_simulators::{Stab, CliffordGateable, QuantumSimulator};
23+
//! use pecos_simulators::{Stabilizer, CliffordGateable, QuantumSimulator};
2424
//!
2525
//! // Create a stabilizer simulator
26-
//! let mut sim = Stab::new(2);
26+
//! let mut sim = Stabilizer::new(2);
2727
//!
2828
//! // Create a Bell state
2929
//! sim.h(&qid(0)).cx(&[(QubitId(0), QubitId(1))]);
@@ -54,21 +54,21 @@ use pecos_random::PecosRng;
5454
///
5555
/// See the [module documentation](self) for more details.
5656
#[derive(Debug, Clone)]
57-
pub struct Stab {
57+
pub struct Stabilizer {
5858
inner: SparseStab,
5959
}
6060

61-
impl Stab {
61+
impl Stabilizer {
6262
/// Create a new stabilizer simulator with the given number of qubits.
6363
///
6464
/// All qubits are initialized in the |0⟩ state.
6565
///
6666
/// # Example
6767
///
6868
/// ```rust
69-
/// use pecos_simulators::Stab;
69+
/// use pecos_simulators::Stabilizer;
7070
///
71-
/// let sim = Stab::new(10);
71+
/// let sim = Stabilizer::new(10);
7272
/// assert_eq!(sim.num_qubits(), 10);
7373
/// ```
7474
#[inline]
@@ -86,9 +86,9 @@ impl Stab {
8686
/// # Example
8787
///
8888
/// ```rust
89-
/// use pecos_simulators::Stab;
89+
/// use pecos_simulators::Stabilizer;
9090
///
91-
/// let sim = Stab::with_seed(10, 42);
91+
/// let sim = Stabilizer::with_seed(10, 42);
9292
/// ```
9393
#[inline]
9494
#[must_use]
@@ -114,15 +114,15 @@ impl Stab {
114114
}
115115
}
116116

117-
impl QuantumSimulator for Stab {
117+
impl QuantumSimulator for Stabilizer {
118118
#[inline]
119119
fn reset(&mut self) -> &mut Self {
120120
self.inner.reset();
121121
self
122122
}
123123
}
124124

125-
impl CliffordGateable for Stab {
125+
impl CliffordGateable for Stabilizer {
126126
#[inline]
127127
fn h(&mut self, qubits: &[QubitId]) -> &mut Self {
128128
self.inner.h(qubits);
@@ -193,7 +193,7 @@ impl CliffordGateable for Stab {
193193
}
194194
}
195195

196-
impl RngManageable for Stab {
196+
impl RngManageable for Stabilizer {
197197
type Rng = PecosRng;
198198

199199
#[inline]
@@ -212,7 +212,7 @@ impl RngManageable for Stab {
212212
}
213213
}
214214

215-
impl StabilizerTableauSimulator for Stab {
215+
impl StabilizerTableauSimulator for Stabilizer {
216216
fn stab_tableau(&self) -> String {
217217
self.inner.stab_tableau()
218218
}
@@ -232,13 +232,13 @@ impl StabilizerTableauSimulator for Stab {
232232

233233
use crate::stabilizer_test_utils::{ForcedMeasurement, StabilizerSimulator};
234234

235-
impl ForcedMeasurement for Stab {
235+
impl ForcedMeasurement for Stabilizer {
236236
fn mz_forced(&mut self, qubit: usize, forced_outcome: bool) -> MeasurementResult {
237237
self.inner.mz_forced(qubit, forced_outcome)
238238
}
239239
}
240240

241-
impl StabilizerSimulator for Stab {
241+
impl StabilizerSimulator for Stabilizer {
242242
fn with_seed(num_qubits: usize, seed: u64) -> Self {
243243
Self::with_seed(num_qubits, seed)
244244
}
@@ -251,7 +251,7 @@ mod tests {
251251

252252
#[test]
253253
fn test_stab_basic() {
254-
let mut sim = Stab::new(2);
254+
let mut sim = Stabilizer::new(2);
255255
sim.h(&[QubitId(0)]);
256256
sim.cx(&[(QubitId(0), QubitId(1))]);
257257
let results = sim.mz(&[QubitId(0), QubitId(1)]);
@@ -260,7 +260,7 @@ mod tests {
260260

261261
#[test]
262262
fn test_stab_full_suite() {
263-
let mut sim = Stab::with_seed(8, 42);
263+
let mut sim = Stabilizer::with_seed(8, 42);
264264
run_full_stabilizer_test_suite(&mut sim, 8);
265265
}
266266
}

crates/pecos-simulators/src/stabilizer_test_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ mod tests {
19081908
fn test_all_stabilizer_sims_agree_on_random_circuits() {
19091909
use crate::{
19101910
DenseStab, DenseStabColOnly, DenseStabRowOnly, GpuStab, GpuStabOpt, GpuStabParallel,
1911-
SparseColOnly, SparseRowOnly, Stab, StabilizerTableauSimulator,
1911+
SparseColOnly, SparseRowOnly, Stabilizer, StabilizerTableauSimulator,
19121912
};
19131913
use pecos_random::PecosRng;
19141914

@@ -1930,7 +1930,7 @@ mod tests {
19301930
let mut dense_row = DenseStabRowOnly::<PecosRng>::new(num_qubits);
19311931
let mut sparse_col = SparseColOnly::new(num_qubits);
19321932
let mut sparse_row = SparseRowOnly::new(num_qubits);
1933-
let mut stab = Stab::new(num_qubits);
1933+
let mut stab = Stabilizer::new(num_qubits);
19341934
let mut gpu_stab = GpuStab::new(num_qubits);
19351935
let mut gpu_stab_opt = GpuStabOpt::new(num_qubits);
19361936
let mut gpu_stab_parallel = GpuStabParallel::new(num_qubits);
@@ -1973,7 +1973,7 @@ mod tests {
19731973
check_tableau!(dense_row, "DenseStabRowOnly");
19741974
check_tableau!(sparse_col, "SparseColOnly");
19751975
check_tableau!(sparse_row, "SparseRowOnly");
1976-
check_tableau!(stab, "Stab");
1976+
check_tableau!(stab, "Stabilizer");
19771977
check_tableau!(gpu_stab, "GpuStab");
19781978
check_tableau!(gpu_stab_opt, "GpuStabOpt");
19791979
check_tableau!(gpu_stab_parallel, "GpuStabParallel");
@@ -2018,7 +2018,7 @@ mod tests {
20182018
check_measurements!(dense_row, "DenseStabRowOnly");
20192019
check_measurements!(sparse_col, "SparseColOnly");
20202020
check_measurements!(sparse_row, "SparseRowOnly");
2021-
check_measurements!(stab, "Stab");
2021+
check_measurements!(stab, "Stabilizer");
20222022
check_measurements!(gpu_stab, "GpuStab");
20232023
check_measurements!(gpu_stab_opt, "GpuStabOpt");
20242024
check_measurements!(gpu_stab_parallel, "GpuStabParallel");

crates/pecos-simulators/tests/stabilizer_suite_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
use pecos_simulators::{
1919
DenseStab, DenseStabColOnly, DenseStabRowOnly, GpuStab, GpuStabOpt, GpuStabParallel,
20-
SparseColOnly, SparseStab, SparseStabHybrid, SparseStabUnsortedVecSet, SparseStabVecSet, Stab,
20+
SparseColOnly, SparseStab, SparseStabHybrid, SparseStabUnsortedVecSet, SparseStabVecSet, Stabilizer,
2121
};
2222

2323
// Generate test suites for all stabilizer simulator implementations
@@ -35,7 +35,7 @@ pecos_simulators::stabilizer_test_suite!(DenseStabRowOnly);
3535
pecos_simulators::stabilizer_test_suite!(SparseColOnly);
3636

3737
// Default wrapper
38-
pecos_simulators::stabilizer_test_suite!(Stab);
38+
pecos_simulators::stabilizer_test_suite!(Stabilizer);
3939

4040
// GPU-optimized stabilizer simulators
4141
pecos_simulators::stabilizer_test_suite!(GpuStab);

design/ENGINES_ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ results = engine.run(program, shots=100)
923923
│ │ │
924924
│ ┌──────────────────────┴──────────────────────────────┐ │
925925
│ │ PyO3 Bindings (pecos-rslib) │ │
926-
│ │ - SparseSim, StateVec exposed to Python │ │
926+
│ │ - SparseStab, StateVec exposed to Python │ │
927927
│ │ - WasmForeignObject for classical co-processors │ │
928928
│ │ - Engine builders for Rust-native pipelines │ │
929929
│ └──────────────────────┬──────────────────────────────┘ │

docs/user-guide/gates.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ All examples in this guide use the following setup:
99
=== ":fontawesome-brands-python: Python"
1010

1111
```python
12-
from pecos.simulators import SparseSim
12+
from pecos.simulators import SparseStab
1313

1414
# Create a stabilizer simulator with 5 qubits
15-
state = SparseSim(num_qubits=5)
15+
state = SparseStab(num_qubits=5)
1616

1717
# Qubit indices for examples
1818
q = 0
@@ -32,10 +32,10 @@ All examples in this guide use the following setup:
3232
```
3333

3434
```hidden-python
35-
from pecos.simulators import SparseSim
35+
from pecos.simulators import SparseStab
3636
3737
# Create a stabilizer simulator with 5 qubits
38-
state = SparseSim(num_qubits=5)
38+
state = SparseStab(num_qubits=5)
3939
4040
# Qubit indices for examples
4141
q = 0
@@ -62,7 +62,7 @@ fn main() {
6262

6363
PECOS supports two categories of quantum gates:
6464

65-
- **Clifford Gates**: Gates that map Pauli operators to Pauli operators. These can be efficiently simulated using stabilizer simulators like `SparseSim`.
65+
- **Clifford Gates**: Gates that map Pauli operators to Pauli operators. These can be efficiently simulated using stabilizer simulators like `SparseStab`.
6666
- **Non-Clifford Gates**: Rotation gates and other operations that require state vector simulation.
6767

6868
## Quick Reference
@@ -113,10 +113,10 @@ The examples below use a simulator instance. Run this setup code first:
113113
=== ":fontawesome-brands-python: Python"
114114

115115
```python
116-
from pecos.simulators import SparseSim
116+
from pecos.simulators import SparseStab
117117

118118
# Create a stabilizer simulator with 5 qubits
119-
state = SparseSim(num_qubits=5)
119+
state = SparseStab(num_qubits=5)
120120

121121
# Qubit indices for examples
122122
q = 0
@@ -1071,7 +1071,7 @@ These operations measure and then prepare the qubit in a specific eigenstate reg
10711071

10721072
| Simulator | Clifford Gates | Non-Clifford Gates | Notes |
10731073
|-----------|---------------|-------------------|-------|
1074-
| **SparseSim** | All | None | Default, fastest for QEC |
1074+
| **SparseStab** | All | None | Default, fastest for QEC |
10751075
| **StateVec** | All | All | Pure Rust state vector |
10761076
| **Qulacs** | All | All | High-performance C++ backend |
10771077
| **CuStateVec** | All | All | GPU-accelerated (requires CUDA) |

0 commit comments

Comments
 (0)