Skip to content

Commit 34302e2

Browse files
authored
fix: update handling of invalid seeds via PL_GLOBAL_SEED
1 parent 10f6545 commit 34302e2

File tree

1 file changed

+2
-3
lines changed
  • src/lightning/fabric/utilities

1 file changed

+2
-3
lines changed

src/lightning/fabric/utilities/seed.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def seed_everything(seed: Optional[int] = None, workers: bool = False, verbose:
2828
seed: the integer value seed for global random state in Lightning.
2929
If ``None``, it will read the seed from ``PL_GLOBAL_SEED`` env variable. If ``None`` and the
3030
``PL_GLOBAL_SEED`` env variable is not set, then the seed defaults to 0. If the seed is provided
31-
as an integer but is not in bounds, a ValueError is raised.
31+
but is not in bounds or cannot be casted to int, a ValueError is raised.
3232
workers: if set to ``True``, will properly configure all dataloaders passed to the
3333
Trainer with a ``worker_init_fn``. If the user already provides such a function
3434
for their dataloaders, setting this argument will have no influence. See also:
@@ -45,8 +45,7 @@ def seed_everything(seed: Optional[int] = None, workers: bool = False, verbose:
4545
try:
4646
seed = int(env_seed)
4747
except ValueError:
48-
seed = 0
49-
rank_zero_warn(f"Invalid seed found: {repr(env_seed)}, seed set to {seed}")
48+
raise ValueError(f"Invalid seed specified via PL_GLOBAL_SEED: {repr(env_seed)}")
5049
elif not isinstance(seed, int):
5150
seed = int(seed)
5251

0 commit comments

Comments
 (0)