Snapshot the full state of the default random generator.
Returns an int64 tensor of length 2, [seed, counter],
that completely characterises the default Philox generator.
The Philox-4×32 PRNG is a stateless counter-based design: the entire infinite sample stream is determined by the two-tuple
where is the seed key and is the call counter. After each draw of a 128-bit output block, is incremented by 1. The next sample is always , so saving is a lossless checkpoint of the generator.
Returns
Tensor1-D int64 tensor [seed, counter] of shape (2,).
Pass this directly to set_rng_state to restore the stream.
Notes
Unlike Mersenne Twister (which requires 624 × 32-bit words of state), Philox's full state is just 128 bits. This makes checkpointing essentially free and enables exact reproducibility of training runs when saved alongside model weights.
Examples
>>> import lucid
>>> lucid.manual_seed(0)
>>> _ = lucid.rand(10) # advance counter by drawing 10 values
>>> state = lucid.get_rng_state()
>>> a = lucid.rand(5)
>>> lucid.set_rng_state(state) # rewind
>>> b = lucid.rand(5)
>>> (a - b).abs().max().item()
0.0