libEnsemble is a Python library for coordinating dynamic ensembles of calculations in parallel. libEnsemble uses a manager process to allocate work to multiple worker processes. A libEnsemble worker is the smallest indivisible unit that can perform calculations. libEnsemble’s work is governed by three routines, collectively known as user functions:
gen_f: Generates inputs to
sim_f: Evaluates a simulation or other evaluation based on output from
alloc_f: Decides whether
gen_fshould be called (and with what input/resources) as workers become available
alloc_f, and calling scripts can be found in
examples/ directory. In order to enable portability, an executor
interface is supplied for users to execute and monitor external applications in their
alloc_f tells each available worker to call
sim_f with the
highest priority unit of work from
gen_f. If a worker is idle and there is
gen_f output to give, the worker is told to call
libEnsemble uses a NumPy structured array known as the history array to keep a record of all simulations. The global history array is stored on the manager, while selected rows and fields of this array are passed to and from user functions.
Example Use Cases
Below are some expected libEnsemble use cases that we support (or are working to support) and plan to have examples of:
A user wants to optimize a simulation calculation. The simulation may already be using parallel resources but not a large fraction of some computer. libEnsemble can coordinate the concurrent evaluation of the simulation
sim_fat various parameter values based on candidate parameter values from
gen_f(possibly after each
A user has a
gen_fthat produces meshes for a
sim_f. Given the
gen_fcan refine a mesh or produce a new mesh. libEnsemble can ensure that the calculated meshes can be used by multiple simulations without requiring movement of data.
A user wants to evaluate a simulation
sim_fwith different sets of parameters, each drawn from a set of possible values. Some parameter values are known to cause the simulation to fail. libEnsemble can stop unresponsive evaluations and recover computational resources for future evaluations. The
gen_fcan possibly update the sampling after discovering regions where evaluations of
A user has a simulation
sim_fthat requires calculating multiple expensive quantities, some of which depend on other quantities. The
sim_fcan observe intermediate quantities in order to stop related calculations and preempt future calculations associated with poor parameter values.
A user has a
sim_fwith multiple fidelities, with the higher-fidelity evaluations requiring more computational resources, and a
alloc_fthat decides which parameters should be evaluated and at what fidelity level. libEnsemble can coordinate these evaluations without requiring the user to know parallel programming.
A user wishes to identify multiple local optima for a
sim_f. Furthermore, sensitivity analysis is desired at each identified optimum. libEnsemble can use the points from the APOSMM
gen_fto identify optima; and after a point is ruled to be an optimum, a different
gen_fcan produce a collection of parameters necessary for sensitivity analysis of
Combinations of these use cases are supported as well. An example of such a combination is using libEnsemble to solve an optimization problem that relies on simulations that fail frequently.
Here we define some terms used throughout libEnsemble’s code and documentation. Although many of these terms seem straight-forward, defining such terms assists with keeping confusion to a minimum when communicating about libEnsemble and its capabilities.
Manager: Single libEnsemble process facilitating communication between other processes. Within libEnsemble, the Manager process configures and passes work to and from the workers.
Worker: libEnsemble processes responsible for performing units of work, which may include submitting or executing tasks. Worker processes run generation and simulation routines, submit additional tasks for execution, and return results to the manager.
Calling Script: libEnsemble is typically imported, parameterized, and initiated in a single Python file referred to as a calling script.
gen_ffunctions are also commonly configured and parameterized here.
User function: A generator, simulator, or allocation function. These are python functions that govern the libEnsemble workflow. They must conform to the libEnsemble API for each respective user function, but otherwise can be created or modified by the user. libEnsemble comes with many examples of each type of user function.
Executor: The executor can be used within user functions to provide a simple, portable interface for running and managing user tasks (applications). There are multiple executors including the
BalsamExecutor. The base
Executorclass allows local sub-processing of serial tasks.
Submit: Enqueue or indicate that one or more jobs or tasks needs to be launched. When using the libEnsemble Executor, a submitted task is executed immediately or queued for execution.
Tasks: Sub-processes or independent units of work. Workers perform tasks as directed by the manager; tasks may include submitting external programs for execution using the Executor.
Persistent: Typically, a worker communicates with the manager before and after initiating a user
sim_fcalculation. However, user functions may also be constructed to communicate directly with the manager, for example, in order to efficiently maintain and update data structures instead of communicating them between manager and worker. These calculations and the workers assigned to them are referred to as persistent.
Resource Manager libEnsemble has a built-in resource manager that can detect (or be provided with) a set of resources (e.g., a node-list). Resources are divided up amongst workers (using resource sets), and can be dynamically reassigned.
Resource Set: The smallest unit of resources that can be assigned (and dynamically reassigned) to workers. By default it is the provisioned resources divided by the number of workers (excluding any workers given in the
zero_resource_workerslibE_specs option). However, it can also be set directly by the
resource setsenumerated on a node (starting with zero). If a resource set has more than one node, then each node is considered to have slot zero.