manual_seed
→Nonemanual_seed(seed: _int)Set the seed of the default Philox counter-based random number generator.
The Lucid RNG uses a Philox-4×32 counter-based PRNG (Salmon et al., 2011). Unlike stateful RNGs (e.g. Mersenne Twister), Philox is a keyed bijection: given a 64-bit key (the seed) and a 64-bit counter , it produces a deterministic 128-bit output block via 10 rounds of the Philox permutation:
Setting the seed to a fixed value fully determines the entire subsequent sampling stream, enabling reproducible experiments.
Parameters
seedintNotes
Calling manual_seed resets the counter to in addition to
updating the key . Two calls with the same seed produce
identical streams regardless of how many samples were drawn in between.
For multi-process reproducibility, seed each worker with a distinct
derived seed, e.g. manual_seed(base_seed + worker_id), to avoid
correlated streams across processes.
Examples
>>> import lucid
>>> lucid.manual_seed(42)
>>> a = lucid.rand(3)
>>> lucid.manual_seed(42)
>>> b = lucid.rand(3)
>>> (a - b).abs().max().item()
0.0