Seeded unit tests (#1072)

* is not -> !=

* Use pytest-randomly to seed unit tests.
This commit is contained in:
Shaden Smith
2021-05-13 15:20:59 -07:00
committed by GitHub
parent 6b49b60ec8
commit 46f4573b1a
4 changed files with 10 additions and 1 deletions

View File

@ -533,7 +533,7 @@ class PipelineModule(nn.Module):
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

View File

@ -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)

View File

@ -1,5 +1,6 @@
pytest
pytest-forked
pytest-randomly
pre-commit
clang-format
sphinx

3
setup.cfg Normal file
View File

@ -0,0 +1,3 @@
[options.entry_points]
pytest_randomly.random_seeder =
deepspeed = deepspeed.runtime.utils:set_random_seed