TensorPlay
API symbolsrandom
Copy
View MarkdownDownload .md

tensorplay.random.fork_rng

tensorplay.random.fork_rng(devices=None, enabled=True, _caller='fork_rng', _devices_kw='devices')[source]

Forks the RNG state: code inside the context gets a pristine RNG.

Saves the CPU RNG state on entry and restores it on exit, so random operations inside the block do not advance the outer stream (mirrors torch.random.fork_rng). CUDA devices are not forked; pass devices=[] explicitly to acknowledge that (same contract as torch).

Ask DeepWiki