Skip to content

Commit bb3e467

Browse files
committed
vibe coded approach lets see how this works
1 parent 5310ddd commit bb3e467

29 files changed

Lines changed: 73 additions & 718 deletions

docs/overview_usecases.rst

Lines changed: 5 additions & 6 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,15 +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
149-
``zero_resource_workers`` ``libE_specs`` option). It can also be set
148+
divided by the number of workers. It can also be set
150149
explicitly using the ``num_resource_sets`` ``libE_specs`` option.
151150

152151
* **Slot**: Resource sets enumerated on a node (starting from zero). If

docs/resource_manager/overview.rst

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ Variable resource assignment
3333
In slightly more detail, the resource manager divides resources into **resource sets**.
3434
One resource set is the smallest unit of resources that can be assigned (and
3535
dynamically reassigned) to workers. By default, the provisioned resources are
36-
divided by the number of workers (excluding any workers given in the
37-
``zero_resource_workers`` :class:`libE_specs<libensemble.specs.LibeSpecs>` option).
36+
divided by the number of workers.
3837
However, it can also be set directly by the ``num_resource_sets``
3938
:class:`libE_specs<libensemble.specs.LibeSpecs>` option. If the latter is set, the
4039
dynamic resource assignment algorithm will always be used.
@@ -217,20 +216,12 @@ Persistent generator
217216
You have *one* persistent generator and want *eight* workers to run concurrent
218217
simulations. In this case you can run with *nine* workers.
219218

220-
Either explicitly set eight resource sets (recommended):
219+
Explicitly set eight resource sets (recommended):
221220

222221
.. code-block:: python
223222
224223
libE_specs["num_resource_sets"] = 8
225224
226-
Or if the generator should always be the same worker, use one zero-resource worker:
227-
228-
.. code-block:: python
229-
230-
libE_specs["zero_resource_workers"] = [1]
231-
232-
For the second option, an allocation function supporting zero-resource workers must be used.
233-
234225
Using the two-node example above, the initial worker mapping in this example will be:
235226

236227
.. image:: ../images/variable_resources_persis_gen1.png

docs/resource_manager/resources_index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ from doing any resource detection or management.
1616
:titlesonly:
1717
:caption: Resource Manager:
1818

19-
Zero-resource workers (e.g., Persistent gen does not need resources) <zero_resource_workers>
2019
overview
2120
resource_detection
2221
scheduler_module

docs/tutorials/forces_gpu_tutorial.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ from the simple forces example are highlighted:
3535
# Optional - to print GPU settings
3636
from libensemble.tools.test_support import check_gpu_setting
3737
38+
3839
def run_forces(H, persis_info, sim_specs, libE_info):
3940
"""Launches the forces MPI app and auto-assigns ranks and GPU resources.
4041
@@ -153,6 +154,7 @@ and use this information however you want.
153154
output = np.zeros(1, dtype=sim_specs["out"])
154155
output["energy"][0] = final_energy
155156
157+
156158
return output
157159
158160
The above code will assign a GPU to each worker on CUDA-capable systems,
@@ -214,7 +216,6 @@ For example::
214216

215217
python run_libe_forces.py --nworkers 9
216218

217-
See :ref:`zero-resource workers<zero_resource_workers>` for more ways to express this.
218219

219220
Changing the number of GPUs per worker
220221
--------------------------------------

libensemble/alloc_funcs/start_only_persistent.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
1515
If ``gen_specs["async_return"]`` or ``alloc_specs["user"]["async_return"]`` is set to True, then any
1616
returned points are given back to the generator.
1717
18-
If any workers are marked as zero_resource_workers, then these will only
19-
be used for generators.
18+
"" or ``alloc_specs["user"]["num_active_gens"]``
19+
persistent generators (defaulting to one).
2020
2121
If any of the persistent generators has exited, then ensemble shutdown
2222
is triggered.
@@ -94,11 +94,10 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
9494

9595
# Now the give_sim_work_first part
9696
points_to_evaluate = ~H["sim_started"] & ~H["cancel_requested"]
97-
avail_workers = support.avail_worker_ids(persistent=False, zero_resource_workers=False, gen_workers=False)
97+
avail_workers = support.avail_worker_ids(persistent=False, gen_workers=False)
9898
if user.get("alt_type"):
9999
avail_workers = list(
100-
set(support.avail_worker_ids(persistent=False, zero_resource_workers=False))
101-
| set(support.avail_worker_ids(persistent=EVAL_SIM_TAG, zero_resource_workers=False))
100+
set(support.avail_worker_ids(persistent=False)) | set(support.avail_worker_ids(persistent=EVAL_SIM_TAG))
102101
)
103102
for wid in avail_workers:
104103
if not np.any(points_to_evaluate):
@@ -118,9 +117,9 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
118117

119118
points_to_evaluate[sim_ids_to_send] = False
120119

121-
# Start persistent gens if no worker to give out. Uses zero_resource_workers if defined.
120+
# Start persistent gens if no worker to give out.
122121
if not np.any(points_to_evaluate):
123-
avail_workers = support.avail_worker_ids(persistent=False, zero_resource_workers=True, gen_workers=True)
122+
avail_workers = support.avail_worker_ids(persistent=False, gen_workers=True)
124123

125124
for wid in avail_workers:
126125
if gen_count < user.get("num_active_gens", 1):

libensemble/manager.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ class Manager:
165165
("persis_state", int),
166166
("active_recv", bool),
167167
("gen_started_time", float),
168-
("zero_resource_worker", bool),
169168
]
170169

171170
def _run_additional_worker(self, hist, sim_specs, gen_specs, libE_specs):
@@ -252,9 +251,6 @@ def __init__(
252251
if self.resources is not None:
253252
gresource = self.resources.glob_resources
254253
self.scheduler_opts = gresource.update_scheduler_opts(self.scheduler_opts)
255-
for wrk in self.W:
256-
if wrk["worker_id"] in gresource.zero_resource_workers:
257-
wrk["zero_resource_worker"] = True
258254

259255
for wrk in self.W:
260256
if wrk["worker_id"] in self.libE_specs.get("gen_workers", []):

libensemble/resources/resources.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ class GlobalResources:
9696
:ivar list global_nodelist: list of all nodes available for running user applications
9797
:ivar int logical_cores_avail_per_node: Logical cores (including SMT threads) available on a node
9898
:ivar int physical_cores_avail_per_node: Physical cores available on a node
99-
:ivar list zero_resource_workers: List of workerIDs to have no resources.
100-
:ivar bool dedicated_mode: Whether to remove libE nodes from global nodelist.
10199
:ivar int num_resource_sets: Number of resource sets, if supplied by the user.
102100
"""
103101

@@ -121,12 +119,9 @@ def __init__(self, libE_specs: dict, platform_info: dict = {}, top_level_dir: st
121119
will not be available to worker-launched tasks (user applications). They will
122120
be removed from the nodelist (if present), before dividing into resource sets.
123121
124-
zero_resource_workers: List[int], Optional
125-
List of workers that require no resources.
126-
127122
num_resource_sets: int, Optional
128123
The total number of resource sets. Resources will be divided into this number.
129-
Default: None. If None, resources will be divided by workers (excluding zero_resource_workers).
124+
Default: None. If None, resources will be divided by workers.
130125
131126
cores_on_node: tuple (int, int), Optional
132127
If supplied gives (physical cores, logical cores) for the nodes. If not supplied,
@@ -166,7 +161,6 @@ def __init__(self, libE_specs: dict, platform_info: dict = {}, top_level_dir: st
166161
"""
167162
self.top_level_dir = top_level_dir
168163
self.dedicated_mode = libE_specs.get("dedicated_mode", False)
169-
self.zero_resource_workers = libE_specs.get("zero_resource_workers", [])
170164
self.num_resource_sets = libE_specs.get("num_resource_sets", None)
171165
self.enforce_worker_core_bounds = libE_specs.get("enforce_worker_core_bounds", False)
172166
self.gpus_per_group = libE_specs.get("gpus_per_group")

libensemble/resources/rset_resources.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ def get_rsets_on_a_node(num_rsets, resources):
129129
@staticmethod
130130
def get_workers2assign2(num_workers, resources):
131131
"""Returns workers to assign resources to"""
132-
zero_resource_list = resources.zero_resource_workers
133-
return num_workers - len(zero_resource_list)
132+
return num_workers
134133

135134
@staticmethod
136135
def even_assignment(nnodes, nworkers):

libensemble/resources/worker_resources.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import os
55
from collections import Counter, OrderedDict
6-
from typing import TYPE_CHECKING, Any
6+
from typing import TYPE_CHECKING
77

88
import numpy as np
99

@@ -51,7 +51,6 @@ def __init__(self, num_workers: int, resources: GlobalResources) -> None:
5151
self.index_list = ResourceManager.get_index_list(
5252
self.num_workers,
5353
self.total_num_rsets,
54-
resources.zero_resource_workers,
5554
)
5655

5756
self.rsets = np.zeros(self.total_num_rsets, dtype=ResourceManager.man_rset_dtype)
@@ -102,20 +101,17 @@ def free_rsets(self, worker=None):
102101
self.nongpu_rsets_free += np.count_nonzero(~self.rsets["gpus"][rsets_to_free])
103102

104103
@staticmethod
105-
def get_index_list(num_workers: int, num_rsets: int, zero_resource_list: list[int | Any]) -> list[int | None]:
104+
def get_index_list(num_workers: int, num_rsets: int) -> list[int | None]:
106105
"""Map WorkerID to index into a nodelist"""
107106
index = 0
108107
index_list = []
109108
for i in range(1, num_workers + 1):
110-
if i in zero_resource_list:
109+
if index >= num_rsets:
110+
# Not enough rsets
111111
index_list.append(None)
112112
else:
113-
if index >= num_rsets:
114-
# Not enough rsets
115-
index_list.append(None)
116-
else:
117-
index_list.append(index)
118-
index += 1
113+
index_list.append(index)
114+
index += 1
119115
return index_list
120116

121117

@@ -197,7 +193,6 @@ def __init__(self, num_workers, resources, workerID):
197193
self.matching_slots = True
198194
self.slot_count = None
199195
self.slots_on_node = None
200-
self.zero_resource_workers = resources.zero_resource_workers
201196
self.local_node_count = len(self.local_nodelist)
202197
self.set_slot_count()
203198
self.gen_nprocs = None
@@ -306,9 +301,6 @@ def set_rset_team(self, rset_team: list[int]) -> None:
306301
slot_count - number of slots on each node
307302
local_node_count
308303
"""
309-
if self.workerID in self.zero_resource_workers:
310-
return
311-
312304
if rset_team != self.rset_team: # Order matters
313305
self.rset_team = rset_team
314306
self.num_rsets = len(rset_team)

libensemble/specs.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ class LibeSpecs(BaseModel):
635635
num_resource_sets: int | None = 0
636636
"""
637637
Total number of resource sets. Resources will be divided into this number.
638-
If not set, resources will be divided evenly (excluding zero_resource_workers).
638+
If not set, resources will be divided evenly by the number of workers.
639639
"""
640640

641641
gen_num_procs: int | None = 0
@@ -681,13 +681,6 @@ class LibeSpecs(BaseModel):
681681
libEnsemble processes (manager and workers) are running.
682682
"""
683683

684-
zero_resource_workers: list[int] | None = []
685-
"""
686-
list of workers that require no resources. For when a fixed mapping of workers
687-
to resources is required. Otherwise, use ``num_resource_sets``.
688-
For use with supported allocation functions.
689-
"""
690-
691684
gen_workers: list[int] | None = []
692685
"""
693686
list of workers that should only run generators. All other workers will only

0 commit comments

Comments
 (0)