diff --git a/exp/pecos-neo/src/lib.rs b/exp/pecos-neo/src/lib.rs index 085555c22..f3089ed34 100644 --- a/exp/pecos-neo/src/lib.rs +++ b/exp/pecos-neo/src/lib.rs @@ -83,9 +83,11 @@ //! .mz(&[1]) //! .build(); //! -//! // Run without noise -//! let mut state = SparseStab::new(2); -//! let mut runner = CircuitRunner::::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::::new(); //! let outcomes = runner.apply_circuit(&mut state, &commands).unwrap(); //! //! // Outcomes are correlated (Bell state) @@ -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::::new().with_seed(42); let outcomes = runner.apply_circuit(&mut state, &commands).unwrap(); @@ -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::::new().with_seed(42); let mut count_0 = 0; diff --git a/exp/pecos-neo/src/runner.rs b/exp/pecos-neo/src/runner.rs index e16b73b30..a583131c6 100644 --- a/exp/pecos-neo/src/runner.rs +++ b/exp/pecos-neo/src/runner.rs @@ -802,6 +802,10 @@ impl CircuitRunner { } /// 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);