diff --git a/.github/workflows/extra.yml b/.github/workflows/extra.yml index 1111d2852..10b320726 100644 --- a/.github/workflows/extra.yml +++ b/.github/workflows/extra.yml @@ -76,7 +76,6 @@ jobs: rm ./libensemble/tests/unit_tests/test_ufunc_runners.py # needs globus-compute rm ./libensemble/tests/regression_tests/test_gpCAM.py # needs gpcam, which doesn't build on 3.13 rm ./libensemble/tests/regression_tests/test_asktell_gpCAM.py # needs gpcam, which doesn't build on 3.13 - rm ./libensemble/tests/regression_tests/test_persistent_gp_multitask_ax.py # needs ax-platform, which doesn't yet support 3.14 rm ./libensemble/tests/regression_tests/test_optimas_ax_mf.py # needs ax-platform, which doesn't yet support 3.14 rm ./libensemble/tests/regression_tests/test_optimas_ax_sf.py # needs ax-platform, which doesn't yet support 3.14 diff --git a/docs/examples/ax_multitask.rst b/docs/examples/ax_multitask.rst deleted file mode 100644 index e3984f39a..000000000 --- a/docs/examples/ax_multitask.rst +++ /dev/null @@ -1,18 +0,0 @@ -persistent_ax_multitask ------------------------ - -Required: `ax-platform`_>=0.5.0 - -Example usage: gp_multitask_ax_ - -To install:: - - pip install ax-platform - -An example of the Ax multitask GP. - -.. automodule:: persistent_ax_multitask - :members: - -.. _`ax-platform`: https://github.com/facebook/Ax -.. _gp_multitask_ax: https://github.com/Libensemble/libensemble/blob/main/libensemble/tests/regression_tests/test_persistent_gp_multitask_ax.py diff --git a/libensemble/tests/regression_tests/test_persistent_gp_multitask_ax.py b/libensemble/tests/regression_tests/test_persistent_gp_multitask_ax.py deleted file mode 100644 index 79236b2db..000000000 --- a/libensemble/tests/regression_tests/test_persistent_gp_multitask_ax.py +++ /dev/null @@ -1,115 +0,0 @@ -""" -Example of multi-fidelity optimization using a persistent GP gen_func (calling -Ax). - - -Execute via one of the following commands: - mpiexec -np 4 python test_persistent_gp_multitask_ax.py - python test_persistent_gp_multitask_ax.py --nworkers 3 - python test_persistent_gp_multitask_ax.py --nworkers 3 --comms tcp - -When running with the above commands, the number of concurrent evaluations of -the objective function will be 3. - -""" - -# Do not change these lines - they are parsed by run-tests.sh -# TESTSUITE_COMMS: local mpi -# TESTSUITE_NPROCS: 4 -# TESTSUITE_EXTRA: true -# TESTSUITE_OS_SKIP: OSX - -import warnings - -import numpy as np - -from libensemble import logger -from libensemble.libE import libE -from libensemble.message_numbers import WORKER_DONE -from libensemble.tools import parse_args, save_libE_output - -# Ax uses a deprecated warn command. -warnings.filterwarnings("ignore", category=UserWarning) -warnings.filterwarnings("ignore", category=DeprecationWarning) -warnings.filterwarnings("ignore", category=FutureWarning) - -from libensemble.gen_funcs.persistent_ax_multitask import persistent_gp_mt_ax_gen_f - - -def run_simulation(H, persis_info, sim_specs, libE_info): - # Extract input parameters - values = list(H["x"][0]) - x0 = values[0] - x1 = values[1] - # Extract fidelity parameter - task = H["task"][0] - if task == "expensive_model": - z = 8 - elif task == "cheap_model": - z = 1 - print("in sim", task) - - libE_output = np.zeros(1, dtype=sim_specs["out"]) - calc_status = WORKER_DONE - - # Function that depends on the resolution parameter - libE_output["f"] = -(x0 + 10 * np.cos(x0 + 0.1 * z)) * (x1 + 5 * np.cos(x1 - 0.2 * z)) - - return libE_output, persis_info, calc_status - - -# Main block is necessary only when using local comms with spawn start method (default on macOS and Windows). -if __name__ == "__main__": - nworkers, is_manager, libE_specs, _ = parse_args() - - mt_params = { - "name_hifi": "expensive_model", - "name_lofi": "cheap_model", - "n_init_hifi": 4, - "n_init_lofi": 4, - "n_opt_hifi": 2, - "n_opt_lofi": 4, - } - - sim_specs = { - "sim_f": run_simulation, - "in": ["x", "task"], - "out": [("f", float)], - } - - gen_specs = { - # Generator function. Will randomly generate new sim inputs 'x'. - "gen_f": persistent_gp_mt_ax_gen_f, - # Generator input. This is a RNG, no need for inputs. - "in": ["sim_id", "x", "f", "task"], - "persis_in": ["sim_id", "x", "f", "task"], - "out": [ - # parameters to input into the simulation. - ("x", float, (2,)), - ("task", str, max(len(str(mt_params["name_hifi"])), len(str(mt_params["name_lofi"])))), - ("resource_sets", int), - ], - "async_return": False, - "batch_size": nworkers - 1, - "user": { - "range": [1, 8], - # Lower bound for the n parameters. - "lb": np.array([0, 0]), - # Upper bound for the n parameters. - "ub": np.array([15, 15]), - }, - } - gen_specs["user"] = {**gen_specs["user"], **mt_params} - - # libE logger - logger.set_level("INFO") - - # Exit criteria - exit_criteria = {"sim_max": 20} # Exit after running sim_max simulations - - # Run LibEnsemble, and store results in history array H - H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, libE_specs=libE_specs) - - # Save results to numpy file - if is_manager: - save_libE_output(H, persis_info, __file__, nworkers) diff --git a/libensemble/tests/scaling_tests/persistent_gp/run_example.py b/libensemble/tests/scaling_tests/persistent_gp/run_example.py deleted file mode 100644 index b8a6f8150..000000000 --- a/libensemble/tests/scaling_tests/persistent_gp/run_example.py +++ /dev/null @@ -1,95 +0,0 @@ -""" -Example of optimization using a persistent GP gen_func, with multi-fidelity - -Usage: ------- -python run_example.py --nworkers 4 -""" - -import numpy as np - -from libensemble import logger -from libensemble.gen_funcs.persistent_ax_multitask import persistent_gp_mt_ax_gen_f -from libensemble.libE import libE -from libensemble.message_numbers import WORKER_DONE -from libensemble.tools import parse_args, save_libE_output - -nworkers, is_manager, libE_specs, _ = parse_args() - -mt_params = { - "name_hifi": "expensive_model", - "name_lofi": "cheap_model", - "n_init_hifi": 4, - "n_init_lofi": 4, - "n_opt_hifi": 2, - "n_opt_lofi": 4, -} - - -def run_simulation(H, persis_info, sim_specs, libE_info): - # Extract input parameters - values = list(H["x"][0]) - x0 = values[0] - x1 = values[1] - # Extract fidelity parameter - task = H["task"][0] - if task == "expensive_model": - z = 8 - elif task == "cheap_model": - z = 1 - - libE_output = np.zeros(1, dtype=sim_specs["out"]) - calc_status = WORKER_DONE - - # Function that depends on the resolution parameter - libE_output["f"] = -(x0 + 10 * np.cos(x0 + 0.1 * z)) * (x1 + 5 * np.cos(x1 - 0.2 * z)) - - return libE_output, persis_info, calc_status - - -sim_specs = { - "sim_f": run_simulation, - "in": ["x", "task"], - "out": [("f", float)], -} - -gen_specs = { - # Generator function. Will randomly generate new sim inputs 'x'. - "gen_f": persistent_gp_mt_ax_gen_f, - # Generator input. This is a RNG, no need for inputs. - "in": ["sim_id", "x", "f", "task"], - "persis_in": ["sim_id", "x", "f", "task"], - "out": [ - # parameters to input into the simulation. - ("x", float, (2,)), - ("task", str, max(len(str(mt_params["name_hifi"])), len(str(mt_params["name_lofi"])))), - ("resource_sets", int), - ], - "async_return": False, - "batch_size": nworkers - 1, - "user": { - "range": [1, 8], - # Lower bound for the n parameters. - "lb": np.array([0, 0]), - # Upper bound for the n parameters. - "ub": np.array([15, 15]), - }, -} -gen_specs["user"] = {**gen_specs["user"], **mt_params} - - -# libE logger -logger.set_level("INFO") - -# Exit criteria -exit_criteria = {"sim_max": 20} # Exit after running sim_max simulations - -# Create a different random number stream for each worker and the manager -persis_info = {} - -# Run LibEnsemble, and store results in history array H -H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs) - -# Save results to numpy file -if is_manager: - save_libE_output(H, persis_info, __file__, nworkers) diff --git a/pixi.lock b/pixi.lock index c4714fc82..c91e89538 100644 --- a/pixi.lock +++ b/pixi.lock @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd8596dc0210788ddfda1f23f01aa4a83aaf85d1242d5b68a530e350e14c174b -size 1084218 +oid sha256:08d5a4373069dc12cfc292c49bee812d7d138c226d005e04bdbb32f78b0513a5 +size 1234374 diff --git a/pyproject.toml b/pyproject.toml index 5302b3039..7e3d8eabe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,6 +121,7 @@ petsc4py = "==3.24.2" pandas = "<3" numpy = "<2.4" proxystore = ">=0.7.1,<0.9" +ax-platform = ">=1.2.4,<2" [tool.pixi.feature.docs.dependencies] sphinx = ">=8.2.3,<9" @@ -166,22 +167,13 @@ python = "3.13.*" [tool.pixi.feature.py314.dependencies] python = "3.14.*" -# ax-platform only works up to 3.13 on Linux - -[tool.pixi.feature.py311e.target.linux-64.dependencies] -ax-platform = "==0.5.0" - [tool.pixi.feature.py311e.dependencies] globus-compute-sdk = ">=4.10.2,<5" -[tool.pixi.feature.py312e.target.linux-64.dependencies] -ax-platform = "==0.5.0" - [tool.pixi.feature.py312e.dependencies] globus-compute-sdk = ">=4.10.2,<5" -[tool.pixi.feature.py313e.target.linux-64.dependencies] -ax-platform = "==0.5.0" +[tool.pixi.feature.py313e] [tool.pixi.feature.py314e]