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

Waste Free SMC available for adaptive tempered and tempered SMC. #721

Merged
merged 19 commits into from
Aug 26, 2024

Conversation

ciguaran
Copy link
Contributor

@ciguaran ciguaran commented Aug 15, 2024

Although SMC base.py was ready for waste-free, tempered and adaptive tempered are coupled to using classic SMC (iterate MCMC and keep the last sample). This PR makes Waste-free available at all levels of the hierarchy.
#710

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.67%. Comparing base (20666de) to head (957b958).
Report is 16 commits behind head on main.

Files Patch % Lines
blackjax/smc/waste_free.py 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #721      +/-   ##
==========================================
- Coverage   98.72%   98.67%   -0.05%     
==========================================
  Files          59       60       +1     
  Lines        2746     2803      +57     
==========================================
+ Hits         2711     2766      +55     
- Misses         35       37       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

junpenglao
junpenglao previously approved these changes Aug 15, 2024
@AdrienCorenflos
Copy link
Contributor

By the way, whilst we are on that, I remember being a bit dubious about waste free for parallel environments: when you have a lot of processors the analysis in the paper does not hold anymore.
@hai-dang-dau have you ever done some back of the envelope calculations on this? I'd like to be able to recommend people to switch off waste free (and maybe increase the number of intermediary distributions in exchange?) if they have a certain number of processors.

@hai-dang-dau
Copy link

It's true that waste-free SMC shines best when the number of processors is small relative to the number of particles. (Say, a dozen of processors for several thousand of particles.) I think this is the case for most practical applications.

If your number of particles is comparable to that of processors (say, 500 processors and 500 particles), then yes standard SMC is better.

However, if you have that many processors, you probably have a lot of memory as well. When you increase the number of particles to about a million (still with 500 CPUs), waste-free starts to be preferable again.

@AdrienCorenflos
Copy link
Contributor

AdrienCorenflos commented Aug 16, 2024 via email

@hai-dang-dau
Copy link

In my previous post, by "processors" I meant the number of MCMC chains that can be run on parallel. Although GPU has a lot of parallel processing capacity, I'm not sure how this translates into the number of MCMC chains. The delicate point is that one MCMC chain itself involves a lot of parallelizable operations (ie matrix multiplications for calculating the likelihood or for generating preconditioned proposals). It is these primitive operations that are usually parallelized automatically by JAX/XLA, not the higher level operations that were taken into account in my reasoning above.

Having said that, it's true that we developed and tested waste-free SMC with CPUs in mind; so it'd definitely be relevant to have recommendations tailored to GPU-accelerated environment.

junpenglao
junpenglao previously approved these changes Aug 26, 2024
Copy link
Member

@junpenglao junpenglao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit

junpenglao
junpenglao previously approved these changes Aug 26, 2024
@junpenglao
Copy link
Member

junpenglao commented Aug 26, 2024

Feel free to merge after fixing the code style

@ciguaran
Copy link
Contributor Author

@junpenglao the review gets dismissed whenever we commit something new, even if it is just github's commiting a reviewer suggestion

@junpenglao junpenglao enabled auto-merge (squash) August 26, 2024 14:12
Copy link
Member

@junpenglao junpenglao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@junpenglao junpenglao merged commit b02b60b into blackjax-devs:main Aug 26, 2024
5 checks passed
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.

4 participants