From 4ddf6d467cdac7d0d792b067b51703a797a93b86 Mon Sep 17 00:00:00 2001 From: jlnav Date: Wed, 6 Sep 2023 09:43:58 -0500 Subject: [PATCH] switch many user-facing examples to update ensemble's persis_info using add_unique_random_streams function --- libensemble/tests/regression_tests/test_1d_sampling.py | 3 ++- .../tests/regression_tests/test_GPU_variable_resources.py | 3 ++- .../regression_tests/test_GPU_variable_resources_multi_task.py | 3 ++- .../tests/regression_tests/test_inverse_bayes_example.py | 3 ++- .../tests/regression_tests/test_persistent_fd_param_finder.py | 3 ++- .../tests/regression_tests/test_persistent_surmise_calib.py | 3 ++- .../forces/forces_adv/run_libe_forces_from_yaml.py | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libensemble/tests/regression_tests/test_1d_sampling.py b/libensemble/tests/regression_tests/test_1d_sampling.py index 6a21b8e27..b7a64e225 100644 --- a/libensemble/tests/regression_tests/test_1d_sampling.py +++ b/libensemble/tests/regression_tests/test_1d_sampling.py @@ -21,6 +21,7 @@ # Import libEnsemble items for this test from libensemble.sim_funcs.one_d_func import one_d_example as sim_f from libensemble.specs import ExitCriteria, GenSpecs, LibeSpecs, SimSpecs +from libensemble.tools import add_unique_random_streams # Main block is necessary only when using local comms with spawn start method (default on macOS and Windows). if __name__ == "__main__": @@ -38,7 +39,7 @@ }, ) - sampling.add_random_streams() + sampling.persis_info = add_unique_random_streams({}, sampling.nworkers + 1) sampling.exit_criteria = ExitCriteria(gen_max=501) sampling.run() diff --git a/libensemble/tests/regression_tests/test_GPU_variable_resources.py b/libensemble/tests/regression_tests/test_GPU_variable_resources.py index 3e8dcd79a..7f272d75c 100644 --- a/libensemble/tests/regression_tests/test_GPU_variable_resources.py +++ b/libensemble/tests/regression_tests/test_GPU_variable_resources.py @@ -36,6 +36,7 @@ from libensemble.sim_funcs import six_hump_camel from libensemble.sim_funcs.var_resources import gpu_variable_resources_from_gen as sim_f from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, LibeSpecs, SimSpecs +from libensemble.tools import add_unique_random_streams # from libensemble import logger # logger.set_level("DEBUG") # For testing the test @@ -83,7 +84,7 @@ }, ) - gpu_test.add_random_streams() + gpu_test.persis_info = add_unique_random_streams({}, gpu_test.nworkers + 1) gpu_test.exit_criteria = ExitCriteria(sim_max=40) gpu_test.run() 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 961be3a6f..f78bcff4e 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 @@ -47,6 +47,7 @@ from libensemble.sim_funcs import six_hump_camel from libensemble.sim_funcs.var_resources import gpu_variable_resources_from_gen as sim_f from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, LibeSpecs, SimSpecs +from libensemble.tools import add_unique_random_streams # from libensemble import logger # logger.set_level("DEBUG") # For testing the test @@ -95,7 +96,7 @@ }, ) - gpu_test.add_random_streams() + gpu_test.persis_info = add_unique_random_streams({}, gpu_test.nworkers + 1) gpu_test.exit_criteria = ExitCriteria(sim_max=40, wallclock_max=300) if gpu_test.ready(): diff --git a/libensemble/tests/regression_tests/test_inverse_bayes_example.py b/libensemble/tests/regression_tests/test_inverse_bayes_example.py index 7e77657b8..993fdfe12 100644 --- a/libensemble/tests/regression_tests/test_inverse_bayes_example.py +++ b/libensemble/tests/regression_tests/test_inverse_bayes_example.py @@ -25,6 +25,7 @@ from libensemble.gen_funcs.persistent_inverse_bayes import persistent_updater_after_likelihood as gen_f from libensemble.sim_funcs.inverse_bayes import likelihood_calculator as sim_f from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, SimSpecs +from libensemble.tools import add_unique_random_streams # Main block is necessary only when using local comms with spawn start method (default on macOS and Windows). if __name__ == "__main__": @@ -57,7 +58,7 @@ alloc_specs=AllocSpecs(alloc_f=alloc_f), ) - bayes_test.add_random_streams() + bayes_test.persis_info = add_unique_random_streams({}, bayes_test.nworkers + 1) gen_user = bayes_test.gen_specs.user val = gen_user["subbatch_size"] * gen_user["num_subbatches"] * gen_user["num_batches"] bayes_test.exit_criteria = ExitCriteria(sim_max=val, wallclock_max=300) diff --git a/libensemble/tests/regression_tests/test_persistent_fd_param_finder.py b/libensemble/tests/regression_tests/test_persistent_fd_param_finder.py index ee353492e..53a2a2f1e 100644 --- a/libensemble/tests/regression_tests/test_persistent_fd_param_finder.py +++ b/libensemble/tests/regression_tests/test_persistent_fd_param_finder.py @@ -29,6 +29,7 @@ from libensemble.sim_funcs.noisy_vector_mapping import func_wrapper as sim_f from libensemble.sim_funcs.noisy_vector_mapping import noisy_function from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, SimSpecs +from libensemble.tools import add_unique_random_streams # Main block is necessary only when using local comms with spawn start method (default on macOS and Windows). if __name__ == "__main__": @@ -62,7 +63,7 @@ alloc_specs=AllocSpecs(alloc_f=alloc_f), exit_criteria=ExitCriteria(gen_max=1000), ) - fd_test.add_random_streams() + fd_test.persis_info = add_unique_random_streams({}, fd_test.nworkers + 1) shutil.copy("./scripts_used_by_reg_tests/ECnoise.m", "./") diff --git a/libensemble/tests/regression_tests/test_persistent_surmise_calib.py b/libensemble/tests/regression_tests/test_persistent_surmise_calib.py index 09739e4f4..10b6502d6 100644 --- a/libensemble/tests/regression_tests/test_persistent_surmise_calib.py +++ b/libensemble/tests/regression_tests/test_persistent_surmise_calib.py @@ -40,6 +40,7 @@ from libensemble.sim_funcs.surmise_test_function import borehole as sim_f from libensemble.sim_funcs.surmise_test_function import tstd2theta from libensemble.specs import AllocSpecs, ExitCriteria, GenSpecs, SimSpecs +from libensemble.tools import add_unique_random_streams if __name__ == "__main__": @@ -100,7 +101,7 @@ exit_criteria=ExitCriteria(sim_max=max_evals), ) - test.add_random_streams() + test.persis_info = add_unique_random_streams({}, test.nworkers + 1) # Perform the run H, _, _ = test.run() diff --git a/libensemble/tests/scaling_tests/forces/forces_adv/run_libe_forces_from_yaml.py b/libensemble/tests/scaling_tests/forces/forces_adv/run_libe_forces_from_yaml.py index 1461832ab..0bca5e93d 100644 --- a/libensemble/tests/scaling_tests/forces/forces_adv/run_libe_forces_from_yaml.py +++ b/libensemble/tests/scaling_tests/forces/forces_adv/run_libe_forces_from_yaml.py @@ -6,6 +6,7 @@ from libensemble.ensemble import Ensemble from libensemble.executors.mpi_executor import MPIExecutor +from libensemble.tools import add_unique_random_streams #################### @@ -36,7 +37,7 @@ } ) -forces.add_random_streams() +forces.persis_info = add_unique_random_streams({}, forces.nworkers + 1) forces.run() forces.save_output(__file__)