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

hmc_tm: add real reproducible random numbers mode #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kostrzewa
Copy link
Member

this will keep the RNG state consistent across executions of different numbers of trajectories (say you have a serial run doing 1000 trajectories at a time in 10 goes and a parallel run doing 10000 trajectories in one run, with this mode, the two runs will still have exactly the same random numbers because the RNG state is saved to file between executions of hmc_tm)

This works only when using reproducible_random_numbers and when the random numbers are requested only through functions supporting this mode.

@kostrzewa kostrzewa force-pushed the save_ranlux_state branch 5 times, most recently from ce46552 to ca6f667 Compare November 18, 2014 15:04
@kostrzewa kostrzewa changed the title hmc_tm: add real reproducible randum numbers mode hmc_tm: add real reproducible random numbers mode Nov 19, 2014
@urbach
Copy link
Contributor

urbach commented Nov 19, 2014

@kostrzewa why using a file. We could reset before each trajectory the RNG state to something depending only on the trajectory number. This would automatically lead to reproducible random numbers if chosen in the input file?

@kostrzewa
Copy link
Member Author

That's also acceptable I guess, except if you want to do this with two different initial seeds. I guess one could of course just use seed^trajcounter -> start_ranlux(seed,level) before each trajectory, the overhead should be minimal and ranlux is probably robust enough that this kind of constant restart should not pose a problem. Is there any chance of seed^trajcounter being non-unique? (i.e. giving the same result for the same seed but two different values of trajcounter)

@kostrzewa
Copy link
Member Author

Is there any chance of seed^trajcounter being non-unique? (i.e. giving the same result for the same seed but two different values of trajcounter)

I guess this could happen if one of them is int while the other is long and then it probably depends on the compiler whether the one is truncated or the other is cast to long. The same applies for signed and unsigned: (int)( -(2^31-1) ) and (unsigned int)(2^32-1) would have the same binary representation.

@urbach
Copy link
Contributor

urbach commented Nov 21, 2014

yes, it might happen that we have for a trajectory the same random numbers. this is not a problem, it only becomes one when it happens regular and often. Can't we make it as unique as possible?

@kostrzewa
Copy link
Member Author

yes, it might happen that we have for a trajectory the same random numbers. this is not a problem, it only becomes one when it happens regular and often. Can't we make it as unique as possible?

Are you sure that can happen? I don't really see how. As long as seed and trajcounter are the same data type the XOR should not cause the same seed to be used ever (in a given run that is and as long as you do fewer than 2^31 trajectories). So I think that as long as one disables the computation of the local seed in the "truly reproducible" case, your idea should achieve the required effect.

I sort of liked the solution with the file because it allows "exporting" the RNG state to a different run even without having matching trajectory numbers.

@urbach
Copy link
Contributor

urbach commented Nov 21, 2014

The only "problem" I have with the file version is that you loose meta-data and files might get lost, but it could be added optional? My proposal is a bit more fool save...

@kostrzewa
Copy link
Member Author

Okay, I will implement both, it should not be difficult to do.

… RNG state consistent

across executions of different numbers of trajectories (say you have a serial run doing
1000 trajectories at a time in 10 goes and a parallel run doing 10000 trajectories
in one run, with this mode, the two runs will still have exactly the
same random numbers because the RNG state is saved to file between executions of hmc_tm)
@urbach
Copy link
Contributor

urbach commented Nov 17, 2016

Is this in principle ready to be merged?

@kostrzewa
Copy link
Member Author

Your proposal is still missing, other than that, I've tested this at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants