Skip to content

Commit

Permalink
Seeded unit tests (#1072)
Browse files Browse the repository at this point in the history
* is not -> !=

* Use pytest-randomly to seed unit tests.
  • Loading branch information
Shaden Smith authored May 13, 2021
1 parent 6b49b60 commit 46f4573
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deepspeed/runtime/pipe/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def ckpt_layer_path(self, ckpt_dir, local_layer_idx):
idx = local_layer_idx + self._local_start
layer_ckpt_path = os.path.join(ckpt_dir, f'layer_{idx:02d}')
rank_repr = self._grid._topo.get_rank_repr(rank=self.global_rank)
if rank_repr is not '':
if rank_repr != '':
layer_ckpt_path += f'-{rank_repr}'
layer_ckpt_path += '-model_states.pt'
return layer_ckpt_path
Expand Down
5 changes: 5 additions & 0 deletions deepspeed/runtime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def ensure_directory_exists(filename):


def set_random_seed(seed):
"""Set the random seed for common PRNGs used during training: random, numpy, and torch.
Args:
seed (int): the seed to use
"""
import numpy
import random
random.seed(seed)
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest
pytest-forked
pytest-randomly
pre-commit
clang-format
sphinx
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[options.entry_points]
pytest_randomly.random_seeder =
deepspeed = deepspeed.runtime.utils:set_random_seed

0 comments on commit 46f4573

Please sign in to comment.