map
map(
models,
sample_kwargs=None,
*,
cache=True,
project=None,
nuts_sampler=None,
instance=None,
progress=True,
dashboard=None,
until=None,
overwrite=False,
)Fit many models in parallel on the cloud.
models is a list of pm.Model – vary priors, structure, or data for model comparison / sensitivity. sample_kwargs is a single dict of pm.sample kwargs applied to all, or a list aligned with models. Each model is uploaded once and the fits spawn concurrently; with no per-container input concurrency Modal fans them out across containers, so each fit is sized to its own model via Cls.with_options (cpu/memory) rather than to the first. Returns InferenceData in input order.
until enables adaptive early-stop (True -> Vehtari defaults, or a dict overriding r_hat / ess): each fit stops once every scalar param clears the target, with draws= as the cap. Applies to the whole batch (nutpie / pymc samplers only); per-model targets are still possible by putting until in each model’s sample_kwargs dict.
overwrite=True ignores any cached result, re-runs every model, and replaces the stored entry (cache=False instead skips the cache entirely, saving nothing).
A live dashboard (on by default; pass dashboard=False to opt out) serves an overview of all models with drill-in per-model pages (chains, convergence, traces) and global / per-model Stop. Each worker writes its own progress into a shared Modal Dict keyed by its model, so the spawned fits surface live without streaming back to the client. The printed line-level progress is job-level only.
Example::
import arviz as az
idatas = cp.map([pooled, hierarchical, per_county], {"draws": 1000})
az.compare({"pooled": idatas[0], "hier": idatas[1], "county": idatas[2]})