-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Bump numpy version due to use of Generator.spawn
only available in >=1.25
#7607
Conversation
Generator.spawn
for compatibility with older versions of numpy
pymc/step_methods/hmc/base_hmc.py
Outdated
@@ -166,7 +166,7 @@ def __init__( | |||
if scaling is None and potential is None: | |||
mean = floatX(np.zeros(size)) | |||
var = floatX(np.ones(size)) | |||
potential = QuadPotentialDiagAdapt(size, mean, var, 10, rng=self.rng.spawn(1)[0]) | |||
potential = QuadPotentialDiagAdapt(size, mean, var, 10, rng=self.rng) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this spawning a new rng?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the potential and the step method have to own independent generators. If they were to share the generator, the sampling state will lose that information, and the step method you’d get from the sampling state would produce different draws than the original step method with a shared generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one potential per step, so makes sense to have a single source of randomness. The state of the potential should be a subset of the the state of the step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I think that you get that with the spawning. Both streams will be independent, but providing the rng to the step method will determine the stream that is produced by the potential
9b4cea3
to
8f65660
Compare
8f65660
to
5dbcb9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. I’m not sure if there were any other files that needed the numpy version bump. I suppose that the tests should pick that up.
5dbcb9d
to
8f09d14
Compare
Generator.spawn
for compatibility with older versions of numpyGenerator.spawn
only available in numpy>1.25
Generator.spawn
only available in numpy>1.25Generator.spawn
only available in >=1.25
5a8bf8c
to
50e034b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7607 +/- ##
==========================================
- Coverage 92.85% 92.84% -0.01%
==========================================
Files 106 106
Lines 17742 17745 +3
==========================================
+ Hits 16474 16476 +2
- Misses 1268 1269 +1
|
Introduced in #7508 (specifically 4ea1406)
Closes #7605
Actually #7508 had a subtle breaking change, in that it used to be possible to seed each chain separately by passing a list of integers/rngs. Now there's no such control. Hopefully nobody needs that behavior these days...
📚 Documentation preview 📚: https://pymc--7607.org.readthedocs.build/en/7607/