diff --git a/docs/platforms/platforms_index.rst b/docs/platforms/platforms_index.rst index 79285aa7b..ac175f998 100644 --- a/docs/platforms/platforms_index.rst +++ b/docs/platforms/platforms_index.rst @@ -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` or :class:`gen_specs` via the ``globus_compute_endpoint`` +Specify a Globus Compute endpoint in :class:`sim_specs` via the ``globus_compute_endpoint`` argument. For example:: from libensemble.specs import SimSpecs diff --git a/libensemble/alloc_funcs/give_sim_work_first.py b/libensemble/alloc_funcs/give_sim_work_first.py index 11ccf211f..96245f7a9 100644 --- a/libensemble/alloc_funcs/give_sim_work_first.py +++ b/libensemble/alloc_funcs/give_sim_work_first.py @@ -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"] @@ -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"] diff --git a/libensemble/alloc_funcs/start_only_persistent.py b/libensemble/alloc_funcs/start_only_persistent.py index 801dd1180..0f35a7d14 100644 --- a/libensemble/alloc_funcs/start_only_persistent.py +++ b/libensemble/alloc_funcs/start_only_persistent.py @@ -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 @@ -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() diff --git a/libensemble/specs.py b/libensemble/specs.py index 70c18bddd..d4cf86d13 100644 --- a/libensemble/specs.py +++ b/libensemble/specs.py @@ -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") @@ -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. @@ -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") @@ -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`. """ - - 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 diff --git a/libensemble/tests/functionality_tests/test_GPU_gen_resources.py b/libensemble/tests/functionality_tests/test_GPU_gen_resources.py index 8feb36ea7..3630e6a30 100644 --- a/libensemble/tests/functionality_tests/test_GPU_gen_resources.py +++ b/libensemble/tests/functionality_tests/test_GPU_gen_resources.py @@ -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. diff --git a/libensemble/tests/functionality_tests/test_mpi_gpu_settings.py b/libensemble/tests/functionality_tests/test_mpi_gpu_settings.py index 203a1ca45..e54810f33 100644 --- a/libensemble/tests/functionality_tests/test_mpi_gpu_settings.py +++ b/libensemble/tests/functionality_tests/test_mpi_gpu_settings.py @@ -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": { diff --git a/libensemble/tests/functionality_tests/test_mpi_gpu_settings_env.py b/libensemble/tests/functionality_tests/test_mpi_gpu_settings_env.py index 30c737cbf..1adbd3636 100644 --- a/libensemble/tests/functionality_tests/test_mpi_gpu_settings_env.py +++ b/libensemble/tests/functionality_tests/test_mpi_gpu_settings_env.py @@ -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. diff --git a/libensemble/tests/functionality_tests/test_mpi_gpu_settings_mock_nodes_multi_task.py b/libensemble/tests/functionality_tests/test_mpi_gpu_settings_mock_nodes_multi_task.py index 1234c6482..5ca478aea 100644 --- a/libensemble/tests/functionality_tests/test_mpi_gpu_settings_mock_nodes_multi_task.py +++ b/libensemble/tests/functionality_tests/test_mpi_gpu_settings_mock_nodes_multi_task.py @@ -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 diff --git a/libensemble/tests/functionality_tests/test_persistent_sampling_CUDA_variable_resources.py b/libensemble/tests/functionality_tests/test_persistent_sampling_CUDA_variable_resources.py index d80818920..e13b3d68b 100644 --- a/libensemble/tests/functionality_tests/test_persistent_sampling_CUDA_variable_resources.py +++ b/libensemble/tests/functionality_tests/test_persistent_sampling_CUDA_variable_resources.py @@ -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. diff --git a/libensemble/tests/functionality_tests/test_runlines_adaptive_workers.py b/libensemble/tests/functionality_tests/test_runlines_adaptive_workers.py index cbff4e279..c48eed15d 100644 --- a/libensemble/tests/functionality_tests/test_runlines_adaptive_workers.py +++ b/libensemble/tests/functionality_tests/test_runlines_adaptive_workers.py @@ -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": { diff --git a/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent.py b/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent.py index 8f80ddb67..4124aab89 100644 --- a/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent.py +++ b/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent.py @@ -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]), diff --git a/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent_oversubscribe_rsets.py b/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent_oversubscribe_rsets.py index a317d9043..7eaac5053 100644 --- a/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent_oversubscribe_rsets.py +++ b/libensemble/tests/functionality_tests/test_runlines_adaptive_workers_persistent_oversubscribe_rsets.py @@ -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]), diff --git a/libensemble/tests/functionality_tests/test_stats_output.py b/libensemble/tests/functionality_tests/test_stats_output.py index b6377f866..5cf8f1ac7 100644 --- a/libensemble/tests/functionality_tests/test_stats_output.py +++ b/libensemble/tests/functionality_tests/test_stats_output.py @@ -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, diff --git a/libensemble/tests/functionality_tests/test_uniform_sampling_with_variable_resources.py b/libensemble/tests/functionality_tests/test_uniform_sampling_with_variable_resources.py index c895d12a8..22a7fd5c2 100644 --- a/libensemble/tests/functionality_tests/test_uniform_sampling_with_variable_resources.py +++ b/libensemble/tests/functionality_tests/test_uniform_sampling_with_variable_resources.py @@ -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": { diff --git a/libensemble/tests/regression_tests/test_GPU_variable_resources.py b/libensemble/tests/regression_tests/test_GPU_variable_resources.py index 940688501..932aebbad 100644 --- a/libensemble/tests/regression_tests/test_GPU_variable_resources.py +++ b/libensemble/tests/regression_tests/test_GPU_variable_resources.py @@ -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 diff --git a/libensemble/tests/regression_tests/test_GPU_variable_resources_multi_task.py b/libensemble/tests/regression_tests/test_GPU_variable_resources_multi_task.py index 87b450db5..c924bae93 100644 --- a/libensemble/tests/regression_tests/test_GPU_variable_resources_multi_task.py +++ b/libensemble/tests/regression_tests/test_GPU_variable_resources_multi_task.py @@ -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 diff --git a/libensemble/tests/regression_tests/test_ensemble_platform_workdir.py b/libensemble/tests/regression_tests/test_ensemble_platform_workdir.py index bb5a63488..958aca104 100644 --- a/libensemble/tests/regression_tests/test_ensemble_platform_workdir.py +++ b/libensemble/tests/regression_tests/test_ensemble_platform_workdir.py @@ -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. diff --git a/libensemble/tests/unit_tests/test_ufunc_runners.py b/libensemble/tests/unit_tests/test_ufunc_runners.py index 0b362700f..79fda7c28 100644 --- a/libensemble/tests/unit_tests/test_ufunc_runners.py +++ b/libensemble/tests/unit_tests/test_ufunc_runners.py @@ -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() @@ -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") diff --git a/libensemble/utils/pydantic_bindings.py b/libensemble/utils/pydantic_bindings.py index 6ae28efe8..f53b73b76 100644 --- a/libensemble/utils/pydantic_bindings.py +++ b/libensemble/utils/pydantic_bindings.py @@ -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)