Closed cbalioglu closed 3 months ago
This seems cool! Could you share an example of where this is commonly used ?
We use it in reset_parameters()
and to_device()
functions in fairseq2.nn.utils.module
.
We also use it in unit/integration tests to avoid changing the global seed.
This PR introduces a new
temporary_manual_seed()
function which is a "cleaner" way totorch.random.fork_rng() + torch.manual_seed()
as it internally usesRngBag
to correctly set the seed only for the passed devices. It also extendsreset_parameters()
andto_device()
utility functions with an extra convenienceseed
parameter.