Parallelization of loo using mirai and mori#378
Draft
florence-bockting wants to merge 6 commits into
Draft
Conversation
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 2bee14f is merged into master:
|
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #308
parallel::mclapply()/parLapply()with mirai + mori for per-observation parallelism (cross-platform, including Windows).cores,loo.daemons/LOO_DAEMONS), andmirai::daemons()(remote/SSH/HPC).What changed
Core (
R/parallel.R):with_loo_daemons(),loo_map(),loo_pool_is_local(),loo_persist_config().Parallelized functions:
loo()(function method),psis()/sis()/tis(),relative_eff(),loo_subsample(),loo_moment_match(),loo_model_weights().Pool precedence: connected pool (user or persistent) always wins →
coresis ignored. Local pools use mori zero-copy forbroadcastobjects (e.g.draws); remote pools serialize.Also:
mirai+moriin DESCRIPTION;vignettes/loo2-parallel.Rmd;tests/testthat/test_parallel.R;benchmark/scripts +bench-comparison.md.Review guide
vignettes/loo2-parallel.Rmdshows the user-facing modelR/parallel.Rincludes the pool lifecycle +loo_map()transportloo.function:R/loo.R→with_loo_daemons()→loo_map(broadcast = list(draws = ...))tests/testthat/test_parallel.Rinclude serial/parallel equivalence, pool precedencebenchmark/README.mdincludes first attempt of a small baseline vs new comparison (see first results inbenchmark/bench-comparison.md)Initial benchmarks (Linux, one machine):
loo.function+ largedrawsbenefits most (~4× with persistent pool); matrixpsis()does not (communication-bound); per-call pool pays ~1s spawn/teardown per call.Follow-up work
benchmark/.mirai::daemons(url = ..., remote = ssh_config(...))).vignettes/loo2-parallel.Rmdwith assumptions, when-to-use guidance, function-specific notes, memory model.Current limitations of implementation
psis()rarely speeds up (large data shipped per worker).cores > 1can be slower than serial on small problems withoutloo.daemons.