-
Notifications
You must be signed in to change notification settings - Fork 107
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
pmap seems to drastically improve performance in the example notebook #251
Comments
It is expected that pmap is faster than vmap using NUTS: in vmap at each sampling step, we are waiting for the chain with the longest leapfrog. This could potentially explain the CPU utilization as most of the time the other chains are finished one sample and just waiting for few chains with large number of leapfrog |
And yes I think it is a great idea to add a pmap example! I think we dont have a lot of those currently. |
I agree with what @junpenglao said: I would expect that to happen with NUTS; each step can only be as fast as the slowest chain and these delays can add up to quite a lot after a few thousand steps. As opposed to Would you like to add an example with |
Thanks a lot for the explanation! I'll be happy to open a PR adding a small section with |
Apologies, I forgot about this issue, I'll get to it this week and open a PR once #243 is merged. |
No problem! Thank you for letting us know. |
Description
I am running
blackjax
inWSL2
on a 32 core CPU.I was playing with the example notebook (https://blackjax-devs.github.io/blackjax/examples/Introduction.html#),
and noticed that the CPU utilization is actually quite low when running multiple chains.
I have modified the code by first running
Then I re-used the inference loop from the single-chain example, but instead of using
vmap
I usedpmap
to parallelize the execution:And this seems to cut the running from 2 minutes to 3 seconds
Am I doing something wrong here, or should the example actually be adjusted to use
pmap
?Reproducing
See full notebooks here:
https://gist.github.com/elanmart/810f1964738b0ddd8f108b17b7969f82
Setup
The text was updated successfully, but these errors were encountered: