distributed

class DistributedExperiment(num_runs, *, random_state=None)

Bases: Experiment

To run experiments in parallel using MPI (via mpi4py).

Parameters:
  • num_runs (int) – Number of runs to perform.

  • random_state (int | Generator | None, default: None) – Random state to use for reproducibility.

add(data)

Add data of the current run to the distributed experiment. Note that this should be only used once per run.

Return type:

None

Parameters:

data (Any)

barrier()

Synchronize all MPI processes.

Return type:

None

broadcast(data)

Broadcast data to all processes.

Ensures that all processes are synchronized before broadcasting, see also (barrier()).

Parameters:

data (TypeVar(T)) – Data to broadcast.

Return type:

TypeVar(T)

Returns:

Broadcasted data.

collect(broadcast=True)

Collect data from all MPI processes and return a sorted dictionary of run data.

Parameters:

broadcast (bool) – Whether to broadcast the collected data to all processes.

Return type:

dict[int, Any] | None

Returns:

A sorted dictionary of run data if the current process is the root, otherwise None.

property is_root: bool

Property that checks if the current MPI process is the root process.

property performs_run: bool

Property that checks if the current MPI process should perform a run when iterating over DistributedExperiment.