What is the max seed you can set up?

What is the maximum seed one can use with:

torch.manual_seed(seed)

Is it the same maximum seed as with CUDA set seed operations?

Thanks for the answer.

From the docs of torch.manual_seed:

seed (int) – The desired seed. Value must be within the inclusive range [-0x8000_0000_0000_0000, 0xffff_ffff_ffff_ffff]. Otherwise, a RuntimeError is raised. Negative inputs are remapped to positive values with the formula 0xffff_ffff_ffff_ffff + seed.

So the largest valid value would be 2**64-1:

torch.manual_seed(18446744073709551615) # works
torch.manual_seed(2**64-1) # works

torch.manual_seed(18446744073709551615+1) # fails
# > RuntimeError: Overflow when unpacking long
torch.manual_seed(2**64) # fails
# > RuntimeError: Overflow when unpacking long
1 Like