Giter Club home page Giter Club logo

fl_partial_personalization's Introduction

Federated Learning with Parial Model Personalization

Authors: Krishna Pillutla, Kshitiz Malik, Abdelrahman Mohamed, Michael Rabbat, Maziar Sanjabi, Lin Xiao

Contact: [email protected], [email protected]

Paper Link.

Requirements

Install PyTorch version 1.9 for your appropriate cuda version, as well torchvision and torchaudio. Then, install other dependences with pip install -r requirements.txt.

Outline of the Repository

Here is the outline:

  • The implementations of various federated optimization algorithms and federated dataloaders are in the folder pfl
  • There are two main files: train_pfl.py and train_finetune.py
  • All the scripts are in the scripts/ folder

The overall pipeline for each task is:

  1. Pretrain the model without personalization (i.e., using FedAvg variants)
  2. Personalize with partial model personalization (using the proposed FedAlt or FedSim) or pFedMe. Note that this stage does not apply for finetuning or Ditto (finetuning with L2 regularization)
  3. Finetune locally (for PFL, pFedMe and Ditto)

Main files

The two main files are:

  • train_pfl.py: for non-personalized pretraining (FedAvg variants) or federated personalization (partial peronsalization with FedAlt/FedSim or pFedMe). These correspond to steps 1 and 2 of the experiment pipeline.
  • train_finetune.py: for personalization with local finetuning. Run directly on the pretrained model for full model finetuning or Ditto. Run on the output of personalization for partial personalization and pFedMe. This corresponds to step 3 of the experiment pipeline.

Scripts

Here is the breakdown of the directory scripts/federated. This contains the scripts to run steps 1 and 2 of the pipeline.

  • scripts/federated/pretrain: pretrain each model with FedAvg variants
  • scripts/federated/partial_personalization: train partial personalization with stateful clients
  • scripts/federated/pfedme: run personalization with pFedMe
  • scripts/federated/generalization_L2: train partial personalization with local regularization (for the generalization experiments)
  • scripts/federated/generaliazation_dropout: train partial personalization with dropout (for the generalization experiments)

Here is the breakdown of the directory scripts/finetune. This containts the scripts to run step 3 of the pipeline.

  • scripts/finetune/finetune: finetune pretrained model either fully or partially (same model parts as partial personalization)
  • scripts/finetune/ditto: finetune pretrained models with L2 regularization (Ditto objective)
  • scripts/finetune/partial_personalization: finetune models trained with FedAlt/FedSim
  • scripts/finetune/pfedme: finetune pFedMe models
  • scripts/finetune/generalization_L2: finetune PFL + regularization models
  • scripts/finetune/generalization_dropout: finetune PFL + dropout models

Example use of scripts

The scripts for the experimental pipeline are:

  1. Pretrain in a non-personalized manner with FedAvg: scripts/federated/pretrain/stackoverflow.sh
  2. Run FedAlt: scripts/federated/partial_personalization/stackoverflow.sh - Note: the saved model in step 1 is loaded again in step 2. Make sure the argument pretrained_model_path points to the correct checkpoint from step 1
  3. Local Finetuning: scripts/finetune/partial_personalization/stackoverflow.sh

Implementation details

The codebase is constructed in a modular and extensible manner. The main functionality is divided into 3 parts: data, models and optimization. Correspondingly, the folder pfl contains the following subfolders:

  • pfl/data: federated dataloaders, from which individual client dataloaders can be obtained
  • pfl/models: implementation of the models. Includes splitting the model between the client and server parts, which can be accessed with model.client_parameters() and model.server_parameters() respectively
  • pfl/optim: implementation of federated learning algorithms including FedAvg, partial personalization approaches (FedSim and FedAlt) as well as pFedMe

Each of these See the README in each of these folders for more details. The details on how to add new datasets or new optimization algorithms are given there. In the current implementation, a new dataset also requires models specific to these datasets to be implemented.

Future work to improve the code

  • Abstract out the datasets into different tasks, so that the models are not data dependent
  • Multi-GPU training

License

This project is released under MIT License, which allows commercial use. See LICENSE for details.

Citation

If you find this repository useful, please consider giving a star โญ and citation:

@inproceedings{Pillutla2022pfl,
  author  = {Krishna Pillutla, Kshitiz Malik, Abdelrahman Mohamed, Michael Rabbat, Maziar Sanjabi, Lin Xiao},
  title   = {Federated Learning with Partial Model Personalization},
  booktitle = {Proceedings of the 39th International Conference on Machine Learning (ICML'22)},
  year    = {2022},
}

fl_partial_personalization's People

Contributors

linxiaolx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.