4242 UnsupportedPlotError ,
4343 UserInputError ,
4444)
45- from ax .exceptions .generation_strategy import MaxParallelismReachedException
45+ from ax .exceptions .generation_strategy import (
46+ MaxParallelismReachedException as MaxConcurrencyReachedException ,
47+ )
4648from ax .generation_strategy .dispatch_utils import choose_generation_strategy_legacy
4749from ax .generation_strategy .generation_strategy import GenerationStrategy
48- from ax .generation_strategy .transition_criterion import MaxGenerationParallelism
50+ from ax .generation_strategy .transition_criterion import (
51+ MaxGenerationParallelism as MaxGenerationConcurrency ,
52+ )
4953from ax .global_stopping .strategies .base import BaseGlobalStoppingStrategy
5054from ax .global_stopping .strategies .improvement import constraint_satisfaction
5155from ax .plot .base import AxPlotConfig
@@ -570,7 +574,7 @@ def get_next_trial(
570574 ),
571575 ttl_seconds = ttl_seconds ,
572576 )
573- except MaxParallelismReachedException as e :
577+ except MaxConcurrencyReachedException as e :
574578 if self ._early_stopping_strategy is not None :
575579 e .message += ( # noqa: B306
576580 " When stopping trials early, make sure to call `stop_trial_early` "
@@ -836,39 +840,39 @@ def get_trials_data_frame(self) -> pd.DataFrame:
836840 """
837841 return self .experiment .to_df ()
838842
839- def get_max_parallelism (self ) -> list [tuple [int , int ]]:
840- """Retrieves maximum number of trials that can be scheduled in parallel
843+ def get_max_concurrency (self ) -> list [tuple [int , int ]]:
844+ """Retrieves maximum number of trials that can be scheduled concurrently
841845 at different stages of optimization.
842846
843847 Some optimization algorithms profit significantly from sequential
844848 optimization (i.e. suggest a few points, get updated with data for them,
845849 repeat, see https://ax.dev/docs/bayesopt.html).
846- Parallelism setting indicates how many trials should be running simulteneously
850+ Concurrency setting indicates how many trials should be running simultaneously
847851 (generated, but not yet completed with data).
848852
849853 The output of this method is mapping of form
850- {num_trials -> max_parallelism_setting }, where the max_parallelism_setting
851- is used for num_trials trials. If max_parallelism_setting is -1, as
852- many of the trials can be ran in parallel , as necessary. If num_trials
853- in a tuple is -1, then the corresponding max_parallelism_setting
854+ {num_trials -> max_concurrency_setting }, where the max_concurrency_setting
855+ is used for num_trials trials. If max_concurrency_setting is -1, as
856+ many of the trials can be ran concurrently , as necessary. If num_trials
857+ in a tuple is -1, then the corresponding max_concurrency_setting
854858 should be used for all subsequent trials.
855859
856860 For example, if the returned list is [(5, -1), (12, 6), (-1, 3)],
857- the schedule could be: run 5 trials with any parallelism , run 6 trials in
858- parallel twice, run 3 trials in parallel for as long as needed. Here,
861+ the schedule could be: run 5 trials with any concurrency , run 6 trials
862+ concurrently twice, run 3 trials concurrently for as long as needed. Here,
859863 'running' a trial means obtaining a next trial from `AxClient` through
860864 get_next_trials and completing it with data when available.
861865
862866 Returns:
863- Mapping of form {num_trials -> max_parallelism_setting }.
867+ Mapping of form {num_trials -> max_concurrency_setting }.
864868 """
865- parallelism_settings = []
869+ concurrency_settings = []
866870 for node in self .generation_strategy ._nodes :
867- # Extract max_parallelism from MaxGenerationParallelism criterion
868- max_parallelism = None
871+ # Extract max_concurrency from MaxGenerationConcurrency criterion
872+ max_concurrency = None
869873 for tc in node .transition_criteria :
870- if isinstance (tc , MaxGenerationParallelism ):
871- max_parallelism = tc .threshold
874+ if isinstance (tc , MaxGenerationConcurrency ):
875+ max_concurrency = tc .threshold
872876 break
873877 # Try to get num_trials from the node. If there's no MinTrials
874878 # criterion (unlimited trials), num_trials will raise UserInputError.
@@ -877,13 +881,16 @@ def get_max_parallelism(self) -> list[tuple[int, int]]:
877881 num_trials = node .num_trials
878882 except UserInputError :
879883 num_trials = - 1
880- parallelism_settings .append (
884+ concurrency_settings .append (
881885 (
882886 num_trials ,
883- max_parallelism if max_parallelism is not None else num_trials ,
887+ max_concurrency if max_concurrency is not None else num_trials ,
884888 )
885889 )
886- return parallelism_settings
890+ return concurrency_settings
891+
892+ def get_max_parallelism (self ) -> list [tuple [int , int ]]:
893+ raise NotImplementedError ("Use `get_max_concurrency` instead." )
887894
888895 def get_optimization_trace (
889896 self , objective_optimum : float | None = None
@@ -1702,8 +1709,8 @@ def __repr__(self) -> str:
17021709 @staticmethod
17031710 def get_recommended_max_parallelism () -> None :
17041711 raise NotImplementedError (
1705- "Use `get_max_parallelism ` instead; parallelism levels are now "
1706- "enforced in generation strategy, so max parallelism is no longer "
1712+ "Use `get_max_concurrency ` instead; concurrency levels are now "
1713+ "enforced in generation strategy, so max concurrency is no longer "
17071714 "just recommended."
17081715 )
17091716
0 commit comments