Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Suggests:
mgcv,
mirai (>= 2.4.0),
modeldata,
mori,
probably,
scales,
spelling,
Expand Down
3 changes: 3 additions & 0 deletions R/loop_over_all_stages.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
}

split <- resamples$splits[[1]]
if (!is.null(static$mori_shared_name)) {
split$data <- mori::map_shared(static$mori_shared_name)
}
split_labs <- resamples |>
dplyr::select(dplyr::starts_with("id"))
# Determine if we're using prediction-based or model-based metrics
Expand Down
14 changes: 14 additions & 0 deletions R/tune_grid_loop.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ tune_grid_loop <- function(
inds <- vec_list_rowwise(inds)
}

# Share the full training data via mori to avoid serializing it to every
# worker. Instead, workers receive lightweight split objects (indices + schema
# only) and map the shared memory region directly.
mori_ref <- NULL
if (strategy != "sequential" && rlang::is_installed("mori")) {
full_data <- resamples[[1]]$splits[[1]]$data
mori_ref <- mori::share(full_data)
static$mori_shared_name <- mori::shared_name(mori_ref)
resamples <- purrr::map(resamples, function(res_row) {
res_row$splits[[1]]$data <- full_data[0L, ]
res_row
})
}

cl <- loop_call(control$parallel_over, strategy, par_opt)
res <- rlang::eval_bare(cl)

Expand Down
Loading