AdvancedMH.jl icon indicating copy to clipboard operation
AdvancedMH.jl copied to clipboard

Vectorised MH

Open treigerm opened this issue 5 years ago • 3 comments

I was wondering whether there is a vectorised implementation of MH (i.e. running several chains in parallel) available in this repo? I've seen that there is a vectorised implementation in AdvancedHMC but I couldn't find any information whether it's available for MH as well.

treigerm avatar Oct 12 '20 14:10 treigerm

If you want to run several chains in parallel, you can use

chain = sample(model, spl, MCMCThreads(), 100000, 4; param_names=["μ", "σ"], chain_type=Chains)

The above is adapted from the README example. chain would then have 4 separate chains in it, each with 100,000 samples.

cpfiffer avatar Oct 12 '20 15:10 cpfiffer

Thanks! I'm aware of the support for using multiple threads. I'm interested in a vectorised implementation because then I could potentially run parallel chains on the GPU which should give better scaling than using multi-threading (if I'm not mistaken). I'm happy to help with adapting any of the existing code to be vectorised if someone gives me pointers about what the general strategy for that should be.

treigerm avatar Oct 12 '20 17:10 treigerm

I actually have no idea how that would work -- my understanding is that GPUs work best when you have many identical instructions. I don't know how that would fit into the current framework.

I'll poke around a little and see what could be done here.

@mohamed82008 or @devmotion to you have any thoughts?

cpfiffer avatar Oct 12 '20 18:10 cpfiffer