Skip to content

Commit

Permalink
config fix for get malicious configs, moving exp_id to sys_config
Browse files Browse the repository at this point in the history
  • Loading branch information
joyce-yuan committed Oct 3, 2024
1 parent 88a3f6c commit 3564905
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
25 changes: 5 additions & 20 deletions src/configs/algo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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",

Expand Down Expand Up @@ -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,
Expand All @@ -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,

Expand All @@ -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,

Expand Down
16 changes: 13 additions & 3 deletions src/configs/sys_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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/",
Expand All @@ -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"
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 3564905

Please sign in to comment.