Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions exp/pecos-neo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@
//! .mz(&[1])
//! .build();
//!
//! // Run without noise
//! let mut state = SparseStab::new(2);
//! let mut runner = CircuitRunner::<SparseStab>::new().with_seed(42);
//! // Run without noise. Measurement randomness comes from the simulator's
//! // RNG, so seed the simulator for reproducible outcomes; the runner seed
//! // only governs noise sampling.
//! let mut state = SparseStab::with_seed(2, 42);
//! let mut runner = CircuitRunner::<SparseStab>::new();
//! let outcomes = runner.apply_circuit(&mut state, &commands).unwrap();
//!
//! // Outcomes are correlated (Bell state)
Expand Down Expand Up @@ -333,7 +335,9 @@ mod tests {
fn test_prelude_usage() {
let commands = CommandBuilder::new().pz(&[0]).h(&[0]).mz(&[0]).build();

let mut state = SparseStab::new(1);
// Measurement outcomes draw from the simulator's RNG, so the simulator
// must be seeded for determinism; the runner seed does not govern them.
let mut state = SparseStab::with_seed(1, 42);
let mut runner = CircuitRunner::<SparseStab>::new().with_seed(42);
let outcomes = runner.apply_circuit(&mut state, &commands).unwrap();

Expand Down Expand Up @@ -400,7 +404,9 @@ mod tests {
fn test_multiple_shots() {
let commands = CommandBuilder::new().pz(&[0]).h(&[0]).mz(&[0]).build();

let mut state = SparseStab::new(1);
// Measurement outcomes draw from the simulator's RNG, so the simulator
// must be seeded for determinism; the runner seed does not govern them.
let mut state = SparseStab::with_seed(1, 42);
let mut runner = CircuitRunner::<SparseStab>::new().with_seed(42);

let mut count_0 = 0;
Expand Down
4 changes: 4 additions & 0 deletions exp/pecos-neo/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,10 @@ impl<S: CliffordGateable> CircuitRunner<S> {
}

/// Set the RNG seed for noise operations.
///
/// This does not affect measurement randomness, which comes from the
/// simulator's own RNG (e.g. `SparseStab::with_seed`); use
/// `set_full_seed` on a program for whole-run determinism.
#[must_use]
pub fn with_seed(mut self, seed: u64) -> Self {
self.rng = PecosRng::seed_from_u64(seed);
Expand Down
Loading