Cohorts across an allocation¶
These functions support a fit that runs on several processes or across several allocations. See fitting a cohort across an allocation.
diff_soup.inference.balance_owners
¶
balance_owners(experiments: Any, lanes: int, *, weight: Callable | None = None) -> Any
Reorder a study's experiments so that equal consecutive blocks of owners carry balanced loads.
The owners are the members of the study's outermost level or cluster, or else the experiments themselves. Each owner's experiments stay together, and the owners are assigned heaviest first, each to the lightest block with room.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiments
|
Any
|
A |
required |
lanes
|
int
|
The number of consecutive blocks, filled in order with |
required |
weight
|
Callable | None
|
A function giving the load of one experiment, or |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The reordered study, or a tuple of the reordered experiments. |
diff_soup.inference.prepare_windows
¶
prepare_windows(experiment: Experiment, trajectory: Any = None, **problem_kwargs: Any) -> Any
Compute and store the window starts of a multiple-shooting experiment before a fit.
A later fit of the same experiment loads them instead of solving again. Set
DIFFSOUP_CACHE_DIR to a shared directory for a run of several processes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment
|
Experiment
|
The experiment whose windows to initialize. |
required |
trajectory
|
Any
|
A |
None
|
**problem_kwargs
|
Any
|
Further keywords of |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The key the windows are stored under, or |
diff_soup.inference.checkpointed_map
¶
checkpointed_map(fn: Callable, items: Sequence[Any], *, ledger_path: Any, resume: bool = True, execution: str = 'serial', device_groups: Any = None, on_conflict: str = 'error') -> CampaignResult
Map a function over independent tasks, recording each outcome in a JSON ledger so a rerun resumes.
Each item carries a task_id that stays the same across restarts. A result is stored as JSON
and comes back in that form. A task that raises is recorded as failed, and the others still
run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
The task, a function of one item returning its result. |
required |
items
|
Sequence[Any]
|
The tasks, mappings or objects with a unique non-empty string |
required |
ledger_path
|
Any
|
The JSON file the ledger is written to, whole, after every change. |
required |
resume
|
bool
|
Whether to read the ledger first, keep its accepted tasks, and run the failed and interrupted ones again. |
True
|
execution
|
str
|
|
'serial'
|
device_groups
|
Any
|
Disjoint JAX submeshes for |
None
|
on_conflict
|
str
|
|
'error'
|
Returns:
| Type | Description |
|---|---|
CampaignResult
|
A |
diff_soup.inference.world
¶
world() -> World
Return this process's rank and the number of processes in the run.
A process not launched under MPI, or one using jax.distributed, is process 0 of 1. Launch
several processes with python -m mpi4py, which needs mpi4py installed.
Returns:
| Type | Description |
|---|---|
World
|
A named tuple |