From 35649056d8e5de0e9c8ff98c6ae3d82324cdd0a6 Mon Sep 17 00:00:00 2001 From: joyce-yuan Date: Thu, 3 Oct 2024 19:51:49 +0000 Subject: [PATCH] config fix for get malicious configs, moving exp_id to sys_config --- src/configs/algo_config.py | 25 +++++-------------------- src/configs/sys_config.py | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/configs/algo_config.py b/src/configs/algo_config.py index 665cb77..a477b58 100644 --- a/src/configs/algo_config.py +++ b/src/configs/algo_config.py @@ -41,7 +41,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st iid_dispfl_clients_new: ConfigType = { "algo": "dispfl", - "exp_id": 12, "exp_type": "iid_dispfl", "neighbors": 2, "active_rate": 0.8, @@ -56,10 +55,9 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st traditional_fl: ConfigType = { "algo": "fedavg", - "exp_id": 10, - "exp_type": "test_malicious_zero_weights6", + "exp_type": "", # Learning setup - "epochs": 1000, + "epochs": 10, "model": "resnet10", "model_lr": 3e-4, "batch_size": 128, @@ -71,10 +69,9 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st "malicious_type": "bad_weights", } -fedweight_users: int = 3 + fedweight: ConfigType = { "algo": "fedweight", - "exp_id": "test1", "num_rep": 1, # Client selection @@ -83,7 +80,7 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st # "community_type": "dataset", "with_sim_consensus": True, # Learning setup - "rounds": 210, + "rounds": 10, "epochs_per_round": 5, "warmup_epochs": 50, "model": "resnet10", @@ -101,7 +98,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st defkt: ConfigType = { "algo": "defkt", - "exp_id": "defkt_test9", "central_client": 1, "mask_last_layer": False, "fine_tune_last_layer": False, @@ -119,8 +115,7 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st fedavg_object_detect: ConfigType = { "algo": "fedavg", - "exp_id": "test_modular_yolo", - "exp_type": "test", + "exp_type": "", # Learning setup "epochs": 10, "model": "yolo", @@ -130,7 +125,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st fediso: ConfigType = { "algo": "fediso", - "exp_id": "test3", "num_rep": 1, # Learning setup @@ -148,7 +142,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st L2C: ConfigType = { "algo": "l2c", "sharing": "weights", - "exp_id": "test3", "alpha_lr": 0.1, "alpha_weight_decay": 0.01, @@ -174,9 +167,7 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st } fedcentral: ConfigType = { - "seed": 1, "algo": "centralized", - "exp_id": "test5", "mask_last_layer": False, "fine_tune_last_layer": False, @@ -193,7 +184,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st fedval: ConfigType = { "algo": "fedval", - "exp_id": "", "num_rep": 1, # Clients selection @@ -222,7 +212,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st swarm_users: int = 3 swarm: ConfigType = { "algo": "swarm", - "exp_id": "test2", "num_rep": 1, # Clients selection @@ -249,7 +238,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st fedstatic: ConfigType = { "algo": "fedstatic", - "exp_id": "test_fedtorus_5", "num_rep": 1, "topology": "torus", @@ -277,7 +265,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st metaL2C_cifar10: ConfigType = { "algo": "metal2c", "sharing": "weights", #"updates" - "exp_id": "", # Client selection "target_users_before_T_0": 0, @@ -304,7 +291,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st fedass: ConfigType = { "algo": "fedass", - "exp_id": "", "num_rep": 1, "load_existing": False, @@ -330,7 +316,6 @@ def get_malicious_types(malicious_config_list: List[ConfigType]) -> Dict[str, st feddatarepr: ConfigType = { "algo": "feddatarepr", - "exp_id": "try2", "num_rep": 1, "load_existing": False, diff --git a/src/configs/sys_config.py b/src/configs/sys_config.py index d62e58c..9c506a1 100644 --- a/src/configs/sys_config.py +++ b/src/configs/sys_config.py @@ -51,6 +51,8 @@ def get_algo_configs(num_users: int, algo_configs: List[str], num_malicious: int # but ideally every node will have different algo # algo_config_map[f"node_{i}"] = random.choice(algo_configs) # As a proof of concept, we're only going to use the traditional fl algo + # in this case, algo_configs[0] is the traditional fl algo + # algo_configs[1] is the malicious fl algo if i < (num_users + 1 - num_malicious): algo_config_map[f"node_{i}"] = algo_configs[0] else: @@ -105,10 +107,11 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): } mpi_system_config = { + "exp_id": "test_new_logging", "comm": { "type": "MPI" }, - "num_users": 6, + "num_users": 3, # "experiment_path": "./experiments/", "dset": "cifar10", "dump_dir": "./expt_dump/", @@ -117,10 +120,10 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): # node_0 is a server currently # The device_ids dictionary depicts the GPUs on which the nodes reside. # For a single-GPU environment, the config will look as follows (as it follows a 0-based indexing): - "device_ids": get_device_ids(num_users=6, gpus_available=[1, 2]), + "device_ids": get_device_ids(num_users=3, gpus_available=[1, 2]), # use this when the list needs to be imported from the algo_config # "algo": get_algo_configs(num_users=3, algo_configs=algo_configs_list), - "algo": get_algo_configs(num_users=6, algo_configs=malicious_algo_config_list, num_malicious=1), + "algos": get_algo_configs(num_users=3, algo_configs=malicious_algo_config_list, num_malicious=0), "samples_per_user": 1000, #TODO: To model scenarios where different users have different number of samples # we need to make this a dictionary with user_id as key and number of samples as value "train_label_distribution": "iid", # Either "iid", "non_iid" "support" @@ -131,6 +134,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): } mpi_non_iid_sys_config = { + "exp_id": "test1", "comm": { "type": "MPI" }, @@ -153,6 +157,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): L2C_users = 3 mpi_L2C_sys_config = { + "exp_id": "test1", "comm": { "type": "MPI" }, @@ -175,6 +180,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): } mpi_metaL2C_support_sys_config = { + "exp_id": "test1", "comm": { "type": "MPI" }, @@ -198,6 +204,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): } mpi_digitfive_sys_config = { + "exp_id": "test1", "comm": { "type": "MPI" }, @@ -222,6 +229,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): swarm_users = 3 mpi_domainnet_sys_config = { + "exp_id": "test1", "comm": { "type": "MPI" }, @@ -245,6 +253,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): } object_detect_system_config = { + "exp_id": "test1", "num_users": 1, "experiment_path": "./experiments/", "dset": "pascal", @@ -267,6 +276,7 @@ def get_digit_five_support(num_users:int, domains:List[str]=DIGIT_FIVE): num_users = 20 gpu_ids = [1, 2, 3, 4, 5, 6, 7] grpc_system_config = { + "exp_id": "test1", "num_users": num_users, "comm": { "type": "GRPC",