Skip to content

seed_everything should crash if invalid seeds are provided #21028

@jonathanking

Description

@jonathanking

Description & Motivation

Hi all,

I'd like to follow up on post-merge thread from #18846:

Current behavior
seed_everything has the behavior of changing the seed to 0 if the user provides an integer seed outside of numpy's acceptable range [0, 2**32-1].

Potential Issue
When the user calls pl.seed_everything(X), where X is outside of the acceptable range, they expect that it is seeded with this value. Instead, a warning is printed, and the code proceeds with seed 0.

I think this behavior is dangerous. If the user provides a seed that is out-of-bounds, this is a user error, and it is safer to raise a ValueError than it is to proceed with something that does not match the user's expectation. In this case, the user desires to set the seed to X. Why would they be ok with using the default seed of 0?

Looking forward to hearing any feedback. Thank you!

Pitch

Proposal
Raise a ValueError if the user specifies a seed to pl.seed_everything that is outside of numpy's acceptable range. This would cause programs to crash if they specify a seed that is out-of-bounds. I argue that out-of-bounds input to pl.seed_everything should be handled in a way that matches user expectations.

Alternatives

No response

Additional context

No response

cc @lantiga @Borda

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions