Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed attack invocation in fl #151

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/algos/fl.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,9 @@ def test(self, **kwargs: Any) -> Tuple[float, float, float]:
self.stats["test_loss"], self.stats["test_acc"], self.stats["test_time"] = test_loss, test_acc, time_taken
return test_loss, test_acc, time_taken

def receive_attack_and_aggregate(self, round: int, attack_start_round: int, attack_end_round: int, dump_file_name: str = ""):
def receive_attack_and_aggregate(self, round: int, attack_start_round: int, attack_end_round: int):
reprs = self.comm_utils.all_gather()

with open(dump_file_name, "wb") as f:
pickle.dump(reprs, f)

# Handle GIA-specific logic
if "gia" in self.config:
print("Server Running GIA attack")
Expand Down Expand Up @@ -229,12 +226,13 @@ def single_round(self, round: int, attack_start_round: int = 0, attack_end_round
attack_end_round (int): The last round for the attack to be performed.
"""

# Normal training when outside the attack range

if round < attack_start_round or round > attack_end_round:
self.receive_and_aggregate()
# Determine if the attack should be performed
attack_in_progress = self.gia_attacker and attack_start_round <= round <= attack_end_round

if attack_in_progress:
self.receive_attack_and_aggregate(round, attack_start_round, attack_end_round)
else:
self.receive_attack_and_aggregate(round, attack_start_round, attack_end_round, dump_file_name)
self.receive_and_aggregate()


def run_protocol(self):
Expand Down
Loading