-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change dangerous default random seed selection #18846
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about 42?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be considered a breaking change for scripts that relied on this behaviour to run ablations
@carmocca I added this to the changed section already. Is there anything else I should do to communicate this change? A warning that the feature changed would be possible to add but then we are again offending all these users who don't want to see false-positive warnings. |
Nothing I can think of. I just wanted to point it out |
(cherry picked from commit 6bfde6a)
What does this PR do?
The
seed_everything
function can be called without arguments. In this case, it will take the seed value from the environment variablePL_GLOBAL_SEED
. But if the environment variable is not set, it falls back to selecting the seed randomly. This isn't usually a problem if Lightning is in control of launching the processes, because child processes will inherit the seed value from the environment variable. However, in cases where processes are launched externally (e.g. SLURM, torchelastic etc.), this default behavior is dangerous because each process will independently choose a random seed. This can affect sampling, randomized validation splits, and other behaviors that rely on each process having the same seed.This PR removes this random behavior and makes it so that the
seed_everything
falls back to setting a fixed seed 0. This change only affects users who have intentionally calledseed_everything
with no arguments, and those who useseed_everything=True
in LightningCLI. Those uses will now have to select the number randomly first, and then pass it in toseed_everything
, unless they are happy with the new default of 0.Fixes #18638
(to be confirmed)
📚 Documentation preview 📚: https://pytorch-lightning--18846.org.readthedocs.build/en/18846/
cc @Borda @carmocca @justusschock @awaelchli