Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output is not reproducible #163

Open
baraaorabi opened this issue Apr 14, 2022 · 1 comment
Open

Output is not reproducible #163

baraaorabi opened this issue Apr 14, 2022 · 1 comment
Labels

Comments

@baraaorabi
Copy link

In line 1505 of the simulator.py script:

NanoSim/src/simulator.py

Lines 1504 to 1506 in 23911b6

for i in range(num_threads):
np.random.seed()
random.seed()

The seed is reset before each process/thread is started. This overrides the setting of the random seed in here:

NanoSim/src/simulator.py

Lines 2180 to 2181 in 23911b6

random.seed(int(args.seed))
np.random.seed(int(args.seed))

It also causes the the output of Nanosim to be not reproducible despite using the same value for the --seed arg. I think these two lines (L1505 and L1506) should be dropped. Or maybe they should be replaced with something like?

deterministically_random_seed = random.getrandbits(32)
np.random.seed(deterministically_random_seed) 
random.seed(deterministically_random_seed)

This would give each thread a new random seed that is deterministically defined by the --seed value which should ensure reproducibility across runs with the same --seed.

@kmnip
Copy link
Collaborator

kmnip commented Apr 15, 2022

Thanks Baraa!
I agree with you. I have suspicions that this is an issue when I was reading through simulator.py recently.
@SaberHQ and I will look into it!

@SaberHQ SaberHQ added the bug label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants