Change user-facing random variable API #1707
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR gets rid of RandomStream, and provides as an alternative random methods on RandomGeneratorType variables.
So one can do:
rng can obviously be a shared variable, and have an update {rng: next_rng}, which is a bit what RandomStream is doing under the hood.
However, everything is now explicit. There are no longer any default_updates, and unlike numpy the user is given the output
next_rngto use afterwards. This is a bit awkward, but it's the most explicit API?The RandomStream had important issues in rewrites, because of the
default_updategraphs are implicit, and when one mutates a graph with such variables they would also need to mutate thedefault_updategraph for the final thing to be correct.RandomVariable Ops will no longer hide the
next_rngoutput like they used to. There's a transition period forcing you to commit to the new flagreturn_next_rng, which will eventually default toTrueif unspecified