Reloo multicore for chains and refits?

Hi there - I’m able to get reloo to run in parallel for the 3 chains of a brms model, but it needs to refit 14 times. I’m wondering if there’s any way to do the refits in parallel as well (or are they dependent on each other?). Here’s my code:

loo(mod, reloo = TRUE, reloo_args = list(cores = 24))

I also have multiple models to do this for and imagine that I could at least have multiple loo functions going at once (using mcapply etc.) even if the refits for a given model need to be sequential.

  • Operating System: CentOS 7
  • brms Version: 2.19.0
  • loo Verion: 2.6.0

reloo supports parallelization via future. See ?reloo. It should work too if you directly run loo but it may be less awkard to first run loo_mod <- loo(mod) and then reloo(mod, loo = loo_mod).

2 Likes

Thanks. I tried splitting loo and reloo, but I’m still only getting parallelization based on chains (3 cores running) instead of chains and refits. Is there anything I should include for future_args?

Here’s the code I’m using. There are 14 refits that it needs to do, but it seems like it’s only doing one at a time with 3 chains in parallel. Unless I’m missing something about refits and chains etc.

loo_mod <- loo(mod)
reloo(mod, loo = loo_mod, cores = 24)

You should not use cores for parallelzation across model fits. Rather, use future outside of the call. E.g.

library(future)
plan(multisession, workers = 4)
reloo(mod, loo = loo_mod, cores = 3)
plan(sequential)

The future package has extensive documentation that describes it’s general use.

2 Likes

Got it! This is hugely helpful and will save a ton of time. Thanks so much.

1 Like