Skip to content

Nikhil172913832/Federated_Learning

Repository files navigation

Federated Learning Platform

Production-grade federated learning with FedAvg, FedProx, differential privacy, and secure aggregation.


Quick Start (One Command)

./launch-platform.sh

Then visit:

That's it. The platform will:

  1. Start FL server and clients
  2. Train across multiple clients
  3. Show real-time progress
  4. Track experiments in MLflow

What You're Looking At

The Core (Start Here)

complete/fl/
├── fl/
│   ├── task.py          # ⭐ Core: train(), test(), load_data()
│   ├── server_app.py    # ⭐ Server: aggregation logic
│   ├── client_app.py    # ⭐ Client: local training
│   ├── aggregation.py   # FedAvg, FedProx, FedNova
│   ├── dp.py            # Differential privacy
│   └── secure_agg.py    # Secure aggregation
├── config/
│   └── default.yaml     # Configuration
└── tests/
    └── test_*.py        # Test suite (80%+ coverage)

Three files to understand the entire system:

  1. task.py - Training loop
  2. server_app.py - Server logic
  3. client_app.py - Client logic

What's Implemented

Algorithms

  • ✅ FedAvg (Federated Averaging)
  • ✅ FedProx (Proximal term for non-IID)
  • ✅ FedNova (Normalized averaging)
  • ✅ Scaffold (Variance reduction)

Privacy & Security

  • ✅ Differential Privacy (DP-SGD, ε-δ guarantees)
  • ✅ Secure Aggregation (encrypted updates)
  • ✅ Non-IID data (Dirichlet, label skew)

Production

  • ✅ Docker deployment
  • ✅ MLflow tracking
  • ✅ Real-time dashboard
  • ✅ 80%+ test coverage
  • ✅ CI/CD pipeline

Configuration

Edit complete/fl/config/default.yaml:

topology:
  num_clients: 10
  fraction: 0.5

train:
  lr: 0.01
  local_epochs: 1
  num_server_rounds: 10

data:
  dataset: "albertvillanova/medmnist-v2"
  subset: "pneumoniamnist"
  batch_size: 32

# Optional: Non-IID data
  non_iid:
    type: "label_skew"
    params:
      alpha: 0.5

# Optional: Differential Privacy
privacy:
  dp_sgd:
    enabled: true
    noise_multiplier: 0.8
    target_epsilon: 3.0

Performance

Configuration Dataset Accuracy Rounds Time
FedAvg (IID) MNIST 98.5% 10 90s
FedAvg (non-IID) MNIST 96.8% 20 180s
FedProx MNIST 97.3% 20 195s
FedAvg + DP MNIST 97.2% 15 120s
FedAvg PneumoniaMNIST 94.7% 50 300s

Tested on: Intel i7-10700K, 32GB RAM, NVIDIA RTX 3080


Development

Local (without Docker)

cd complete/fl
pip install -e ".[dev]"
pytest tests/ -v --cov=fl
flwr run . local-simulation --stream

Docker

./launch-platform.sh  # Start
docker compose -f complete/compose-with-ui.yml down  # Stop

Architecture

SuperLink (Server)
    ├── Aggregates updates (FedAvg/FedProx)
    ├── Manages rounds
    └── Logs to MLflow
         │
    ┌────┴────┬────────┬────────┐
    │         │        │        │
SuperNode  SuperNode  ...  SuperNode
(Client 1) (Client 2)     (Client N)
    │         │              │
Private    Private       Private
Data       Data          Data

Documentation


Testing

cd complete/fl

# All tests
pytest tests/ -v

# With coverage
pytest tests/ -v --cov=fl --cov-report=html

# Specific test
pytest tests/test_integration.py -v

Coverage: 80%+


What Makes This Production-Ready

  1. Battle-tested algorithms: FedAvg, FedProx, DP-SGD
  2. Comprehensive testing: 80%+ coverage
  3. Production deployment: Docker, Kubernetes
  4. Privacy guarantees: Differential privacy (ε-δ)
  5. Real-world datasets: Medical imaging
  6. Experiment tracking: MLflow integration
  7. Professional docs: Complete guides

License

Apache 2.0


One Command to Rule Them All

./launch-platform.sh

Everything else is in the docs.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published