Skip to content

Commit

Permalink
PYTHONHASHSEED needs to be in the range of [0,2**32 - 1]
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
tianyu-l committed Dec 12, 2024
1 parent 0186284 commit 61c08eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion torchtitan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def set_determinism(

# The native RNGs and python RNG may not be important, except for the 1-D PP case, but we seed them for consistency.
torch.manual_seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
# PYTHONHASHSEED can be a decimal number in the range [0,2**32 - 1]
os.environ["PYTHONHASHSEED"] = str(seed % (2**32 - 1))

# As long as we are not in the 1-D (PP-only) case, we will have a seed to use for all ranks of the SPMD mesh.
# IF PP is also used, this seed is unique per PP rank.
Expand Down

0 comments on commit 61c08eb

Please sign in to comment.