From d7007c9e3c5386fb6d5c67e6f81f0c70a2cbabef Mon Sep 17 00:00:00 2001 From: hyunwoongko Date: Wed, 29 Dec 2021 04:29:17 +0900 Subject: [PATCH] Modify broadcasting operation for random seed --- parallelformers/parallel/process.py | 8 +++----- setup.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/parallelformers/parallel/process.py b/parallelformers/parallel/process.py index cf8cd26..f44acb6 100644 --- a/parallelformers/parallel/process.py +++ b/parallelformers/parallel/process.py @@ -150,14 +150,12 @@ def inference(self, model: nn.Module) -> None: model (nn.Module): model weight """ if self.seed is None: - seed = time() + seed = torch.tensor(int(time())).cuda() + dist.broadcast(seed, src=0) + seed = seed.item() else: seed = self.seed - seed = torch.tensor(int(seed)).cuda() - dist.broadcast(seed, src=0) - seed = seed.item() - torch.manual_seed(seed) np.random.seed(seed) random.seed(seed) diff --git a/setup.py b/setup.py index 145866c..6ee5fb7 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name='parallelformers', - version='1.2.1', + version='1.2.2', description= 'An Efficient Model Parallelization Toolkit for Deployment', long_description=long_description,