From 4e33e43e9f72625e23657164a81d2b4a9b0aad2a Mon Sep 17 00:00:00 2001 From: liuzhe-lz <40699903+liuzhe-lz@users.noreply.github.com> Date: Fri, 18 Feb 2022 15:17:02 +0800 Subject: [PATCH] Manually cherry-pick bug fix PRs (#4532) --- dependencies/required.txt | 3 ++- dependencies/required_extra.txt | 4 ++-- nni/algorithms/hpo/tpe_tuner.py | 9 ++++++--- nni/tools/nnictl/ts_management.py | 2 +- pipelines/integration-test-aml.yml | 2 -- pipelines/integration-test-hybrid.yml | 2 -- pipelines/integration-test-kubeflow.yml | 2 -- pipelines/integration-test-openpai-linux.yml | 2 -- pipelines/integration-test-remote-l2l.yml | 2 -- pipelines/integration-test-remote-l2w.yml | 2 -- pipelines/integration-test-trt.yml | 2 -- test/ut/sdk/test_builtin_tuners.py | 2 ++ 12 files changed, 13 insertions(+), 21 deletions(-) diff --git a/dependencies/required.txt b/dependencies/required.txt index 2f61063a4b..322d2fcc73 100644 --- a/dependencies/required.txt +++ b/dependencies/required.txt @@ -4,7 +4,8 @@ json_tricks >= 3.15.5 psutil pyyaml >= 5.4 requests -responses +responses ; python_version >= "3.7" +responses < 0.18 ; python_version < "3.7" schema typeguard PythonWebHDFS diff --git a/dependencies/required_extra.txt b/dependencies/required_extra.txt index 7e3be7525c..4ec68e1246 100644 --- a/dependencies/required_extra.txt +++ b/dependencies/required_extra.txt @@ -6,8 +6,8 @@ ConfigSpaceNNI smac4nni # BOHB -ConfigSpace==0.4.11 -statsmodels==0.12.0 +ConfigSpace>=0.4.11 +statsmodels>=0.12.0 # PPOTuner gym diff --git a/nni/algorithms/hpo/tpe_tuner.py b/nni/algorithms/hpo/tpe_tuner.py index 4f8e4e5fde..c233e97b23 100644 --- a/nni/algorithms/hpo/tpe_tuner.py +++ b/nni/algorithms/hpo/tpe_tuner.py @@ -22,6 +22,7 @@ from nni.tuner import Tuner from nni.common.hpo_utils import OptimizeMode, format_search_space, deformat_parameters, format_parameters +from nni.utils import extract_scalar_reward from . import random_tuner _logger = logging.getLogger('nni.tuner.tpe') @@ -126,9 +127,11 @@ def generate_parameters(self, parameter_id, **kwargs): self._running_params[parameter_id] = params return deformat_parameters(params, self.space) - def receive_trial_result(self, parameter_id, _parameters, loss, **kwargs): - if self.optimize_mode is OptimizeMode.Maximize: - loss = -loss + def receive_trial_result(self, parameter_id, _parameters, value, **kwargs): + if self.optimize_mode is OptimizeMode.Minimize: + loss = extract_scalar_reward(value) + else: + loss = -extract_scalar_reward(value) if self.liar: self.liar.update(loss) params = self._running_params.pop(parameter_id) diff --git a/nni/tools/nnictl/ts_management.py b/nni/tools/nnictl/ts_management.py index 8703c0e92f..4dffe21ebf 100644 --- a/nni/tools/nnictl/ts_management.py +++ b/nni/tools/nnictl/ts_management.py @@ -9,7 +9,7 @@ 'remote', 'openpai', 'pai', 'aml', - 'dlc' + 'dlc', 'kubeflow', 'frameworkcontroller', 'adl', diff --git a/pipelines/integration-test-aml.yml b/pipelines/integration-test-aml.yml index 1fa5d2468a..d16899d0fc 100644 --- a/pipelines/integration-test-aml.yml +++ b/pipelines/integration-test-aml.yml @@ -19,8 +19,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" echo "Build docker image: $(build_docker_image)" - - python3 -m pip install --upgrade pip setuptools displayName: Prepare - script: | diff --git a/pipelines/integration-test-hybrid.yml b/pipelines/integration-test-hybrid.yml index b852ed1b22..862e695a17 100644 --- a/pipelines/integration-test-hybrid.yml +++ b/pipelines/integration-test-hybrid.yml @@ -18,8 +18,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" - - python3 -m pip install --upgrade pip setuptools displayName: Prepare - script: | diff --git a/pipelines/integration-test-kubeflow.yml b/pipelines/integration-test-kubeflow.yml index c91644eacc..6068d7998b 100644 --- a/pipelines/integration-test-kubeflow.yml +++ b/pipelines/integration-test-kubeflow.yml @@ -22,8 +22,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" - - python3 -m pip install --upgrade pip setuptools displayName: Prepare - script: | diff --git a/pipelines/integration-test-openpai-linux.yml b/pipelines/integration-test-openpai-linux.yml index f9e4bf5434..08733b6a5c 100644 --- a/pipelines/integration-test-openpai-linux.yml +++ b/pipelines/integration-test-openpai-linux.yml @@ -25,8 +25,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" echo "Build docker image: $(build_docker_image)" - - python3 -m pip install --upgrade pip setuptools displayName: Prepare - script: | diff --git a/pipelines/integration-test-remote-l2l.yml b/pipelines/integration-test-remote-l2l.yml index 455817c3a2..65a2d3a67e 100644 --- a/pipelines/integration-test-remote-l2l.yml +++ b/pipelines/integration-test-remote-l2l.yml @@ -23,8 +23,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" - - python3 -m pip install --upgrade pip setuptools displayName: Prepare - script: | diff --git a/pipelines/integration-test-remote-l2w.yml b/pipelines/integration-test-remote-l2w.yml index f660e92436..1cd2af7492 100644 --- a/pipelines/integration-test-remote-l2w.yml +++ b/pipelines/integration-test-remote-l2w.yml @@ -27,7 +27,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" echo "Build ID: $(Build.BuildId)" - python3 -m pip install --upgrade pip setuptools python3 setup.py clean --all displayName: Prepare on Linux manager @@ -44,7 +43,6 @@ jobs: sshEndpoint: $(worker) runOptions: commands commands: | - conda activate l2w & python -m pip install --upgrade pip setuptools conda activate l2w & python /tmp/nnitest/$(Build.BuildId)/test/vso_tools/install_nni.py $(NNI_RELEASE) failOnStdErr: false displayName: Install NNI on Windows worker diff --git a/pipelines/integration-test-trt.yml b/pipelines/integration-test-trt.yml index d8bc7ef162..5f73b34d8c 100644 --- a/pipelines/integration-test-trt.yml +++ b/pipelines/integration-test-trt.yml @@ -18,8 +18,6 @@ jobs: echo "Working directory: ${PWD}" echo "NNI version: ${NNI_RELEASE}" - - python3 -m pip install --upgrade pip setuptools displayName: Prepare - script: | diff --git a/test/ut/sdk/test_builtin_tuners.py b/test/ut/sdk/test_builtin_tuners.py index 597dfefff2..c201ae8a9d 100644 --- a/test/ut/sdk/test_builtin_tuners.py +++ b/test/ut/sdk/test_builtin_tuners.py @@ -58,6 +58,8 @@ def receive(*args): return receive def send_trial_result(self, tuner, parameter_id, parameters, metrics): + if parameter_id % 2 == 1: + metrics = {'default': metrics, 'extra': 'hello'} tuner.receive_trial_result(parameter_id, parameters, metrics) tuner.trial_end(parameter_id, True)