Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/platforms/platforms_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ accessible on the remote system::
exctr.register_app(full_path="/home/user/forces.x", app_name="forces")
task = exctr.submit(app_name="forces", num_procs=64)

Specify a Globus Compute endpoint in either :class:`sim_specs<libensemble.specs.SimSpecs>` or :class:`gen_specs<libensemble.specs.GenSpecs>` via the ``globus_compute_endpoint``
Specify a Globus Compute endpoint in :class:`sim_specs<libensemble.specs.SimSpecs>` via the ``globus_compute_endpoint``
argument. For example::

from libensemble.specs import SimSpecs
Expand Down
4 changes: 2 additions & 2 deletions libensemble/alloc_funcs/give_sim_work_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def give_sim_work_first(
work is given out unless all entries in ``H`` are returned.

Can give points in highest priority, if ``"priority"`` is a field in ``H``.
If ``gen_specs["give_all_with_same_priority"]`` or ``alloc_specs["user"]["give_all_with_same_priority"]`` is set to True, then
If ``gen_specs["batch_evaluate_same_priority"]`` or ``alloc_specs["user"]["batch_evaluate_same_priority"]`` is set to True, then
all points with the same priority value are given as a batch to the sim.

Workers performing sims will be assigned resources given in H["resource_sets"]
Expand Down Expand Up @@ -54,7 +54,7 @@ def give_sim_work_first(
return {}, persis_info

# Initialize alloc_specs["user"] as user.
batch_give = user.get("give_all_with_same_priority", False)
batch_give = user.get("batch_evaluate_same_priority", False)
gen_in = gen_specs.get("in", [])

manage_resources = libE_info["use_resource_sets"]
Expand Down
4 changes: 2 additions & 2 deletions libensemble/alloc_funcs/start_only_persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
async_return: Boolean, optional
Return results to gen as they come in (after sample). Default: False (batch return).

give_all_with_same_priority: Boolean, optional
batch_evaluate_same_priority: Boolean, optional
If True, then all points with the same priority value are given as a batch to the sim.
Default is False

Expand Down Expand Up @@ -62,7 +62,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l

active_recv_gen = user.get("active_recv_gen", False) # Persistent gen can handle irregular communications
initial_batch_size = user.get("initial_batch_size", 0) # Always batch return until this many evals complete
batch_give = user.get("give_all_with_same_priority", False)
batch_give = user.get("batch_evaluate_same_priority", False)

support = AllocSupport(W, manage_resources, persis_info, libE_info)
gen_count = support.count_persis_gens()
Expand Down
52 changes: 20 additions & 32 deletions libensemble/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,23 @@ def set_fields_from_vocs(self):

class GenSpecs(BaseModel):
"""
Specifications for configuring a Generator Function.
Specifications for configuring a Generator.
"""

gen_f: object | None = None
generator: object | None = None
"""
Python function matching the ``gen_f`` interface. Produces parameters for evaluation by a
A pre-initialized generator object. Produces parameters for evaluation by a
simulator function, and makes decisions based on simulator function output.

These inherit from the `gest-api`
(https://github.com/campa-consortium/gest-api) base class. Recommended over
the classic ``gen_f`` interface.
"""

generator: object | None = None
gen_f: object | None = None
"""
A pre-initialized generator object.
Python function matching the ``gen_f`` interface. Produces parameters for evaluation by a
simulator function, and makes decisions based on simulator function output.
"""

inputs: list[str] | None = Field(default=[], alias="in")
Expand All @@ -191,13 +196,6 @@ class GenSpecs(BaseModel):
Also used to construct libEnsemble's history array.
"""

globus_compute_endpoint: str | None = ""
"""
A Globus Compute (https://www.globus.org/compute) ID corresponding to an active endpoint on a remote system.
libEnsemble's workers will submit generator function instances to this endpoint instead of
calling them locally.
"""

initial_batch_size: int = 0
"""
Initial sample size.
Expand Down Expand Up @@ -243,42 +241,39 @@ class GenSpecs(BaseModel):
they will be automatically derived from VOCS.
"""

# Only used if using the only_persistent_gens allocation function (default)
num_active_gens: int = 1
"""
Maximum number of persistent generators to start. Default: 1.
Maximum number of persistent generators to start.
Only used if using the ``only_persistent_gens`` allocation function (the default).
"""

async_return: bool = False
"""
Return results to gen as they come in (after sample). Default: False (batch return).
Return results to generator as they come in (after sample). Default of False implies batch return.
Only used if using the ``only_persistent_gens`` allocation function (the default).
"""

active_recv_gen: bool = False
"""
Create gen in active receive mode. If True, the manager does not need to wait
for a return from the generator before sending further returned points.
Default: False. Only used if using the ``only_persistent_gens`` allocation function (the default).
Initialize generator in active-receive mode. The manager won't wait for new points
from the generator upon passing back simulation results or other instructions.
This eliminates the "handshake" between manager and generator.
Only used if using the ``only_persistent_gens`` allocation function (the default).
"""

give_all_with_same_priority: bool = False
batch_evaluate_same_priority: bool = False
"""
If True, then all points with the same priority value are given as a batch to the sim.
Default: False. Only used if using the ``only_persistent_gens`` allocation function (the default).
Pass all points with the same priority value as a batch to a single simulator call.
"""

alt_type: bool = False
"""
If True, then the specialized allocator behavior for some persistent gens is used.
Only used if using the ``only_persistent_gens`` allocation function (the default).
Enable specialized allocator behavior for ``only_persistent_gens``.
"""

batch_mode: bool = False
"""
If True, then the generator will not be started if there are still simulations
running. Only used if using the ``give_sim_work_first`` allocation function.
Don't query the generator until all running simulations have finished.
"""

@model_validator(mode="after")
Expand Down Expand Up @@ -347,13 +342,6 @@ class AllocSpecs(BaseModel):
As of libEnsemble v2.0, generator-specific allocation options (e.g., ``async_return``,
``num_active_gens``) have been moved to :class:`GenSpecs<libensemble.specs.GenSpecs>`.
"""

outputs: list[tuple] = Field([], alias="out")
"""
list of 2- or 3-tuples corresponding to NumPy dtypes. e.g. ``("dim", int, (3,))``, or ``("path", str)``.
Allocation functions that modify libEnsemble's History array with additional fields should list those
fields here. Also used to construct libEnsemble's history array.
"""
# end_alloc_tag


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"persis_in": ["f", "x", "sim_id"],
"out": [("num_procs", int), ("num_gpus", int), ("x", float, n)],
"initial_batch_size": nworkers - 1,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"async_return": False,
"user": {
"max_procs": nworkers - 1, # Any sim created can req. 1 worker up to all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"gen_f": gen_f,
"persis_in": ["f", "x", "sim_id"],
"out": [("priority", float), ("resource_sets", int), ("x", float, n)],
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"async_return": False,
"initial_batch_size": nworkers - 1,
"user": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"persis_in": ["f", "x", "sim_id"],
"out": [("priority", float), ("resource_sets", int), ("x", float, n)],
"initial_batch_size": nworkers - 1,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"async_return": False,
"user": {
"max_resource_sets": nworkers - 1, # Any sim created can req. 1 worker up to all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"persis_in": ["f", "x", "sim_id"],
"out": [("priority", float), ("num_procs", int), ("num_gpus", int), ("x", float, n)],
"initial_batch_size": nsim_workers,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"async_return": False,
"user": {
"max_procs": max(nsim_workers // 2, 1), # Any sim created can req. 1 worker up to max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"persis_in": ["f", "x", "sim_id"],
"out": [("resource_sets", int), ("x", float, n)],
"initial_batch_size": nworkers - 1,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"async_return": True,
"user": {
"max_resource_sets": nworkers - 1, # Any sim created can req. 1 worker up to all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"in": ["sim_id"],
"out": [("priority", float), ("resource_sets", int), ("x", float, n), ("x_on_cube", float, n)],
"batch_mode": False,
"give_all_with_same_priority": True,
"batch_evaluate_same_priority": True,
"num_active_gens": 1,
"initial_batch_size": 5,
"user": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"persis_in": ["x", "f", "sim_id"],
"out": [("priority", float), ("resource_sets", int), ("x", float, n), ("x_on_cube", float, n)],
"initial_batch_size": nworkers - 1,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"user": {
"max_resource_sets": max_rsets,
"lb": np.array([-3, -2]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"persis_in": ["f", "x", "sim_id"],
"out": [("priority", float), ("resource_sets", int), ("x", float, n), ("x_on_cube", float, n)],
"initial_batch_size": nworkers - 1,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"user": {
"max_resource_sets": max_rsets,
"lb": np.array([-3, -2]),
Expand Down
2 changes: 1 addition & 1 deletion libensemble/tests/functionality_tests/test_stats_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
("x_on_cube", float, n),
],
"batch_mode": False,
"give_all_with_same_priority": True,
"batch_evaluate_same_priority": True,
"num_active_gens": 1,
"async_return": True,
"batch_size": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
],
"batch_size": 5,
"batch_mode": False,
"give_all_with_same_priority": True,
"batch_evaluate_same_priority": True,
"num_active_gens": 1,
"async_return": True,
"user": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
persis_in=["f", "x", "sim_id"],
out=[("num_procs", int), ("num_gpus", int), ("x", float, 2)],
initial_batch_size=gpu_test.nworkers - 1,
give_all_with_same_priority=False,
batch_evaluate_same_priority=False,
async_return=False,
user={
"max_procs": gpu_test.nworkers - 1, # Any sim created can req. 1 worker up to max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
persis_in=["f", "x", "sim_id"],
out=[("num_procs", int), ("num_gpus", int), ("x", float, 2)],
initial_batch_size=nworkers - 1,
give_all_with_same_priority=False,
batch_evaluate_same_priority=False,
async_return=False,
user={
"max_procs": (nworkers - 1) // 2, # Any sim created can req. 1 worker up to max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"persis_in": ["f", "x", "sim_id"],
"out": [("priority", float), ("resource_sets", int), ("x", float, n)],
"initial_batch_size": ensemble.nworkers - 1,
"give_all_with_same_priority": False,
"batch_evaluate_same_priority": False,
"async_return": False,
"user": {
"max_resource_sets": ensemble.nworkers - 1, # Any sim created can req. 1 worker up to all.
Expand Down
8 changes: 4 additions & 4 deletions libensemble/tests/unit_tests/test_ufunc_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def test_globus_compute_runner_pass():
def test_globus_compute_runner_fail():
calc_in, sim_specs, gen_specs = get_ufunc_args()

gen_specs["globus_compute_endpoint"] = "4321"
sim_specs["globus_compute_endpoint"] = "4321"

with mock.patch("globus_compute_sdk.Executor"):
runner = Runner.from_specs(gen_specs)
runner = Runner.from_specs(sim_specs)

# Creating Mock Globus ComputeExecutor and Globus Compute future object - yes exception
globus_compute_mock = mock.Mock()
Expand All @@ -124,12 +124,12 @@ def test_globus_compute_runner_fail():
globus_compute_future.exception.return_value = Exception

runner.globus_compute_executor = globus_compute_mock
runners = {2: runner.run}
runners = {1: runner.run}

libE_info = {"H_rows": np.array([2, 3, 4]), "workerID": 1, "comm": "fakecomm"}

with pytest.raises(Exception):
out, persis_info = runners[2](calc_in, {"libE_info": libE_info, "persis_info": {}, "tag": 2})
out, persis_info = runners[1](calc_in, {"libE_info": libE_info, "persis_info": {}, "tag": 1})
pytest.fail("Expected exception")


Expand Down
3 changes: 0 additions & 3 deletions libensemble/utils/pydantic_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
model["inputs"] = FieldInfo.merge_field_infos(model["inputs"], Field(alias="in"))
model["outputs"] = FieldInfo.merge_field_infos(model["outputs"], Field(alias="out"))

model = specs.AllocSpecs.model_fields
model["outputs"] = FieldInfo.merge_field_infos(model["outputs"], Field(alias="out"))

specs.SimSpecs.model_rebuild(force=True)
specs.GenSpecs.model_rebuild(force=True)
specs.AllocSpecs.model_rebuild(force=True)
Expand Down
Loading