Skip to content

Add seed as a tensor argument to the samplex#314

Draft
ihincks wants to merge 6 commits intomainfrom
tensor-seed
Draft

Add seed as a tensor argument to the samplex#314
ihincks wants to merge 6 commits intomainfrom
tensor-seed

Conversation

@ihincks
Copy link
Collaborator

@ihincks ihincks commented Mar 1, 2026

Summary

This PR deprecates the rng argument and adds seed as a 0-d tensor input.

Closes #305

Details and comments

This PR also got me to think a bit deeper about what kind of seed stability we can actually support across versions and OSes. I've documented that in the sample method. Esentially, we can guarantee stability of the raw bit stream everywhere and always. However, consumers of that stream, like an implementation of generating 64 bit integers, is package dependent. NumPy treats changes to such implementations as a breaking change, so we get safety by pinning to a major version. Likewise, if samplomatic consumes these integers in a different way, that's also a breaking change to seed stability. We need to try our best not to.

AI: a bit of Claude Opus 4.6

@ihincks
Copy link
Collaborator Author

ihincks commented Mar 2, 2026

I need to think a bit more about this PR. Specifically, I'm concerned about the case where someone wants to generate 10000 randomizations, and they want to be able to do it in either 1 chunk of 10000, or 10 chunks of 1000, or 50 chunks of 2000, etc. It seems like the seed control of this PR doesn't go far enough. Something that might be sufficient is letting it have shape (num_randomizations, ). I wonder if there is a more elegant way, though. Performance is also a concern.

@ihincks
Copy link
Collaborator Author

ihincks commented Mar 2, 2026

The more I think about it, the more I think that this PR isn't solving a lot of problems. It's not helping a user of .sample(), they still only get one seed. It's not helping an implementer of executor, because they will have to do a lot of heavy lifting to split randomization axes with seed control.

- 'parameter_values' <float64[2]>: Input parameter values to use during sampling.
>)
- 'parameter_values' <float64[2]>: Input parameter values to use during sampling.
<BLANKLINE>
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this about? seems like a weird artifact

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's because the __str__ of the object literally has a blank line, and apparently doctest uses this set of characters to test against it. something claude knows but i didn't.

major versions because historically they have never, for example, changed how
``rng.integers()`` consumes the underlying raw bit stream to generate integers, though
in principle they could. Samplomatic will issue changelog notices if it ever changes a
distribution implementation, though will avoid doing so in general.
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@ihincks ihincks marked this pull request as draft March 2, 2026 20:47
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.

Allow seed as a tensor-valued argument to sample

2 participants