-
Notifications
You must be signed in to change notification settings - Fork 22
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
Should we make a YGM RNG helper? #131
Comments
There are currently two open pull requests that use randomization, so it would make sense for I'm thinking that a |
I also concur that we'll want a to set rank RNG seeds via something like Are there scenarios where we might want ranks to share seeds? I've encountered this in distributed memory optimization, where you're evaluating an objective function globally via |
We may want to have multiple independent RNGs that are seeded differently. That's why I was thinking about something outside of comm, so that you could define more than one of them, as needed. Obviously it will need the comm to set itself up correctly, much like the containers do. How about: ygm::random rng(comm, 42); // sets up based on a global seed of 42, using default std::default_random_engine ygm::random rng2(comm); // uses std::random_device to initialize global seed, then follows same rank offset mechanisms. ygm::randomstd::mt19937 rng3(comm, 42); // customizes underlying RNG engine based on standard C++ interface. auto dice = rng.uniform_int(1,6); // helper functions for the standard distributions, add esoteric ones as needed. Saving and restoring the distributed RNGs is also important for some apps. |
hash(seed + rank), but at very high rank count, we should probably should really do a global duplication detection check. Supporting algorithms that want to sample many independent runs of code without ever encountering a duplicate seed might take something like: There probably are some uses cases where we would want the same RNG seed on every rank; however, that is easy enough to do with just standard sequential code and a broadcast for the seed. Perhaps we don't try to support this directly in YGM. |
I'm in favor of a YGM rng interface that is a standalone object in the spirit you describe above. The one aspect I'm not positive on is adding the distributions as a method on the rng objects. This is definitely a less confusing interface than sticking with STL but may have drawbacks. My main concerns are:
|
I see your point. we could have the YGM interface decay into a reference to its underlying std::rng so that users can construct their own distributions. |
@steiltre @bwpriest @LFletch1
What are you're thoughts on making a ygm::random that helps initialize distributed STD RNGs from a common base seed?
It could be templated by the RNG engine, defaulting to std::default_random_engine.
Base seed, or single random device value, then apply some deterministic rank offset mechanism.
Helper functions for pulling out the common distribution types we use.
The text was updated successfully, but these errors were encountered: