A programming framework for agentic AI
Do not persist entire AutoMLState in Searcher (#870)
Antoni Baum5f67c0ab8af6
diff --git a/flaml/automl/automl.py b/flaml/automl/automl.pyindex c086584aa..74b8741ac 100644--- a/flaml/automl/automl.py+++ b/flaml/automl/automl.py@@ -491,7 +491,7 @@ class AutoMLState:return estimator, train_time-def size(state: AutoMLState, config: dict) -> float:+def size(learner_classes: dict, config: dict) -> float:"""Size function.Returns:@@ -499,7 +499,7 @@ def size(state: AutoMLState, config: dict) -> float:"""config = config.get("ml", config)estimator = config["learner"]- learner_class = state.learner_classes.get(estimator)+ learner_class = learner_classes.get(estimator)return learner_class.size(config)@@ -3125,7 +3125,7 @@ class AutoML(BaseEstimator):min_resource=min_resource_all_estimator,max_resource=self.max_resource,config_constraints=[- (partial(size, self._state), "<=", self._mem_thres)+ (partial(size, self._state.learner_classes), "<=", self._mem_thres)],metric_constraints=self.metric_constraints,seed=self._seed,diff --git a/test/automl/test_constraints.py b/test/automl/test_constraints.pyindex 7555100d3..1222e4ed0 100644--- a/test/automl/test_constraints.py+++ b/test/automl/test_constraints.py@@ -55,7 +55,9 @@ def test_metric_constraints():min_resource=automl.min_resource,max_resource=automl.max_resource,time_budget_s=automl._state.time_budget,- config_constraints=[(partial(size, automl._state), "<=", automl._mem_thres)],+ config_constraints=[+ (partial(size, automl._state.learner_classes), "<=", automl._mem_thres)+ ],metric_constraints=automl.metric_constraints,num_samples=5,)@@ -159,7 +161,9 @@ def test_metric_constraints_custom():min_resource=automl.min_resource,max_resource=automl.max_resource,time_budget_s=automl._state.time_budget,- config_constraints=[(partial(size, automl._state), "<=", automl._mem_thres)],+ config_constraints=[+ (partial(size, automl._state.learner_classes), "<=", automl._mem_thres)+ ],metric_constraints=automl.metric_constraints,num_samples=5,)diff --git a/test/automl/test_python_log.py b/test/automl/test_python_log.pyindex 5a1e9ec15..720e48665 100644--- a/test/automl/test_python_log.py+++ b/test/automl/test_python_log.py@@ -84,7 +84,11 @@ class TestLogging(unittest.TestCase):min_resource=automl.min_resource,max_resource=automl.max_resource,config_constraints=[- (partial(size, automl._state), "<=", automl._mem_thres)+ (+ partial(size, automl._state.learner_classes),+ "<=",+ automl._mem_thres,+ )],metric_constraints=automl.metric_constraints,)diff --git a/test/automl/test_xgboost2d.py b/test/automl/test_xgboost2d.pyindex 46150a257..e31ac5314 100644--- a/test/automl/test_xgboost2d.py+++ b/test/automl/test_xgboost2d.py@@ -77,7 +77,9 @@ def test_simple(method=None):min_resource=automl.min_resource,max_resource=automl.max_resource,time_budget_s=automl._state.time_budget,- config_constraints=[(partial(size, automl._state), "<=", automl._mem_thres)],+ config_constraints=[+ (partial(size, automl._state.learner_classes), "<=", automl._mem_thres)+ ],metric_constraints=automl.metric_constraints,num_samples=5,)