unisim.backend.genesis.materialization.preserve_torch_globals

unisim.backend.genesis.materialization.preserve_torch_globals(torch)[source]

Snapshot torch global defaults and restore them after gs.init.

gs.init mutates the host process: it forces torch.set_default_device("cuda:0") on the GPU lane, and passing seed= would reseed the global RNG (REPORT #1372 §3.5 [10]). The adapter never passes a seed and restores default device/dtype plus the torch RNG state so the training process observes no pollution (REPORT #1372 §5.8).

Parameters:

torch (Any)

Return type:

Iterator[None]