Skip to content

Commit e16659f

Browse files
committed
Merge branch 'refactor/gen_on_manager_true' into refactor/gen_on_worker_try_again
2 parents 94fc628 + 6505cd8 commit e16659f

52 files changed

Lines changed: 303 additions & 367 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ repos:
3737
rev: v1.19.1
3838
hooks:
3939
- id: mypy
40+
args: [--config-file=pyproject.toml]

docs/FAQ.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ We recommend using the following options to help debug workflows::
1313
logger.set_level("DEBUG")
1414
libE_specs["safe_mode"] = True
1515

16-
To make it easier to debug a generator try setting the **libE_specs** option ``gen_on_manager``.
17-
To do so, add the following to your calling script::
18-
19-
libE_specs["gen_on_manager"] = True
20-
2116
With this, ``pdb`` breakpoints can be set as usual in the generator.
2217

2318
For more debugging options see "How can I debug specific libEnsemble processes?" below.

docs/data_structures/libE_specs.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ libEnsemble is primarily customized by setting options within a ``LibeSpecs`` in
99
1010
from libensemble.specs import LibeSpecs
1111
12-
specs = LibeSpecs(gen_on_manager=True, save_every_k_gens=100, sim_dirs_make=True, nworkers=4)
12+
specs = LibeSpecs(save_every_k_gens=100, sim_dirs_make=True, nworkers=4)
1313
1414
.. dropdown:: Settings by Category
1515
:open:
@@ -26,9 +26,8 @@ libEnsemble is primarily customized by setting options within a ``LibeSpecs`` in
2626
**nworkers** [int]:
2727
Number of worker processes in ``"local"``, ``"threads"``, or ``"tcp"``.
2828

29-
**gen_on_manager** [bool] = False
30-
Instructs Manager process to run generator functions.
31-
This generator function can access/modify user objects by reference.
29+
**gen_on_worker** [bool] = False
30+
Instructs Worker process to run generator instead of Manager.
3231

3332
**mpi_comm** [MPI communicator] = ``MPI.COMM_WORLD``:
3433
libEnsemble MPI communicator.

docs/overview_usecases.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ to support):
5353
.. dropdown:: **Click Here for Use-Cases**
5454

5555
* A user wants to optimize a simulation calculation. The simulation may
56-
already be using parallel resources but not a large fraction of a
57-
computer. libEnsemble can coordinate concurrent evaluations of the
56+
already be using parallel resources but not a large fraction of a
57+
computer. libEnsemble can coordinate concurrent evaluations of the
5858
simulation ``sim_f`` at multiple parameter values based on candidate parameter
5959
values produced by ``gen_f`` (possibly after each ``sim_f`` output).
6060

@@ -117,7 +117,7 @@ its capabilities.
117117
* **User function**: A generator, simulator, or allocation function. These
118118
Python functions govern the libEnsemble workflow. They
119119
must conform to the libEnsemble API for each respective user function, but otherwise can
120-
be created or modified by the user.
120+
be created or modified by the user.
121121
libEnsemble includes many examples of each type.
122122

123123
* **Executor**: The executor provides a simple, portable interface for
@@ -138,14 +138,14 @@ its capabilities.
138138
allowing them to maintain and update data structures efficiently. These
139139
calculations and their assigned workers are referred to as *persistent*.
140140

141-
* **Resource Manager**: libEnsemble includes a built-in resource manager that can detect
141+
* **Resource Manager**: libEnsemble includes a built-in resource manager that can detect
142142
(or be provided with) available resources (e.g., a node list). Resources are
143143
divided among workers using *resource sets* and can be dynamically
144144
reassigned.
145145

146146
* **Resource Set**: The smallest unit of resources that can be assigned (and
147147
dynamically reassigned) to workers. By default this is the provisioned resources
148-
divided by the number of workers (excluding any workers listed in the
148+
divided by the number of workers (excluding any workers listed in the
149149
``zero_resource_workers`` ``libE_specs`` option). It can also be set
150150
explicitly using the ``num_resource_sets`` ``libE_specs`` option.
151151

docs/platforms/aurora.rst

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ simulations for each worker:
5757
.. code-block:: python
5858
5959
# Instruct libEnsemble to exit after this many simulations
60-
ensemble.exit_criteria = ExitCriteria(sim_max=nsim_workers*2)
60+
ensemble.exit_criteria = ExitCriteria(sim_max=nsim_workers * 2)
6161
6262
Now grab an interactive session on two nodes (or use the batch script at
6363
``../submission_scripts/submit_pbs_aurora.sh``)::
@@ -115,26 +115,6 @@ will use one GPU tile)::
115115

116116
python run_libe_forces.py -n 25
117117

118-
Running generator on the manager
119-
--------------------------------
120-
121-
An alternative is to run the generator on a thread on the manager. The
122-
number of workers can then be set to the number of simulation workers.
123-
124-
Change the ``libE_specs`` in **run_libe_forces.py** as follows:
125-
126-
.. code-block:: python
127-
128-
nsim_workers = ensemble.nworkers
129-
130-
# Persistent gen does not need resources
131-
ensemble.libE_specs = LibeSpecs(
132-
gen_on_manager=True,
133-
134-
then we can run with 12 (instead of 13) workers::
135-
136-
python run_libe_forces.py -n 12
137-
138118
Dynamic resource assignment
139119
---------------------------
140120

docs/platforms/perlmutter.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,27 +105,6 @@ To see GPU usage, ssh into the node you are on in another window and run::
105105

106106
watch -n 0.1 nvidia-smi
107107

108-
Running generator on the manager
109-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110-
111-
An alternative is to run the generator on a thread on the manager. The
112-
number of workers can then be set to the number of simulation workers.
113-
114-
Change the ``libE_specs`` in **run_libe_forces.py** as follows.
115-
116-
.. code-block:: python
117-
118-
nsim_workers = ensemble.nworkers
119-
120-
# Persistent gen does not need resources
121-
ensemble.libE_specs = LibeSpecs(
122-
gen_on_manager=True,
123-
)
124-
125-
and run with::
126-
127-
python run_libe_forces.py -n 4
128-
129108
To watch video
130109
^^^^^^^^^^^^^^
131110

docs/platforms/platforms_index.rst

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,21 @@ simulation worker, and libEnsemble will distribute user applications across the
2424
node allocation. This is the **most common approach** where each simulation
2525
runs an MPI application.
2626

27-
The generator will run on a worker by default, but if running a single generator,
28-
the :ref:`libE_specs<datastruct-libe-specs>` option **gen_on_manager** is recommended,
29-
which runs the generator on the manager (using a thread) as below.
27+
.. image:: ../images/centralized_gen_on_manager.png
28+
:alt: centralized
29+
:scale: 55
3030

31-
.. list-table::
32-
:widths: 60 40
31+
A SLURM batch script may include:
3332

34-
* - .. image:: ../images/centralized_gen_on_manager.png
35-
:alt: centralized
36-
:scale: 55
33+
.. code-block:: bash
3734
38-
- In calling script:
35+
#SBATCH --nodes 3
3936
40-
.. code-block:: python
41-
:linenos:
37+
python run_libe_forces.py --nworkers 3
4238
43-
ensemble.libE_specs = LibeSpecs(
44-
gen_on_manager=True,
45-
)
46-
47-
A SLURM batch script may include:
48-
49-
.. code-block:: bash
50-
51-
#SBATCH --nodes 3
52-
53-
python run_libe_forces.py --nworkers 3
54-
55-
When using **gen_on_manager**, set ``nworkers`` to the number of workers desired for running simulations.
39+
If running multiple generator processes instead, then set the
40+
:ref:`libE_specs<datastruct-libe-specs>` option **gen_on_worker** so that multiple
41+
worker processes can run multiple generator instances.
5642

5743
Dedicated Mode
5844
^^^^^^^^^^^^^^
@@ -62,32 +48,29 @@ True, the MPI executor will not launch applications on nodes where libEnsemble P
6248
processes (manager and workers) are running. Workers launch applications onto the
6349
remaining nodes in the allocation.
6450

65-
.. list-table::
66-
:widths: 60 40
67-
68-
* - .. image:: ../images/centralized_dedicated.png
69-
:alt: centralized dedicated mode
70-
:scale: 30
7151

72-
- In calling script:
52+
.. image:: ../images/centralized_dedicated.png
53+
:alt: centralized dedicated mode
54+
:scale: 30
7355

74-
.. code-block:: python
75-
:linenos:
56+
In calling script:
7657

77-
ensemble.libE_specs = LibeSpecs(
78-
num_resource_sets=2,
79-
dedicated_mode=True,
80-
)
58+
.. code-block:: python
59+
:linenos:
8160
82-
A SLURM batch script may include:
61+
ensemble.libE_specs = LibeSpecs(
62+
gen_on_worker=True,
63+
num_resource_sets=2,
64+
dedicated_mode=True,
65+
)
8366
84-
.. code-block:: bash
67+
A SLURM batch script may include:
8568

86-
#SBATCH --nodes 3
69+
.. code-block:: bash
8770
88-
python run_libe_forces.py --nworkers 3
71+
#SBATCH --nodes 3
8972
90-
Note that **gen_on_manager** is not set in the above example.
73+
python run_libe_forces.py --nworkers 3
9174
9275
Distributed Running
9376
-------------------
@@ -137,8 +120,7 @@ Zero-resource workers
137120
---------------------
138121

139122
Users with persistent ``gen_f`` functions may notice that the persistent workers
140-
are still automatically assigned system resources. This can be resolved by using
141-
the ``gen_on_manager`` option or by
123+
are still automatically assigned system resources. This can be resolved by
142124
:ref:`fixing the number of resource sets<zero_resource_workers>`.
143125

144126
Assigning GPUs

docs/running_libE.rst

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ determine the parameters/inputs for simulations. Simulator functions run and
1212
manage simulations, which often involve running a user application (see
1313
:doc:`Executor<executor/ex_index>`).
1414

15-
.. note::
16-
As of version 1.3.0, the generator can be run as a thread on the manager,
17-
using the :ref:`libE_specs<datastruct-libe-specs>` option **gen_on_manager**.
18-
When using this option, set the number of workers desired for running
19-
simulations. See :ref:`Running generator on the manager<gen-on-manager>`
20-
for more details.
21-
2215
To use libEnsemble, you will need a calling script, which in turn will specify
2316
generator and simulator functions. Many :doc:`examples<examples/examples_index>`
2417
are available.
@@ -161,29 +154,6 @@ If this example was run as::
161154

162155
No simulations will be able to run.
163156

164-
.. _gen-on-manager:
165-
166-
Running generator on the manager
167-
--------------------------------
168-
169-
The majority of libEnsemble use cases run a single generator. The
170-
:ref:`libE_specs<datastruct-libe-specs>` option **gen_on_manager** will cause
171-
the generator function to run on a thread on the manager. This can run
172-
persistent user functions, sharing data structures with the manager, and avoids
173-
additional communication to a generator running on a worker. When using this
174-
option, the number of workers specified should be the (maximum) number of
175-
concurrent simulations.
176-
177-
If modifying a workflow to use ``gen_on_manager`` consider the following.
178-
179-
* Set ``nworkers`` to the number of workers desired for running simulations.
180-
* If using :meth:`add_unique_random_streams()<tools.add_unique_random_streams>`
181-
to seed random streams, the default generator seed will be zero.
182-
* If you have a line like ``libE_specs["nresource_sets"] = nworkers -1``, this
183-
line should be removed.
184-
* If the generator does use resources, ``nresource_sets`` can be increased as needed
185-
so that the generator and all simulations are resourced.
186-
187157
Environment Variables
188158
---------------------
189159

docs/tutorials/executor_forces_tutorial.rst

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -336,44 +336,6 @@ These may require additional browsing of the documentation to complete.
336336
337337
...
338338
339-
Running the generator on the manager
340-
------------------------------------
341-
342-
As of version 1.3.0, the generator can be run on a thread on the manager,
343-
using the :ref:`libE_specs<datastruct-libe-specs>` option **gen_on_manager**.
344-
345-
Change the libE_specs as follows.
346-
347-
.. code-block:: python
348-
:linenos:
349-
:lineno-start: 28
350-
351-
nsim_workers = ensemble.nworkers
352-
353-
# Persistent gen does not need resources
354-
ensemble.libE_specs = LibeSpecs(
355-
gen_on_manager=True,
356-
sim_dirs_make=True,
357-
ensemble_dir_path="./test_executor_forces_tutorial",
358-
)
359-
360-
When running set ``nworkers`` to the number of workers desired for running simulations.
361-
E.g., Instead of:
362-
363-
.. code-block:: bash
364-
365-
python run_libe_forces.py --nworkers 5
366-
367-
use:
368-
369-
.. code-block:: bash
370-
371-
python run_libe_forces.py --nworkers 4
372-
373-
Note that as the generator random number seed will be zero instead of one, the checksum will change.
374-
375-
For more information see :ref:`Running generator on the manager<gen-on-manager>`.
376-
377339
Running forces application with input file
378340
------------------------------------------
379341

0 commit comments

Comments
 (0)