From f6aa8eed3f30ac3c0207efa9c07fd15a2a76da44 Mon Sep 17 00:00:00 2001 From: Jing Dong Date: Tue, 13 Dec 2022 14:19:09 -0800 Subject: [PATCH 1/5] Added an info reminding user that if no time_budget and no max_iter is specified, then effectively zero-shot AutoML is used --- flaml/automl/automl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flaml/automl/automl.py b/flaml/automl/automl.py index 078ce67a2..e5eecb3fa 100644 --- a/flaml/automl/automl.py +++ b/flaml/automl/automl.py @@ -2566,6 +2566,11 @@ class AutoML(BaseEstimator): self._use_ray = use_ray or n_concurrent_trials > 1 # use the following condition if we have an estimation of average_trial_time and average_trial_overhead # self._use_ray = use_ray or n_concurrent_trials > ( average_trail_time + average_trial_overhead) / (average_trial_time) + + # If no time_budget and no max_iter is specified, then effectively zero-shot AutoML is used. + if time_budget is -1 and max_iter is None: + logger.info('Neither time_budegt nor max_iter is specified, zero-shot ML is used. ') + if self._use_ray is not False: import ray From 5778227a714396815502cfed0f2d5a9900ee105f Mon Sep 17 00:00:00 2001 From: Jing Dong <35925336+jingdong00@users.noreply.github.com> Date: Fri, 16 Dec 2022 14:41:33 +0800 Subject: [PATCH 2/5] Fix checkpoint path issue checkpoint path may be named dir_or_data instead of value --- website/docs/Examples/Tune-PyTorch.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/docs/Examples/Tune-PyTorch.md b/website/docs/Examples/Tune-PyTorch.md index 83f38e609..d75c716c7 100644 --- a/website/docs/Examples/Tune-PyTorch.md +++ b/website/docs/Examples/Tune-PyTorch.md @@ -261,7 +261,8 @@ if torch.cuda.is_available(): best_trained_model = nn.DataParallel(best_trained_model) best_trained_model.to(device) -checkpoint_path = os.path.join(best_trial.checkpoint.value, "checkpoint") +checkpoint_value = getattr(best_trial.checkpoint, "dir_or_data", None) or best_trial.checkpoint.value +checkpoint_path = os.path.join(checkpoint_value, "checkpoint") model_state, optimizer_state = torch.load(checkpoint_path) best_trained_model.load_state_dict(model_state) @@ -283,4 +284,4 @@ Files already downloaded and verified Best trial test set accuracy: 0.6294 ``` -[Link to notebook](https://github.com/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb) | [Open in colab](https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb) \ No newline at end of file +[Link to notebook](https://github.com/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb) | [Open in colab](https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/tune_pytorch.ipynb) From 68886053881336142809673a8afb93a7b6d89009 Mon Sep 17 00:00:00 2001 From: skzhang1 Date: Sat, 17 Dec 2022 13:31:52 -0500 Subject: [PATCH 3/5] remove --- flaml/automl/automl.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/flaml/automl/automl.py b/flaml/automl/automl.py index e5eecb3fa..ea1031738 100644 --- a/flaml/automl/automl.py +++ b/flaml/automl/automl.py @@ -2567,10 +2567,6 @@ class AutoML(BaseEstimator): # use the following condition if we have an estimation of average_trial_time and average_trial_overhead # self._use_ray = use_ray or n_concurrent_trials > ( average_trail_time + average_trial_overhead) / (average_trial_time) - # If no time_budget and no max_iter is specified, then effectively zero-shot AutoML is used. - if time_budget is -1 and max_iter is None: - logger.info('Neither time_budegt nor max_iter is specified, zero-shot ML is used. ') - if self._use_ray is not False: import ray From 7e4e4c7901897983bc45d5546ac869c83edf702f Mon Sep 17 00:00:00 2001 From: skzhang1 Date: Sat, 17 Dec 2022 13:34:11 -0500 Subject: [PATCH 4/5] clean up --- flaml/automl/automl.py | 1 - 1 file changed, 1 deletion(-) diff --git a/flaml/automl/automl.py b/flaml/automl/automl.py index ea1031738..078ce67a2 100644 --- a/flaml/automl/automl.py +++ b/flaml/automl/automl.py @@ -2566,7 +2566,6 @@ class AutoML(BaseEstimator): self._use_ray = use_ray or n_concurrent_trials > 1 # use the following condition if we have an estimation of average_trial_time and average_trial_overhead # self._use_ray = use_ray or n_concurrent_trials > ( average_trail_time + average_trial_overhead) / (average_trial_time) - if self._use_ray is not False: import ray From 3a194d047bae043fbdc79dfd3cde05be8687dc49 Mon Sep 17 00:00:00 2001 From: Jing Dong Date: Mon, 19 Dec 2022 09:22:16 -0800 Subject: [PATCH 5/5] fix checkpoint.value in the notebook and test --- notebook/tune_pytorch.ipynb | 19 +++++++++++++------ test/tune/test_pytorch_cifar10.py | 6 +++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/notebook/tune_pytorch.ipynb b/notebook/tune_pytorch.ipynb index d90f4fb9c..93153ac50 100644 --- a/notebook/tune_pytorch.ipynb +++ b/notebook/tune_pytorch.ipynb @@ -347,7 +347,11 @@ " best_trained_model = nn.DataParallel(best_trained_model)\n", "best_trained_model.to(device)\n", "\n", - "checkpoint_path = os.path.join(best_trial.checkpoint.value, \"checkpoint\")\n", + "checkpoint_value = (\n", + " getattr(best_trial.checkpoint, \"dir_or_data\", None)\n", + " or best_trial.checkpoint.value\n", + ")\n", + "checkpoint_path = os.path.join(checkpoint_value, \"checkpoint\")\n", "\n", "model_state, optimizer_state = torch.load(checkpoint_path)\n", "best_trained_model.load_state_dict(model_state)\n", @@ -358,11 +362,9 @@ } ], "metadata": { - "interpreter": { - "hash": "f7771e6a3915580179405189f5aa4eb9047494cbe4e005b29b851351b54902f6" - }, "kernelspec": { - "display_name": "Python 3.8.10 64-bit ('venv': venv)", + "display_name": "Python 3.11.0 64-bit", + "language": "python", "name": "python3" }, "language_info": { @@ -375,12 +377,17 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.12" + "version": "3.11.0" }, "metadata": { "interpreter": { "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" } + }, + "vscode": { + "interpreter": { + "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" + } } }, "nbformat": 4, diff --git a/test/tune/test_pytorch_cifar10.py b/test/tune/test_pytorch_cifar10.py index 2151bf281..188d9750f 100644 --- a/test/tune/test_pytorch_cifar10.py +++ b/test/tune/test_pytorch_cifar10.py @@ -313,7 +313,11 @@ def cifar10_main( best_trained_model = nn.DataParallel(best_trained_model) best_trained_model.to(device) - checkpoint_path = os.path.join(best_trial.checkpoint.value, "checkpoint") + checkpoint_value = ( + getattr(best_trial.checkpoint, "dir_or_data", None) + or best_trial.checkpoint.value + ) + checkpoint_path = os.path.join(checkpoint_value, "checkpoint") model_state, optimizer_state = torch.load(checkpoint_path) best_trained_model.load_state_dict(model_state)