Skip to content

Commit 089ae9b

Browse files
authored
convert state to tuple explicitly when setting python random state (#9401)
* convert state to tuple explicitly * update changelog
1 parent 439db22 commit 089ae9b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
5959
* Added Fault Tolerant Training to `DataFetcher` ([#8891](https://github.com/PyTorchLightning/pytorch-lightning/pull/8891))
6060
* Replaced old prefetch iterator with new `DataFetcher` in training loop ([#8953](https://github.com/PyTorchLightning/pytorch-lightning/pull/8953))
6161
* Added partial support for global random state fault-tolerance in map-style datasets ([#8950](https://github.com/PyTorchLightning/pytorch-lightning/pull/8950))
62+
* Converted state to tuple explicitly when setting Python random state ([#9401](https://github.com/PyTorchLightning/pytorch-lightning/pull/9401))
63+
6264

6365
- Checkpoint saving & loading extensibility:
6466
* Added `CheckpointIO` to expose checkpoint IO from training type plugin ([#8743](https://github.com/PyTorchLightning/pytorch-lightning/pull/8743))

pytorch_lightning/utilities/auto_restart.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ def set_rng_states(rng_state_dict: Dict[str, Any]) -> None:
263263
"""Set the global random state of :mod:`torch`, :mod:`numpy` and Python in the current process."""
264264
torch.set_rng_state(rng_state_dict.get("torch"))
265265
np.random.set_state(rng_state_dict.get("numpy"))
266-
python_set_rng_state(rng_state_dict.get("python"))
266+
version, state, gauss = rng_state_dict.get("python")
267+
python_set_rng_state((version, tuple(state), gauss))
267268

268269

269270
class CaptureIterableDataset(IterableDataset):

0 commit comments

Comments
 (0)