From 15369e2776fee336e76a1d3bc31b4f19ece367a6 Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 01:31:19 +0800 Subject: [PATCH 1/9] add wrap fedex --- federatedscope/autotune/algos.py | 66 ++++++++++++++++++- federatedscope/contrib/trainer/example.py | 2 +- federatedscope/core/configs/cfg_hpo.py | 7 ++ .../example_configs/femnist/hpo_ss_fedex.yaml | 11 ++++ .../femnist/hpo_ss_fedex_arm.yaml | 15 +++++ .../femnist/hpo_ss_fedex_arm_table.yaml | 3 + .../femnist/hpo_ss_fedex_grid.yaml | 5 ++ .../example_configs/femnist/hpo_ss_sha.yaml | 17 +++++ federatedscope/example_configs/femnist/run.sh | 8 +++ .../example_configs/femnist/sha.yaml | 45 +++++++++++++ .../femnist/sha_wrap_fedex.yaml | 49 ++++++++++++++ .../femnist/sha_wrap_fedex_arm.yaml | 51 ++++++++++++++ .../example_configs/sha_wrap_fedex_arm.yaml | 32 +++++++++ .../sha_wrap_fedex_ss_table.yaml | 3 + 14 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 federatedscope/example_configs/femnist/hpo_ss_fedex.yaml create mode 100644 federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml create mode 100644 federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml create mode 100644 federatedscope/example_configs/femnist/hpo_ss_fedex_grid.yaml create mode 100644 federatedscope/example_configs/femnist/hpo_ss_sha.yaml create mode 100644 federatedscope/example_configs/femnist/run.sh create mode 100644 federatedscope/example_configs/femnist/sha.yaml create mode 100644 federatedscope/example_configs/femnist/sha_wrap_fedex.yaml create mode 100644 federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml create mode 100644 federatedscope/example_configs/sha_wrap_fedex_arm.yaml create mode 100644 federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml diff --git a/federatedscope/autotune/algos.py b/federatedscope/autotune/algos.py index 392f5bfcb..9272412f7 100644 --- a/federatedscope/autotune/algos.py +++ b/federatedscope/autotune/algos.py @@ -1,6 +1,8 @@ import os import logging from copy import deepcopy +from contextlib import redirect_stdout +from yacs.config import CfgNode as CN import threading from itertools import product import math @@ -59,6 +61,8 @@ def get_scheduler(init_cfg): scheduler = SuccessiveHalvingAlgo(init_cfg) elif init_cfg.hpo.scheduler == 'pbt': scheduler = PBT(init_cfg) + elif init_cfg.hpo.scheduler == 'wrap_sha': + scheduler = SHAWrapFedex(init_cfg) return scheduler @@ -72,7 +76,7 @@ def __init__(self, cfg): """ self._cfg = cfg - + # TODO: load from generated file. self._search_space = parse_search_space(self._cfg.hpo.ss) self._init_configs = self._setup() @@ -280,6 +284,64 @@ def _generate_next_population(self, configs, perfs): return next_population +class SHAWrapFedex(SuccessiveHalvingAlgo): + def _cache_yaml(self): + # Save as file + for idx in range(self._cfg.hpo.table.cand): + sample_ss = parse_search_space( + self._cfg.hpo.table.ss).sample_configuration( + self._cfg.hpo.table.num) + # Convert Configuration to CfgNode + tmp_cfg = CN() + for arm, configuration in enumerate(sample_ss): + tmp_cfg[f'arm{arm}'] = CN() + for key, value in configuration.get_dictionary().items(): + tmp_cfg[f'arm{arm}'][key] = value + + with open( + os.path.join(self._cfg.hpo.working_folder, + f'{idx}_tmp_grid_search_space.yaml'), + 'w') as f: + with redirect_stdout(f): + print(tmp_cfg.dump()) + + def _setup(self): + init_configs = super(SHAWrapFedex, self)._setup() + self._cache_yaml() + + for trial_cfg in init_configs: + trial_cfg['hpo.fedex.ss'] = os.path.join( + self._cfg.hpo.working_folder, + f"{trial_cfg['hpo.table.idx']}_tmp_grid_search_space.yaml") + + return init_configs + + # def _stop_criterion(self, configs, last_results): + # return len(configs) <= 1 + # + # def _generate_next_population(self, configs, perfs): + # indices = [(i, val) for i, val in enumerate(perfs)] + # indices.sort(key=lambda x: x[1], reverse=self._cfg.hpo.larger_better) + # next_population = [ + # configs[tp[0]] for tp in + # indices[:math. + # ceil(float(len(indices)) / self._cfg.hpo.sha.elim_rate)] + # ] + # + # for trial_cfg in next_population: + # if 'federate.restore_from' not in trial_cfg: + # trial_cfg['federate.restore_from'] = trial_cfg[ + # 'federate.save_to'] + # if self._cfg.hpo.sha.budgets and self._stage < len( + # self._cfg.hpo.sha.budgets): + # trial_cfg[ + # 'federate.total_round_num'] = self._cfg.hpo.sha.budgets[ + # self._stage] + # trial_cfg['eval.freq'] = self._cfg.hpo.sha.budgets[self._stage] + # + # return next_population + + # TODO: refactor PBT to enable async parallel #class PBT(IterativeScheduler): # """Population-based training (the full paper "Population Based Training of Neural Networks" can be found at https://arxiv.org/abs/1711.09846) tailored to FL setting, where, in each iteration, just a limited number of communication rounds are allowed for each trial (We will provide the asynchornous version later). @@ -353,4 +415,4 @@ def _generate_next_population(self, configs, perfs): # # next_generation.append(new_cfg) # -# return next_generation +# return next_generation \ No newline at end of file diff --git a/federatedscope/contrib/trainer/example.py b/federatedscope/contrib/trainer/example.py index 22c383ba4..ad4335a2c 100644 --- a/federatedscope/contrib/trainer/example.py +++ b/federatedscope/contrib/trainer/example.py @@ -1,5 +1,5 @@ from federatedscope.register import register_trainer -from federatedscope.core.trainers.trainer import GeneralTorchTrainer +from federatedscope.core.trainers.torch_trainer import GeneralTorchTrainer # Build your trainer here. diff --git a/federatedscope/core/configs/cfg_hpo.py b/federatedscope/core/configs/cfg_hpo.py index a54bf0298..ed5485b72 100644 --- a/federatedscope/core/configs/cfg_hpo.py +++ b/federatedscope/core/configs/cfg_hpo.py @@ -46,6 +46,13 @@ def extend_hpo_cfg(cfg): cfg.hpo.fedex.num_arms = 16 cfg.hpo.fedex.diff = False + # Table + cfg.hpo.table = CN() + cfg.hpo.table.ss = '' + cfg.hpo.table.num = 4 + cfg.hpo.table.cand = 81 + cfg.hpo.table.idx = 0 + def assert_hpo_cfg(cfg): # HPO related diff --git a/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml b/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml new file mode 100644 index 000000000..f54f6f94b --- /dev/null +++ b/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml @@ -0,0 +1,11 @@ +hpo.fedex.eta0: + type: cate + choices: [-1.0, 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1.0] +hpo.fedex.gamma: + type: float + lower: 0.0 + upper: 1.0 + log: True +hpo.fedex.diff: + type: cate + choices: [True, False] \ No newline at end of file diff --git a/federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml b/federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml new file mode 100644 index 000000000..ce5746295 --- /dev/null +++ b/federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml @@ -0,0 +1,15 @@ +optimizer.lr: + type: cate + choices: [0.01, 0.01668, 0.02783, 0.04642, 0.07743, 0.12915, 0.21544, 0.35938, 0.59948, 1.0] +optimizer.weight_decay: + type: cate + choices: [0.0, 0.001, 0.01, 0.1] +model.dropout: + type: cate + choices: [0.0, 0.5] +federate.local_update_steps: + type: cate + choices: [1, 2, 3, 4] +data.batch_size: + type: cate + choices: [16, 32, 64] \ No newline at end of file diff --git a/federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml b/federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml new file mode 100644 index 000000000..d40abc429 --- /dev/null +++ b/federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml @@ -0,0 +1,3 @@ +hpo.table.idx: + type: cate + choices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80] diff --git a/federatedscope/example_configs/femnist/hpo_ss_fedex_grid.yaml b/federatedscope/example_configs/femnist/hpo_ss_fedex_grid.yaml new file mode 100644 index 000000000..957548435 --- /dev/null +++ b/federatedscope/example_configs/femnist/hpo_ss_fedex_grid.yaml @@ -0,0 +1,5 @@ +optimizer.lr: [0.01, 0.01668, 0.02783, 0.04642, 0.07743, 0.12915, 0.21544, 0.35938, 0.59948, 1.0] +optimizer.weight_decay: [0.0, 0.001, 0.01, 0.1] +model.dropout: [0.0, 0.5] +federate.local_update_steps: [1, 2, 3, 4] +data.batch_size: [16, 32, 64] \ No newline at end of file diff --git a/federatedscope/example_configs/femnist/hpo_ss_sha.yaml b/federatedscope/example_configs/femnist/hpo_ss_sha.yaml new file mode 100644 index 000000000..62627ad19 --- /dev/null +++ b/federatedscope/example_configs/femnist/hpo_ss_sha.yaml @@ -0,0 +1,17 @@ +optimizer.lr: + type: float + lower: 0.01 + upper: 1.0 + log: True +optimizer.weight_decay: + type: cate + choices: [0.0, 0.001, 0.01, 0.1] +model.dropout: + type: cate + choices: [0.0, 0.5] +federate.local_update_steps: + type: cate + choices: [1, 2, 3, 4] +data.batch_size: + type: cate + choices: [16, 32, 64] \ No newline at end of file diff --git a/federatedscope/example_configs/femnist/run.sh b/federatedscope/example_configs/femnist/run.sh new file mode 100644 index 000000000..aaa695886 --- /dev/null +++ b/federatedscope/example_configs/femnist/run.sh @@ -0,0 +1,8 @@ +# SHA +python hpo.py --cfg federatedscope/example_configs/femnist/sha.yaml + +# SHA wrap FedEX (FedEX related param) +python hpo.py --cfg federatedscope/example_configs/femnist/sha_wrap_fedex.yaml + +# SHA wrap FedEX (arm) +python hpo.py --cfg federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml \ No newline at end of file diff --git a/federatedscope/example_configs/femnist/sha.yaml b/federatedscope/example_configs/femnist/sha.yaml new file mode 100644 index 000000000..3cc482bef --- /dev/null +++ b/federatedscope/example_configs/femnist/sha.yaml @@ -0,0 +1,45 @@ +use_gpu: True +device: 0 +early_stop: + patience: 100 +seed: 12345 +federate: + mode: standalone + local_update_steps: 1 + batch_or_epoch: epoch + total_round_num: 500 + sample_client_rate: 1.0 + share_local_model: True + online_aggr: True +data: + root: data/ + type: femnist + splits: [0.6,0.2,0.2] + batch_size: 16 + subsample: 0.05 + transform: [['ToTensor'], ['Normalize', {'mean': [0.1307], 'std': [0.3081]}]] + num_workers: 0 +model: + type: convnet2 + hidden: 2048 + out_channels: 62 + dropout: 0.5 +optimizer: + lr: 0.01 + weight_decay: 0.0 + grad_clip: 5.0 +criterion: + type: CrossEntropyLoss +trainer: + type: cvtrainer +eval: + freq: 1 + metrics: ['acc', 'correct', 'f1'] + split: ['test', 'val', 'train'] +hpo: + scheduler: sha + num_workers: 1 + init_cand_num: 81 + ss: federatedscope/example_configs/femnist/hpo_ss_sha.yaml + sha: + budgets: [2, 4, 12, 36] diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml new file mode 100644 index 000000000..91e00b01a --- /dev/null +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml @@ -0,0 +1,49 @@ +use_gpu: True +device: 0 +early_stop: + patience: 100 +seed: 12345 +federate: + mode: standalone + local_update_steps: 1 + batch_or_epoch: epoch + total_round_num: 500 + sample_client_rate: 1.0 + share_local_model: True + online_aggr: True +data: + root: data/ + type: femnist + splits: [0.6,0.2,0.2] + batch_size: 16 + subsample: 0.05 + transform: [['ToTensor'], ['Normalize', {'mean': [0.1307], 'std': [0.3081]}]] + num_workers: 0 +model: + type: convnet2 + hidden: 2048 + out_channels: 62 + dropout: 0.5 +optimizer: + lr: 0.01 + weight_decay: 0.0 + grad_clip: 5.0 +criterion: + type: CrossEntropyLoss +trainer: + type: cvtrainer +eval: + freq: 1 + metrics: ['acc', 'correct', 'f1'] + split: ['test', 'val', 'train'] +hpo: + scheduler: sha + num_workers: 1 + init_cand_num: 81 + ss: federatedscope/example_configs/femnist/hpo_ss_fedex.yaml + sha: + budgets: [2, 4, 12, 36] + fedex: + use: True + ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex_grid.yaml' + diff: True diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml new file mode 100644 index 000000000..21ff305ed --- /dev/null +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml @@ -0,0 +1,51 @@ +use_gpu: True +device: 0 +early_stop: + patience: 100 +seed: 12345 +federate: + mode: standalone + local_update_steps: 1 + batch_or_epoch: epoch + total_round_num: 500 + sample_client_rate: 1.0 + share_local_model: True + online_aggr: True +data: + root: data/ + type: femnist + splits: [0.6,0.2,0.2] + batch_size: 16 + subsample: 0.05 + transform: [['ToTensor'], ['Normalize', {'mean': [0.1307], 'std': [0.3081]}]] + num_workers: 0 +model: + type: convnet2 + hidden: 2048 + out_channels: 62 + dropout: 0.5 +optimizer: + lr: 0.01 + weight_decay: 0.0 + grad_clip: 5.0 +criterion: + type: CrossEntropyLoss +trainer: + type: cvtrainer +eval: + freq: 1 + metrics: ['acc', 'correct', 'f1'] + split: ['test', 'val', 'train'] +hpo: + scheduler: wrap_sha + num_workers: 1 + init_cand_num: 81 + ss: federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml + table: + ss: federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml + num: 4 + cand: 81 + sha: + budgets: [2, 4, 12, 36] + fedex: + use: True diff --git a/federatedscope/example_configs/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/sha_wrap_fedex_arm.yaml new file mode 100644 index 000000000..f047c965e --- /dev/null +++ b/federatedscope/example_configs/sha_wrap_fedex_arm.yaml @@ -0,0 +1,32 @@ +outdir: 'sha_wrap_fedex' +use_gpu: True +federate: + mode: 'standalone' + total_round_num: 20 + make_global_eval: False + client_num: 5 + share_local_model: True + online_aggr: True + use_diff: True +trainer: + type: 'general' +eval: + freq: 10 +data: + type: 'toy' +model: + type: 'lr' +hpo: + scheduler: wrap_sha + num_workers: 1 + init_cand_num: 5 + ss: federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml + table: + ss: federatedscope/example_configs/toy_hpo_ss.yaml + num: 4 + cand: 5 + sha: + budgets: [2, 4] + fedex: + use: True + diff --git a/federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml b/federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml new file mode 100644 index 000000000..7daa21631 --- /dev/null +++ b/federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml @@ -0,0 +1,3 @@ +hpo.table.idx: + type: cate + choices: [0, 1, 2, 3, 4] \ No newline at end of file From f3a02038ec2d16b7291922925e98e06700ca26f2 Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 01:35:48 +0800 Subject: [PATCH 2/9] remove redundant code --- federatedscope/autotune/algos.py | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/federatedscope/autotune/algos.py b/federatedscope/autotune/algos.py index 9272412f7..f7b886c45 100644 --- a/federatedscope/autotune/algos.py +++ b/federatedscope/autotune/algos.py @@ -4,14 +4,8 @@ from contextlib import redirect_stdout from yacs.config import CfgNode as CN import threading -from itertools import product import math -import yaml - -import numpy as np -import torch - from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.worker_builder import get_client_cls, get_server_cls @@ -76,7 +70,6 @@ def __init__(self, cfg): """ self._cfg = cfg - # TODO: load from generated file. self._search_space = parse_search_space(self._cfg.hpo.ss) self._init_configs = self._setup() @@ -316,31 +309,6 @@ def _setup(self): return init_configs - # def _stop_criterion(self, configs, last_results): - # return len(configs) <= 1 - # - # def _generate_next_population(self, configs, perfs): - # indices = [(i, val) for i, val in enumerate(perfs)] - # indices.sort(key=lambda x: x[1], reverse=self._cfg.hpo.larger_better) - # next_population = [ - # configs[tp[0]] for tp in - # indices[:math. - # ceil(float(len(indices)) / self._cfg.hpo.sha.elim_rate)] - # ] - # - # for trial_cfg in next_population: - # if 'federate.restore_from' not in trial_cfg: - # trial_cfg['federate.restore_from'] = trial_cfg[ - # 'federate.save_to'] - # if self._cfg.hpo.sha.budgets and self._stage < len( - # self._cfg.hpo.sha.budgets): - # trial_cfg[ - # 'federate.total_round_num'] = self._cfg.hpo.sha.budgets[ - # self._stage] - # trial_cfg['eval.freq'] = self._cfg.hpo.sha.budgets[self._stage] - # - # return next_population - # TODO: refactor PBT to enable async parallel #class PBT(IterativeScheduler): From 80a4e40d8179f1ba8e06a77a1d1fb56c8b64b656 Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 13:16:57 +0800 Subject: [PATCH 3/9] add yaml file --- .../example_configs/cora/hpo_ss_fedex.yaml | 11 +++++ .../cora/hpo_ss_fedex_arm.yaml | 12 +++++ .../cora/hpo_ss_fedex_arm_table.yaml | 3 ++ .../cora/hpo_ss_fedex_grid.yaml | 4 ++ .../example_configs/cora/hpo_ss_sha.yaml | 14 ++++++ federatedscope/example_configs/cora/sha.yaml | 43 ++++++++++++++++ .../example_configs/cora/sha_wrap_fedex.yaml | 46 +++++++++++++++++ .../cora/sha_wrap_fedex_arm.yaml | 49 +++++++++++++++++++ .../example_configs/femnist/hpo_ss_fedex.yaml | 2 +- .../example_configs/femnist/sha.yaml | 1 + .../femnist/sha_wrap_fedex.yaml | 1 + .../femnist/sha_wrap_fedex_arm.yaml | 1 + 12 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 federatedscope/example_configs/cora/hpo_ss_fedex.yaml create mode 100644 federatedscope/example_configs/cora/hpo_ss_fedex_arm.yaml create mode 100644 federatedscope/example_configs/cora/hpo_ss_fedex_arm_table.yaml create mode 100644 federatedscope/example_configs/cora/hpo_ss_fedex_grid.yaml create mode 100644 federatedscope/example_configs/cora/hpo_ss_sha.yaml create mode 100644 federatedscope/example_configs/cora/sha.yaml create mode 100644 federatedscope/example_configs/cora/sha_wrap_fedex.yaml create mode 100644 federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml diff --git a/federatedscope/example_configs/cora/hpo_ss_fedex.yaml b/federatedscope/example_configs/cora/hpo_ss_fedex.yaml new file mode 100644 index 000000000..edece27da --- /dev/null +++ b/federatedscope/example_configs/cora/hpo_ss_fedex.yaml @@ -0,0 +1,11 @@ +hpo.fedex.eta0: + type: cate + choices: [-1.0, 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1.0] +hpo.fedex.gamma: + type: float + lower: 0.0 + upper: 1.0 + log: False +hpo.fedex.diff: + type: cate + choices: [True, False] \ No newline at end of file diff --git a/federatedscope/example_configs/cora/hpo_ss_fedex_arm.yaml b/federatedscope/example_configs/cora/hpo_ss_fedex_arm.yaml new file mode 100644 index 000000000..b17cc0d4a --- /dev/null +++ b/federatedscope/example_configs/cora/hpo_ss_fedex_arm.yaml @@ -0,0 +1,12 @@ +optimizer.lr: + type: cate + choices: [0.01, 0.01668, 0.02783, 0.04642, 0.07743, 0.12915, 0.21544, 0.35938, 0.59948, 1.0] +optimizer.weight_decay: + type: cate + choices: [0.0, 0.001, 0.01, 0.1] +model.dropout: + type: cate + choices: [0.0, 0.5] +federate.local_update_steps: + type: cate + choices: [1, 2, 3, 4, 5, 6, 7, 8] \ No newline at end of file diff --git a/federatedscope/example_configs/cora/hpo_ss_fedex_arm_table.yaml b/federatedscope/example_configs/cora/hpo_ss_fedex_arm_table.yaml new file mode 100644 index 000000000..d40abc429 --- /dev/null +++ b/federatedscope/example_configs/cora/hpo_ss_fedex_arm_table.yaml @@ -0,0 +1,3 @@ +hpo.table.idx: + type: cate + choices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80] diff --git a/federatedscope/example_configs/cora/hpo_ss_fedex_grid.yaml b/federatedscope/example_configs/cora/hpo_ss_fedex_grid.yaml new file mode 100644 index 000000000..6a4ec35b2 --- /dev/null +++ b/federatedscope/example_configs/cora/hpo_ss_fedex_grid.yaml @@ -0,0 +1,4 @@ +optimizer.lr: [0.01, 0.01668, 0.02783, 0.04642, 0.07743, 0.12915, 0.21544, 0.35938, 0.59948, 1.0] +optimizer.weight_decay: [0.0, 0.001, 0.01, 0.1] +model.dropout: [0.0, 0.5] +federate.local_update_steps: [1, 2, 3, 4, 5, 6, 7, 8] \ No newline at end of file diff --git a/federatedscope/example_configs/cora/hpo_ss_sha.yaml b/federatedscope/example_configs/cora/hpo_ss_sha.yaml new file mode 100644 index 000000000..2d8509978 --- /dev/null +++ b/federatedscope/example_configs/cora/hpo_ss_sha.yaml @@ -0,0 +1,14 @@ +optimizer.lr: + type: float + lower: 0.01 + upper: 1.0 + log: True +optimizer.weight_decay: + type: cate + choices: [0.0, 0.001, 0.01, 0.1] +model.dropout: + type: cate + choices: [0.0, 0.5] +federate.local_update_steps: + type: cate + choices: [1, 2, 3, 4, 5, 6, 7, 8] \ No newline at end of file diff --git a/federatedscope/example_configs/cora/sha.yaml b/federatedscope/example_configs/cora/sha.yaml new file mode 100644 index 000000000..9c9b8c326 --- /dev/null +++ b/federatedscope/example_configs/cora/sha.yaml @@ -0,0 +1,43 @@ +use_gpu: True +device: 3 +early_stop: + patience: 100 +seed: 12345 +federate: + mode: standalone + make_global_eval: True + client_num: 5 + local_update_steps: 1 + total_round_num: 500 + share_local_model: True + online_aggr: True + use_diff: True +data: + root: data/ + type: cora + splitter: 'louvain' + batch_size: 1 +model: + type: gcn + hidden: 64 + dropout: 0.5 + out_channels: 7 +optimizer: + lr: 0.25 + weight_decay: 0.0005 +criterion: + type: CrossEntropyLoss +trainer: + type: nodefullbatch_trainer +eval: + freq: 1 + metrics: ['acc', 'correct', 'f1'] + split: ['test', 'val', 'train'] +hpo: + scheduler: sha + num_workers: 1 + init_cand_num: 81 + ss: 'federatedscope/example_configs/cora/hpo_ss_sha.yaml' + sha: + budgets: [2, 4, 12, 36] + metric: 'server_global_eval.val_loss' diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex.yaml new file mode 100644 index 000000000..9df1c19df --- /dev/null +++ b/federatedscope/example_configs/cora/sha_wrap_fedex.yaml @@ -0,0 +1,46 @@ +use_gpu: True +device: 3 +early_stop: + patience: 100 +seed: 12345 +federate: + mode: standalone + make_global_eval: True + client_num: 5 + local_update_steps: 1 + total_round_num: 500 + share_local_model: True + online_aggr: True + use_diff: True +data: + root: data/ + type: cora + splitter: 'louvain' + batch_size: 1 +model: + type: gcn + hidden: 64 + dropout: 0.5 + out_channels: 7 +optimizer: + lr: 0.25 + weight_decay: 0.0005 +criterion: + type: CrossEntropyLoss +trainer: + type: nodefullbatch_trainer +eval: + freq: 1 + metrics: ['acc', 'correct', 'f1'] + split: ['test', 'val', 'train'] +hpo: + scheduler: sha + num_workers: 1 + init_cand_num: 81 + ss: 'federatedscope/example_configs/cora/hpo_ss_fedex.yaml' + sha: + budgets: [2, 4, 12, 36] + fedex: + use: True + ss: 'federatedscope/example_configs/cora/hpo_ss_fedex_grid.yaml' + metric: 'server_global_eval.val_loss' diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml new file mode 100644 index 000000000..51f5bd4eb --- /dev/null +++ b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml @@ -0,0 +1,49 @@ +use_gpu: True +device: 3 +early_stop: + patience: 100 +seed: 12345 +federate: + mode: standalone + make_global_eval: True + client_num: 5 + local_update_steps: 1 + total_round_num: 500 + share_local_model: True + online_aggr: True + use_diff: True +data: + root: data/ + type: cora + splitter: 'louvain' + batch_size: 1 +model: + type: gcn + hidden: 64 + dropout: 0.5 + out_channels: 7 +optimizer: + lr: 0.25 + weight_decay: 0.0005 +criterion: + type: CrossEntropyLoss +trainer: + type: nodefullbatch_trainer +eval: + freq: 1 + metrics: ['acc', 'correct', 'f1'] + split: ['test', 'val', 'train'] +hpo: + scheduler: wrap_sha + num_workers: 1 + init_cand_num: 81 + ss: 'federatedscope/example_configs/cora/hpo_ss_fedex_arm_table.yaml' + table: + ss: 'federatedscope/example_configs/cora/hpo_ss_fedex_arm.yaml' + num: 4 + cand: 81 + sha: + budgets: [2, 4, 12, 36] + fedex: + use: True + metric: 'server_global_eval.val_loss' diff --git a/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml b/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml index f54f6f94b..edece27da 100644 --- a/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml +++ b/federatedscope/example_configs/femnist/hpo_ss_fedex.yaml @@ -5,7 +5,7 @@ hpo.fedex.gamma: type: float lower: 0.0 upper: 1.0 - log: True + log: False hpo.fedex.diff: type: cate choices: [True, False] \ No newline at end of file diff --git a/federatedscope/example_configs/femnist/sha.yaml b/federatedscope/example_configs/femnist/sha.yaml index 3cc482bef..50d72b21b 100644 --- a/federatedscope/example_configs/femnist/sha.yaml +++ b/federatedscope/example_configs/femnist/sha.yaml @@ -11,6 +11,7 @@ federate: sample_client_rate: 1.0 share_local_model: True online_aggr: True + use_diff: True data: root: data/ type: femnist diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml index 91e00b01a..bc44e4f5a 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml @@ -11,6 +11,7 @@ federate: sample_client_rate: 1.0 share_local_model: True online_aggr: True + use_diff: True data: root: data/ type: femnist diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml index 21ff305ed..06f685eef 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml @@ -11,6 +11,7 @@ federate: sample_client_rate: 1.0 share_local_model: True online_aggr: True + use_diff: True data: root: data/ type: femnist From c83b2a9e2d0609ff3de83861adf40c4f4fbd346a Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 13:31:01 +0800 Subject: [PATCH 4/9] merge master --- federatedscope/example_configs/cora/run.sh | 8 ++++++++ federatedscope/example_configs/cora/sha.yaml | 2 +- federatedscope/example_configs/cora/sha_wrap_fedex.yaml | 2 +- .../example_configs/cora/sha_wrap_fedex_arm.yaml | 2 +- federatedscope/example_configs/femnist/sha.yaml | 2 +- .../example_configs/femnist/sha_wrap_fedex.yaml | 2 +- .../example_configs/femnist/sha_wrap_fedex_arm.yaml | 2 +- federatedscope/example_configs/sha_wrap_fedex_arm.yaml | 4 ++-- 8 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 federatedscope/example_configs/cora/run.sh diff --git a/federatedscope/example_configs/cora/run.sh b/federatedscope/example_configs/cora/run.sh new file mode 100644 index 000000000..fcb735f6d --- /dev/null +++ b/federatedscope/example_configs/cora/run.sh @@ -0,0 +1,8 @@ +# SHA +python hpo.py --cfg federatedscope/example_configs/cora/sha.yaml + +# SHA wrap FedEX (FedEX related param) +python hpo.py --cfg federatedscope/example_configs/cora/sha_wrap_fedex.yaml + +# SHA wrap FedEX (arm) +python hpo.py --cfg federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml \ No newline at end of file diff --git a/federatedscope/example_configs/cora/sha.yaml b/federatedscope/example_configs/cora/sha.yaml index 9c9b8c326..37f7347f8 100644 --- a/federatedscope/example_configs/cora/sha.yaml +++ b/federatedscope/example_configs/cora/sha.yaml @@ -35,7 +35,7 @@ eval: split: ['test', 'val', 'train'] hpo: scheduler: sha - num_workers: 1 + num_workers: 0 init_cand_num: 81 ss: 'federatedscope/example_configs/cora/hpo_ss_sha.yaml' sha: diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex.yaml index 9df1c19df..9e29970c1 100644 --- a/federatedscope/example_configs/cora/sha_wrap_fedex.yaml +++ b/federatedscope/example_configs/cora/sha_wrap_fedex.yaml @@ -35,7 +35,7 @@ eval: split: ['test', 'val', 'train'] hpo: scheduler: sha - num_workers: 1 + num_workers: 0 init_cand_num: 81 ss: 'federatedscope/example_configs/cora/hpo_ss_fedex.yaml' sha: diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml index 51f5bd4eb..887bcdb11 100644 --- a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml @@ -35,7 +35,7 @@ eval: split: ['test', 'val', 'train'] hpo: scheduler: wrap_sha - num_workers: 1 + num_workers: 0 init_cand_num: 81 ss: 'federatedscope/example_configs/cora/hpo_ss_fedex_arm_table.yaml' table: diff --git a/federatedscope/example_configs/femnist/sha.yaml b/federatedscope/example_configs/femnist/sha.yaml index 50d72b21b..e6bb74fc3 100644 --- a/federatedscope/example_configs/femnist/sha.yaml +++ b/federatedscope/example_configs/femnist/sha.yaml @@ -39,7 +39,7 @@ eval: split: ['test', 'val', 'train'] hpo: scheduler: sha - num_workers: 1 + num_workers: 0 init_cand_num: 81 ss: federatedscope/example_configs/femnist/hpo_ss_sha.yaml sha: diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml index bc44e4f5a..bc02516e5 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml @@ -39,7 +39,7 @@ eval: split: ['test', 'val', 'train'] hpo: scheduler: sha - num_workers: 1 + num_workers: 0 init_cand_num: 81 ss: federatedscope/example_configs/femnist/hpo_ss_fedex.yaml sha: diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml index 06f685eef..83d3a3060 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml @@ -39,7 +39,7 @@ eval: split: ['test', 'val', 'train'] hpo: scheduler: wrap_sha - num_workers: 1 + num_workers: 0 init_cand_num: 81 ss: federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml table: diff --git a/federatedscope/example_configs/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/sha_wrap_fedex_arm.yaml index f047c965e..72736b897 100644 --- a/federatedscope/example_configs/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/sha_wrap_fedex_arm.yaml @@ -20,9 +20,9 @@ hpo: scheduler: wrap_sha num_workers: 1 init_cand_num: 5 - ss: federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml + ss: 'federatedscope/example_configs/sha_wrap_fedex_ss_table.yaml' table: - ss: federatedscope/example_configs/toy_hpo_ss.yaml + ss: 'federatedscope/example_configs/toy_hpo_ss.yaml' num: 4 cand: 5 sha: From ee2ec121d69f4c5e587da1a1e754b6371ff21f51 Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 13:55:25 +0800 Subject: [PATCH 5/9] fix minor bug --- federatedscope/example_configs/cora/sha.yaml | 2 +- federatedscope/example_configs/cora/sha_wrap_fedex.yaml | 2 +- .../example_configs/cora/sha_wrap_fedex_arm.yaml | 2 +- federatedscope/example_configs/femnist/sha.yaml | 6 ++++-- .../example_configs/femnist/sha_wrap_fedex.yaml | 7 ++++--- .../example_configs/femnist/sha_wrap_fedex_arm.yaml | 8 +++++--- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/federatedscope/example_configs/cora/sha.yaml b/federatedscope/example_configs/cora/sha.yaml index 37f7347f8..95987c55c 100644 --- a/federatedscope/example_configs/cora/sha.yaml +++ b/federatedscope/example_configs/cora/sha.yaml @@ -40,4 +40,4 @@ hpo: ss: 'federatedscope/example_configs/cora/hpo_ss_sha.yaml' sha: budgets: [2, 4, 12, 36] - metric: 'server_global_eval.val_loss' + metric: 'server_global_eval.val_avg_loss' diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex.yaml index 9e29970c1..81667ac39 100644 --- a/federatedscope/example_configs/cora/sha_wrap_fedex.yaml +++ b/federatedscope/example_configs/cora/sha_wrap_fedex.yaml @@ -43,4 +43,4 @@ hpo: fedex: use: True ss: 'federatedscope/example_configs/cora/hpo_ss_fedex_grid.yaml' - metric: 'server_global_eval.val_loss' + metric: 'server_global_eval.val_avg_loss' diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml index 887bcdb11..5c2b5109e 100644 --- a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml @@ -46,4 +46,4 @@ hpo: budgets: [2, 4, 12, 36] fedex: use: True - metric: 'server_global_eval.val_loss' + metric: 'server_global_eval.val_avg_loss' diff --git a/federatedscope/example_configs/femnist/sha.yaml b/federatedscope/example_configs/femnist/sha.yaml index e6bb74fc3..c1da95261 100644 --- a/federatedscope/example_configs/femnist/sha.yaml +++ b/federatedscope/example_configs/femnist/sha.yaml @@ -1,5 +1,5 @@ use_gpu: True -device: 0 +device: 3 early_stop: patience: 100 seed: 12345 @@ -28,6 +28,7 @@ model: optimizer: lr: 0.01 weight_decay: 0.0 +grad: grad_clip: 5.0 criterion: type: CrossEntropyLoss @@ -41,6 +42,7 @@ hpo: scheduler: sha num_workers: 0 init_cand_num: 81 - ss: federatedscope/example_configs/femnist/hpo_ss_sha.yaml + ss: 'federatedscope/example_configs/femnist/hpo_ss_sha.yaml' sha: budgets: [2, 4, 12, 36] + metric: 'client_summarized_weighted_avg.val_avg_loss' diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml index bc02516e5..3409febcc 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex.yaml @@ -1,5 +1,5 @@ use_gpu: True -device: 0 +device: 3 early_stop: patience: 100 seed: 12345 @@ -28,6 +28,7 @@ model: optimizer: lr: 0.01 weight_decay: 0.0 +grad: grad_clip: 5.0 criterion: type: CrossEntropyLoss @@ -41,10 +42,10 @@ hpo: scheduler: sha num_workers: 0 init_cand_num: 81 - ss: federatedscope/example_configs/femnist/hpo_ss_fedex.yaml + ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex.yaml' sha: budgets: [2, 4, 12, 36] fedex: use: True ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex_grid.yaml' - diff: True + metric: 'client_summarized_weighted_avg.val_avg_loss' diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml index 83d3a3060..39309339c 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml @@ -1,5 +1,5 @@ use_gpu: True -device: 0 +device: 3 early_stop: patience: 100 seed: 12345 @@ -28,6 +28,7 @@ model: optimizer: lr: 0.01 weight_decay: 0.0 +grad: grad_clip: 5.0 criterion: type: CrossEntropyLoss @@ -41,12 +42,13 @@ hpo: scheduler: wrap_sha num_workers: 0 init_cand_num: 81 - ss: federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml + ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml' table: - ss: federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml + ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml' num: 4 cand: 81 sha: budgets: [2, 4, 12, 36] fedex: use: True + metric: 'client_summarized_weighted_avg.val_avg_loss' \ No newline at end of file From 2e3df5932738d1ab8e0898240520bc3fe10a3bd1 Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 15:37:17 +0800 Subject: [PATCH 6/9] sample without rep --- federatedscope/autotune/algos.py | 6 +++++- federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/federatedscope/autotune/algos.py b/federatedscope/autotune/algos.py index b034918bc..7c8144ee1 100644 --- a/federatedscope/autotune/algos.py +++ b/federatedscope/autotune/algos.py @@ -332,10 +332,14 @@ def _setup(self): init_configs = super(SHAWrapFedex, self)._setup() self._cache_yaml() - for trial_cfg in init_configs: + for idx, trial_cfg in enumerate(init_configs): + trial_cfg['hpo.table.idx'] = idx trial_cfg['hpo.fedex.ss'] = os.path.join( self._cfg.hpo.working_folder, f"{trial_cfg['hpo.table.idx']}_tmp_grid_search_space.yaml") + trial_cfg['federate.save_to'] = os.path.join( + self._cfg.hpo.working_folder, + "{}.pth".format(config2str(trial_cfg))) return init_configs diff --git a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml index 5c2b5109e..b3dac5916 100644 --- a/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/cora/sha_wrap_fedex_arm.yaml @@ -46,4 +46,7 @@ hpo: budgets: [2, 4, 12, 36] fedex: use: True + diff: False + eta0: 0.050 + gamma: 0.495861 metric: 'server_global_eval.val_avg_loss' From d8f9e9a828ed5f5f8f20bd2ed16c65cfb0903f54 Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 15:53:40 +0800 Subject: [PATCH 7/9] add plt tools --- federatedscope/autotune/utils.py | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/federatedscope/autotune/utils.py b/federatedscope/autotune/utils.py index 7d4fa74e3..44eeda46e 100644 --- a/federatedscope/autotune/utils.py +++ b/federatedscope/autotune/utils.py @@ -83,3 +83,55 @@ def summarize_hpo_results(configs, perfs, white_list=None, desc=False): d = sorted(d, key=lambda ele: ele[-1], reverse=desc) df = pd.DataFrame(d, columns=cols) return df + + +def parse_logs(file_list): + import numpy as np + import matplotlib.pyplot as plt + + FONTSIZE = 40 + MARKSIZE = 25 + + def process(file): + history = [] + with open(file, 'r') as F: + for line in F: + try: + state, line = line.split('INFO: ') + config = eval(line[line.find('{'): line.find('}') + 1]) + performance = float(line[line.find('performance'):].split(' ')[1]) + print(config, performance) + history.append((config, performance)) + except: + continue + best_seen = np.inf + tol_budget = 0 + x, y = [], [] + + for config, performance in history: + tol_budget += config['federate.total_round_num'] + if best_seen > performance or config['federate.total_round_num'] > tmp_b: + best_seen = performance + x.append(tol_budget) + y.append(best_seen) + tmp_b = config['federate.total_round_num'] + return np.array(x) / tol_budget, np.array(y) + + # Draw + plt.figure(figsize=(10, 7.5)) + plt.xticks(fontsize=FONTSIZE) + plt.yticks(fontsize=FONTSIZE) + + plt.xlabel('Fraction of budget', size=FONTSIZE) + plt.ylabel('Loss', size=FONTSIZE) + + for file in file_list: + x, y = process(file) + plt.plot(x, y, linewidth=1, markersize=MARKSIZE) + plt.legend(file_list, fontsize=23, loc='lower right') + plt.savefig(f'exp2.pdf', bbox_inches='tight') + plt.close() + + + + From 6da942ab5e80b87581b22ff903fd2ecf9566d8eb Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Sun, 5 Jun 2022 21:57:33 +0800 Subject: [PATCH 8/9] fix file name --- federatedscope/autotune/algos.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/federatedscope/autotune/algos.py b/federatedscope/autotune/algos.py index 7c8144ee1..b58861a66 100644 --- a/federatedscope/autotune/algos.py +++ b/federatedscope/autotune/algos.py @@ -329,8 +329,8 @@ def _cache_yaml(self): print(tmp_cfg.dump()) def _setup(self): - init_configs = super(SHAWrapFedex, self)._setup() self._cache_yaml() + init_configs = super(SHAWrapFedex, self)._setup() for idx, trial_cfg in enumerate(init_configs): trial_cfg['hpo.table.idx'] = idx @@ -339,8 +339,8 @@ def _setup(self): f"{trial_cfg['hpo.table.idx']}_tmp_grid_search_space.yaml") trial_cfg['federate.save_to'] = os.path.join( self._cfg.hpo.working_folder, - "{}.pth".format(config2str(trial_cfg))) - + "idx_{}.pth".format(idx)) + print(init_configs) return init_configs From 1c47c0cb292a2503c8761d19be23d62ec93bc94b Mon Sep 17 00:00:00 2001 From: rayrayraykk <18007356109@163.com> Date: Mon, 6 Jun 2022 13:29:16 +0800 Subject: [PATCH 9/9] update config --- federatedscope/example_configs/femnist/sha.yaml | 4 ++-- .../example_configs/femnist/sha_wrap_fedex_arm.yaml | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/federatedscope/example_configs/femnist/sha.yaml b/federatedscope/example_configs/femnist/sha.yaml index c1da95261..7da25a142 100644 --- a/federatedscope/example_configs/femnist/sha.yaml +++ b/federatedscope/example_configs/femnist/sha.yaml @@ -41,8 +41,8 @@ eval: hpo: scheduler: sha num_workers: 0 - init_cand_num: 81 + init_cand_num: 27 ss: 'federatedscope/example_configs/femnist/hpo_ss_sha.yaml' sha: - budgets: [2, 4, 12, 36] + budgets: [12, 13, 19] metric: 'client_summarized_weighted_avg.val_avg_loss' diff --git a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml index 39309339c..6d134a9d8 100644 --- a/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml +++ b/federatedscope/example_configs/femnist/sha_wrap_fedex_arm.yaml @@ -41,14 +41,18 @@ eval: hpo: scheduler: wrap_sha num_workers: 0 - init_cand_num: 81 + init_cand_num: 27 ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex_arm_table.yaml' table: ss: 'federatedscope/example_configs/femnist/hpo_ss_fedex_arm.yaml' - num: 4 + num: 27 cand: 81 sha: - budgets: [2, 4, 12, 36] + budgets: [12, 13, 19] fedex: + sched: 'aggressive' use: True + diff: False + eta0: -1.0 + gamma: 0.0 metric: 'client_summarized_weighted_avg.val_avg_loss' \ No newline at end of file