Skip to content

Add optional seed parameter to stim.Tableau.random() - #1099

Open
xguot wants to merge 1 commit into
quantumlib:mainfrom
xguot:feature/974-tableau-seed
Open

Add optional seed parameter to stim.Tableau.random()#1099
xguot wants to merge 1 commit into
quantumlib:mainfrom
xguot:feature/974-tableau-seed

Conversation

@xguot

@xguot xguot commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #974

This PR introduces an optional seed parameter to stim.Tableau.random() to
allow for deterministic generation of random tableaus.

@xguot
xguot force-pushed the feature/974-tableau-seed branch from 5eea33d to 385cc2c Compare July 31, 2026 00:07
@Strilanc

Copy link
Copy Markdown
Collaborator

A seed is supposed to be used for generating a sequence of results, not just one. If it's just one tableau then it's more of a weird indexing system.

In order for this to be merged, it would be necessary to define a stim.TableauSampler that took a seed when initialized and then had a method next_tableau() that could be called repeatedly.

@xguot
xguot marked this pull request as draft July 31, 2026 14:40
@xguot
xguot force-pushed the feature/974-tableau-seed branch from 8601bc1 to 7599858 Compare August 1, 2026 00:24
@xguot

xguot commented Aug 1, 2026

Copy link
Copy Markdown
Author

Implemented 'TableauSampler' with 'next_tableau()', the internal rng state should advances across calls.

@xguot
xguot marked this pull request as ready for review August 1, 2026 00:38

@Strilanc Strilanc 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.

Makes more sense now, but various little changes to the design and documentation are needed.

Comment thread doc/stim.pyi
Comment thread doc/stim.pyi Outdated
Comment thread doc/stim.pyi Outdated
Comment thread doc/stim.pyi Outdated
Comment thread src/stim/stabilizers/tableau_sampler.pybind.cc Outdated
Comment thread src/stim/stabilizers/tableau_sampler.pybind.cc Outdated
Comment thread src/stim/stabilizers/tableau_sampler.pybind.cc Outdated
Comment thread src/stim/stabilizers/tableau_sampler_pybind_test.py
Implements a stateful C++ TableauSampler wrapped with Pybind11 to enable
reproducible generation of Clifford tableaus via a seedable mt19937_64
random number generator.
@xguot
xguot force-pushed the feature/974-tableau-seed branch from 7599858 to dbeec0e Compare August 1, 2026 01:10
@xguot

xguot commented Aug 1, 2026

Copy link
Copy Markdown
Author

Updated the docstrings and removed the asserts.

Thank you!

@xguot
xguot requested a review from Strilanc August 1, 2026 03:11
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.

Feature request: Add seed support to stim.Tableau.random() for reproducibility

2 participants