feat: Modify inter-shot random_seed behaviour, provide legacy behaviour through seed_mode - #209
feat: Modify inter-shot random_seed behaviour, provide legacy behaviour through seed_mode#209jake-arkinstall wants to merge 6 commits into
Conversation
… seeds a pRNG before yielding seeds per-shot
|
Some guidance for reviewers.
|
| Setting to True provides the high level Selene interface, and | ||
| using False allows for Selene to be used as an intermediate | ||
| component for use with an external result stream handler. | ||
| seed_mode: The mode for handling random seeds. |
There was a problem hiding this comment.
Worth considering using an enum for this instead of a string?
There was a problem hiding this comment.
It could be. Though it will necessitate an extra import e.g.:
from selene_sim import SeedMode
run_shots(..., seed_mode=SeedMode.legacy)
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Adjusts the random_seed behaviour to avoid overlap between batches of run_shots using nearby seeds.
The existing behaviour was such that if one ran run_shots of N shots with a random_seed of M, components are seeded with M on the first shot, M+1 on the second, up to M+N-1. This acts as a reproducibility aid, but causes confusion when expected entirely different batches of shots.
The new default behaviour is to randomise the seed per-shot, by passing random_seed to a Pcg64Mcg pRNG and yielding shot RNGs by advancing this RNG to the required shot. As such, the chance of any overlap between two subsequent run_shots runs is very small, even if the seeds are close.
The existing behaviour still serves some purposes, so is available via a new
seed_modeparameter that can be provided torun_shotsandrun. Pass "legacy" for the existing mode, "default" for the new randomised mode. We demonstrate this by persisting some original snapshots with this mode in this PR, but may revise them to use the default mode later on.The legacy mode will be supported throughout this major version. It will eventually be dropped entirely, and our only mode will be to randomise seeds between shots. To repeat prior experiments, shot_increment and shot_offset can be used as demonstrated in determinism tests.