This repository contains the source code for the NeurIPS 2023 paper "FLuID: Mitigating Stragglers in Federated Learning using Invariant Dropout" by Irene Wang, Prashant J. Nair, and Divya Mahajan. [pdf]
This project is implemented using the Flower framework v0.18.0. Also uses Flower's Android example as an implementation basis.
If you use FLuID in your research, please cite our paper:
@inproceedings{fluid,
author={Irene Wang and Prashant J. Nair and Divya Mahajan},
booktitle={Advances in Neural Information Processing Systems},
title={FLuID: Mitigating Stragglers in Federated Learning using Invariant Dropout},
year={2023}
}
The project requires Python >=3.7, <=3.9, and uses Gradle to build the client mobile app. The mobile application has been verified to be working for devices with at least Android 9 (sdk 28)
Install FLuID and other project dependencies
pip install flwr==0.18.0
pip install tensorflow
git clone https://github.com/iwang05/FLuID.git
cd FLuID
A reminder that the technique requires a minimum of 2 clients for training
-
To Install the application on an Android Device, first do the following:
- Enable
Developer Mode
andUSB debugging
on the Android Device - Connect a mobile device wirelessly or using a USB cord
- Enable
-
There are two options for building the client application:
- Using Android Studio
- In Android Studio open the project at
<Dataset>/client/
- Use the
Run App
function on Android Studio to build and install the application
- In Android Studio open the project at
- Using Gradlew
cd <Dataset>/client/ gradlew installDebug
- If on Max or Linux run
./gradlew installDebug
- If on Max or Linux run
- Using Android Studio
Configure <dataset>/server.py
- Specify the number of clients to run with
min_fit_clients
,min_eval_clients
, andmin_available_clients
, - Specify the server's IP address, and the number of rounds to run:
fl.server.start_server("192.168.1.7:1999", config={"num_rounds": 10}, server=server, strategy=strategy)
- To start the server, in
FLuID/<dataset>
run
python server.py
- Open the Client app corresponding on your phone
- Add the client ID (between 1-10), the IP and port of your server, and press
Load Dataset
. This will load the local dataset in memory. - Then press
Setup Connection Channel
which will establish a connection with the server. - Finally, press
Train Federated!
which will start the federated training.
Change the dropout method in fedDrop<dataset>_android.py
- This is the actual implementation of the dropout methods
- In the method
configure_fit
Select the desired dropout method
fit_ins_drop = FitIns(self.drop_rand(parameters, self.p_val, [0,3], 10, client.cid), config_drop)
NOTE: No additional model definition needed to be generated to run the current code.
- All 6 required model definitions to run the current code
p=[1.0, 0.95, 0.85, 0.75, 0.65, 0.5]
are included in<Dataset>/client/app/src/main/assets/model
- To modify the model, or add new sub-model sizes, you would need to generate
.tflite
files for all sub-model sizes that you wish to run, plus the full model sizep=1.0
To generate more model definitions for sub-model sizes:
- Define the modle in
<Dataset>/tflite_convertor/convert_to_tflite.py
. - Vary the
p
variable to create models of different sizes (1.0 = full model, 0.5 = model with half the size) - Execute the script, and models will be created in the
tflite_convertor/tflite_model
folder
python convert_to_tflite.py
- Rename each file as
<p>_<original file name>.tflite
.- For example, a the
train_head.tflite
file create withp=0.75
would be renamed as0.75_train_head.tflite
- For example, a the
- Add files to
<Dataset>/client/app/src/main/assets/model
directory
- Follow the
Processing the Dataset
instructions in the README files for each dataset subfolder - Add the downloaded datasets to
<Dataset>/client/app/src/main/assets/data
directory
This project contains the implementation of the FLuID framework for CIFAR10, FEMNIST, and Shakespeare and also implements baseline techniques for Random and Ordered Dropout.
These datasets are all publicly available for download. The Shakespeare and FEMNIST datasets can be obtained from the official LEAF Repo. Please follow the instructions there to download the LEAF datasets there
- 5 example user datasets are included for each dataset in
<Dataset>/client/app/src/main/assets/data
The CIFAR10 Implementation uses the dataset partitioned by and provided by the Flower Framework and can be downloaded from this link
Quick start instructions above outline the general steps to run FLuID, for dataset-specific processing instructions please refer to the README in each dataset subfolder.
- In case of an
SDK location not found
Error when building the Client Application, create a filelocal.properties
file in<Dataset>/client/
with the following line:
sdk.dir=<sdk dir path>
where <sdk.dir path>
is the path of where your Android SDK is installed.
This source code is licensed under the Apache License, Version 2.0 found in the LICENSE file in the root directory.