Skip to content

Fix seed correlation - #231

Merged
david-pl merged 4 commits into
mainfrom
david/228-fix-seed-correlation
Sep 29, 2026
Merged

david-pl merged 4 commits into
mainfrom
david/228-fix-seed-correlation

Conversation

@david-pl

Copy link
Copy Markdown
Collaborator

Closes #228.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Low severity

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 thread skills/ppvm-usage/SKILL.md Outdated
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.
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-29 07:32 UTC

Copilot AI review requested due to automatic review settings September 28, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Seeded sampling documentation needs correction, and the example contains a type-checking issue.

Review effort: Lite
Findings: 1 Low severity

Open (1)

Comment thread crates/ppvm-vihaco/src/shots.rs Outdated
/// 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments are maybe a little verbose, e.g. adding issue #228 adds little extra info.

@rafaelha rafaelha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI review requested due to automatic review settings September 29, 2026 07:24
@david-pl
david-pl enabled auto-merge (squash) September 29, 2026 07:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The usage guide’s runnable example still uses entropy-seeded construction instead of deterministic per-shot seeding.

Review effort: Lite
Findings: 1 Low severity

Open (1)

@david-pl
david-pl merged commit da073eb into main Sep 29, 2026
14 checks passed
@david-pl
david-pl deleted the david/228-fix-seed-correlation branch September 29, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sample() with seeds s and s+1 returns almost the same shots (per-shot seed is seed + i)

3 participants