Fix seed correlation - #231
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Documentation examples contain an invalid type usage and do not apply the documented derived seed.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes correlated per-shot seeds by scrambling user seeds before deriving deterministic shot seeds.
Changes:
- Updates Python and Vihaco seed derivation.
- Adds regression coverage for nearby seeds.
- Updates documentation and dependencies.
| File | Description |
|---|---|
skills/ppvm-usage/SKILL.md |
Updates seeded sampling guidance. |
ppvm-python/test/generalized_tableau/test_stim.py |
Adds nearby-seed regression coverage. |
ppvm-python/src/ppvm/generalized_tableau.py |
Documents the new seed behavior. |
crates/ppvm-vihaco/src/shots.rs |
Scrambles Vihaco shot seeds. |
crates/ppvm-vihaco/Cargo.toml |
Adds rand. |
crates/ppvm-stim/src/executor.rs |
Updates sampling documentation. |
crates/ppvm-python-native/src/interface_tableau.rs |
Scrambles Python-native shot seeds. |
crates/ppvm-python-native/Cargo.toml |
Adds rand. |
Cargo.lock |
Locks dependency updates. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+227
to
+230
| // from it for reproducible runs. Scramble the user seed first | ||
| // (`let base = SmallRng::seed_from_u64(seed).random::<u64>();`), then use | ||
| // `new_with_seed(.., base.wrapping_add(i as u64))`. Plain `seed + i` makes calls | ||
| // with seeds `s` and `s + 1` share almost all their shots. |
|
rafaelha
reviewed
Sep 28, 2026
| /// identical for a given seed regardless of thread count. | ||
| /// The base seed is scrambled through a `SmallRng` before the index is added, | ||
| /// so nearby base seeds (`s`, `s + 1`, ...) give unrelated shots rather than | ||
| /// the same shots shifted by one (issue #228). Depends only on |
Collaborator
There was a problem hiding this comment.
comments are maybe a little verbose, e.g. adding issue #228 adds little extra info.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #228.