Skip to content

Commit 745f5cb

Browse files
ayushidalmiafacebook-github-bot
authored andcommitted
Update seed (#869)
Summary: Pull Request resolved: #869 In this diff add some more configs to set seed Created from CodeHub with https://fburl.com/edit-in-codehub Reviewed By: JKSenthil Differential Revision: D59824341 fbshipit-source-id: 0a9ac5729fa1928f4dcd1be4cfce53a0243980e7
1 parent fac9d15 commit 745f5cb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tests/framework/test_auto_unit_gpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def forward(self, x):
135135
return x
136136

137137
# so all ranks start with same initialized weights
138-
seed(0)
139138
device = init_from_env()
139+
seed(0)
140140
my_module = Net()
141141

142142
auto_unit = DummyAutoUnit(

torchtnt/utils/env.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def seed(seed: int, deterministic: Optional[Union[str, int]] = None) -> None:
140140
torch.manual_seed(seed)
141141
np.random.seed(seed)
142142
random.seed(seed)
143+
os.environ["PYTHONHASHSEED"] = str(seed)
143144

144145
if deterministic is not None:
145146
_log.debug(f"Setting deterministic debug mode to {deterministic}")
@@ -155,3 +156,5 @@ def seed(seed: int, deterministic: Optional[Union[str, int]] = None) -> None:
155156
torch.backends.cudnn.benchmark = False
156157
# reference: https://docs.nvidia.com/cuda/cublas/index.html#cublasApi_reproducibility
157158
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8"
159+
if deterministic_debug_mode == 2:
160+
set_float32_precision("highest")

0 commit comments

Comments
 (0)