Skip to contents

run_baseline_config_parallel_bis() is the large-model counterpart of run_baseline_config_parallel(). It is designed to remain stable on very large NIMBLE models (e.g., >80,000 nodes; WGNAS-scale) and on HPC/cluster environments, where naïve PSOCK parallelization can trigger memory blow-ups or fail due to missing closure bindings on workers.

Compared to the non-_bis function, this version:

  • supports resolving build_fn by name (character) on workers, including optional namespace lookup;

  • supports injecting build_fn as text (opts$build_fn_text) and exporting the captured environment of the builder closure (opts$build_fn_object, opts$builder_env_names) to prevent errors like “objet 'hindcast_' introuvable”;

  • avoids mandatory disk I/O (no log files required), suitable for clusters with restricted write access;

  • times only the MCMC execution phase (optionally using $run(time=TRUE)), keeping compilation outside the per-chain runtime by construction;

  • says memory: optional worker-side gc() clean-up after each chain to reduce peak usage on large graphs;

  • can optionally return the actual nimbleMCMCconf used on each worker (opts$return_conf = TRUE) so downstream diagnostics can reuse the exact sampler/monitor configuration.

The function assumes that build_fn returns at least a list with model and conf (plus optional monitors). The returned object includes samples, runtime_s, runtime_by_chain, and sampler_times, and optionally conf_by_chain.

Usage

run_baseline_config_parallel_bis(
  build_fn,
  niter,
  nburnin,
  thin,
  monitors = NULL,
  nchains = 3L,
  seed = 1L,
  n_cores = nchains,
  extra_export = character(0),
  samplesAsCodaMCMC = FALSE,
  export_global = FALSE,
  opts = NULL
)

Arguments

build_fn

A builder function, or a single character string giving the builder name. The builder must return a list with at least model and conf.

niter, nburnin, thin

MCMC settings passed to NIMBLE.

monitors

Optional monitor vector (if NULL, may fall back to parts$monitors).

nchains

Number of parallel chains to run.

seed

Base RNG seed (each chain uses seed + chain_id - 1).

n_cores

Number of PSOCK workers.

extra_export

Optional additional symbols to export to workers.

samplesAsCodaMCMC

Passed to nimble::runMCMC() fallback (when not using $run()).

export_global

If TRUE, exports the whole master .GlobalEnv (not recommended unless needed).

opts

List of advanced options (cluster type, packages, builder injection, timings).

Value

A list with:

  • samples: list of per-chain samples (matrix or coda, depending on options),

  • runtime_s: wall-clock time of the full parallel phase,

  • runtime_by_chain: numeric vector of per-chain MCMC runtimes,

  • sampler_times: list of Cmcmc$getTimes() outputs (if enabled),

  • conf_by_chain: optional list of nimbleMCMCconf (if opts$return_conf = TRUE),

  • opts_effective: the effective options used.