Parallelization of loo using mirai and mori#378
Draft
florence-bockting wants to merge 11 commits into
Draft
Conversation
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 30834a4 is merged into loo-v3.0.0:
|
6 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## loo-v3.0.0 #378 +/- ##
==============================================
+ Coverage 92.70% 94.39% +1.68%
==============================================
Files 31 32 +1
Lines 3029 3121 +92
==============================================
+ Hits 2808 2946 +138
+ Misses 221 175 -46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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).mirai::daemons()(local, remote/SSH/HPC); a connected pool always wins.loo_mirai()(optional n_daemons for one-off pools).coresargument andoptions(mc.cores)as loo parallelism controls (still functional as a per-call local pool bridge when> 1and no pool is connected; once-per-session warning).options(loo.cores)(deprecated since 2.x).What changed
Core (
R/parallel.R):with_loo_daemons(),loo_map(),loo_pool_is_local(),loo_n_workers(),loo_mirai(); deprecation helpers forcores/mc.cores.Parallelized functions:
loo()(function method),psis()/sis()/tis(),relative_eff(),loo_subsample(),loo_moment_match(),loo_model_weights().Pool precedence: any connected
mirai::daemons()pool (user-managed) always wins > deprecatedcoresis ignored. Local pools use mori zero-copy for broadcast objects (e.g. draws); remote pools serialize (with conservative chunking when broadcasting).Also:
mirai+moriin DESCRIPTION;vignettes/loo2-parallel.Rmd;vignettes/migration-guide.Rmd;tests/testthat/test_parallel.R;benchmark/scripts +bench-comparison.md.Review guide
vignettes/loo2-parallel.Rmdshows the user-facing modelvignettes/migration-guide.Rmdprovides a parallelization migration table and examplesR/parallel.Rincludes the pool lifecycle +loo_map()transport,loo_mirai()tests/testthat/test_parallel.Rinclude serial/parallel equivalence, pool precedence,loo_mirai(), deprecation warningsbenchmark/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.This PR has been developed with assistance of Cursor.