This repository contains the Proof of Concept (PoC) for running Federated Learning on top of Nillion. It consists of two main components: a Server and a Client.
Federated Learning is a machine learning technique that trains algorithms across multiple decentralized edge devices or servers holding local data samples, without exchanging them. This project demonstrates how to implement Federated Learning using Nillion's secure infrastructure.
- Python 3.10 or higher
- pip
- poetry
- Install poetry:
pip install poetry
- Install project dependencies with examples extras to run the examples:
poetry install -E examples
To run the Federated Learning system, you need to start the Nillion devnet, the server, and at least two clients.
- Start the Nillion devnet:
# Terminal 0
nillion-devnet
- Start the server:
# Terminal 1
poetry run python3 examples/logistic_regression/server.py
- Start the first client:
# Terminal 2
poetry run python3 examples/logistic_regression/client.py 0
- Start the second client:
# Terminal 3
poetry run python3 examples/logistic_regression/client.py 1
You can start additional clients by incrementing the client number on the server.py
file.
If you make changes to the fl_service.proto
file, you need to regenerate the gRPC code:
poetry run python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. nillion_fl/network/fl_service.proto
examples/
: Includes various example implementations (convolutional networks, logistic regression, neural networks).nillion_fl/
: The main package for Nillion Federated Learning (contains base client, and server implementations)core/
: Core components for client and server implementations.network/
: Contains protocol buffer definitions for network communication.nilvm/
: Nillion Network related components, including federated averaging implementation.pytorch/
: PyTorch-specific implementations for client and server.
This project is licensed under the Apache2 License. See the LICENSE file for details.