diff --git a/modules/rng.py b/modules/rng.py index 72dc87de..6eef8186 100644 --- a/modules/rng.py +++ b/modules/rng.py @@ -8,12 +8,12 @@ def randn(seed, shape, generator=None): Uses the seed parameter to set the global torch seed; to generate more with that seed, use randn_like/randn_without_seed.""" - manual_seed(seed) - if generator is not None: - # if generator is not none, we must generate a noise with and without - # generator together to avoid future 'randn' get same noise again - torch.randn(shape, device=devices.device) + # If generator is not none, we must use another seed to + # avoid global torch.rand to get same noise again. + manual_seed((seed + 262144) % 65536) + else: + manual_seed(seed) if shared.opts.randn_source == "NV": return torch.asarray((generator or nv_rng).randn(shape), device=devices.device)