-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(framework): add FedRDF robust dynamic aggregation strategy #6044
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
base: main
Are you sure you want to change the base?
Conversation
|
Hey @francordel , thanks for opening the PR! We recently migrated all strategies to https://github.com/adap/flower/tree/main/framework/py/flwr/serverapp/strategy and make use of the |
|
Hi @francordel, just checking in here to see if there are any questions from your end re Javier's above comments. Please let us know by when you aim to continue working on this PR. Best regards, |
|
Hi @WilliamLindskog, |
Addresses review feedback from PR adap#6044 by @danieljanes: "We recently migrated all strategies to serverapp/strategy and make use of the Message abstraction instead of FitIns/Res etc. Could you update the strategy in that way? Also, because scipy is not a package that comes with Flower, we'll need to put the import in a try/except." Migration implementation: - Moved from server/strategy to serverapp/strategy - Replaced FitIns/FitRes with Message abstraction (Iterable[Message]) - Use ArrayRecord/MetricRecord instead of Parameters/Metrics - Updated aggregate_train/aggregate_evaluate signatures for Message API - Wrapped scipy import in try/except with HAS_SCIPY flag (lines 31-37) - Added ImportError in __init__ with installation instructions (lines 133-137) - Migrated all unit tests to new API Performance optimization: During migration testing, discovered critical bottleneck in _compute_skewness that made threshold > 0 functionality impractical: - Sample max 100 weight positions instead of testing all positions - Reduces K-S test complexity from O(n_parameters * 100) to O(100 * 100) - Enables practical use of adaptive FedAvg/FFT switching - Threshold=0.5 now completes in ~97s vs hanging indefinitely Scipy dependency handling: Import wrapped in try/except block with HAS_SCIPY flag. Strategy __init__ raises ImportError with clear message if scipy not installed, directing users to install scipy>=1.7.0. Files changed: - framework/py/flwr/serverapp/strategy/fedrdf.py (new, migrated + optimized) - framework/py/flwr/serverapp/strategy/fedrdf_test.py (new, migrated) - framework/py/flwr/serverapp/strategy/__init__.py (add FedRDF export) - framework/py/flwr/server/strategy/__init__.py (remove old export) - framework/py/flwr/server/strategy/fedrdf.py (deleted) - framework/py/flwr/server/strategy/fedrdf_test.py (deleted) Testing: - All unit tests passing in new location - Threshold functionality verified working (0.0, 0.5, 1.0 tested) - ImportError raised correctly when scipy not available Related: PR adap#6044
|
Good evening @jafermarq @WilliamLindskog ! Addresses review feedback from PR #6044 by @danieljanes: Migration implementation:
Performance optimization:
Scipy dependency handling: Files changed:
Testing:
|
Issue
Closes #6043.
Description
Flower currently lacks a robust aggregation strategy to defend against poisoning attacks in Federated Learning.
When malicious clients send corrupted model updates, the standard FedAvg aggregation can be heavily compromised, leading to a significant degradation in global model performance.
Related issues/PRs
Proposal
Implement FedRDF (Robust and Dynamic Aggregation Function) — a strategy that defends against poisoning attacks through adaptive, frequency-domain aggregation.
Explanation
FedRDF introduces the following improvements:
thresholdparameter controls the robustness–efficiency trade-off.threshold ≤ 0: Always uses FFT-based robust aggregation.threshold > 0: Switches adaptively based on detected skewness.Implementation Details
FedAvg.aggregate_fit()to perform adaptive, DFT-based aggregation.thresholdparameter for dynamic switching.Testing
Reference
E. Mármol Campos, A. González-Vidal, J. L. Hernández-Ramos, and A. Skarmeta,
"FedRDF: A Robust and Dynamic Aggregation Function Against Poisoning Attacks in Federated Learning",
IEEE Transactions on Emerging Topics in Computing, vol. 13, no. 1, pp. 48–67, 2025.
DOI: 10.1109/TETC.2024.3474484
Checklist
#contributions).Any other comments?
Files changed:
framework/py/flwr/server/strategy/fedrdf.py(371 lines) — strategy implementation.framework/py/flwr/server/strategy/fedrdf_test.py(228 lines) — test suite.framework/py/flwr/server/strategy/__init__.py(2 lines) — addedFedRDFexport.