Skip to content
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

Llm eloquence2 #788

Open
wants to merge 124 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
61e4b51
Init for LLM (#592)
rayrayraykk May 15, 2023
b5ff4ab
update
rayrayraykk May 15, 2023
144d79e
Merge pull request #595 from rayrayraykk/dev_llm
qbc2016 May 15, 2023
166c800
add LICENSE
rayrayraykk May 15, 2023
bf3ed37
merge
rayrayraykk May 15, 2023
3980e3b
fix minor bugs
rayrayraykk May 16, 2023
669d1ac
add chatbot
rayrayraykk May 16, 2023
8a98c79
modify
rayrayraykk May 16, 2023
a1dd245
modify yaml
rayrayraykk May 16, 2023
b67d8ea
Merge pull request #596 from rayrayraykk/dev_llm
qbc2016 May 16, 2023
cba1cd4
update
rayrayraykk May 16, 2023
e189689
Merge pull request #597 from rayrayraykk/dev_llm
qbc2016 May 16, 2023
13e42bd
fix
rayrayraykk May 16, 2023
e3851aa
fix
rayrayraykk May 16, 2023
1dfeb0c
enable prompt
rayrayraykk May 16, 2023
41a2aca
Merge pull request #598 from rayrayraykk/dev_llm
qbc2016 May 16, 2023
3ea0118
LLM Enhancement: model sharding (#599)
rayrayraykk May 29, 2023
a7232e5
Add adapters (#607)
qbc2016 May 29, 2023
5fe8a49
[Feature] Offsite tuning (#610)
rayrayraykk Jun 1, 2023
0328a63
[HotFix] Fix device map when transformer version mismatch (#619)
rayrayraykk Jun 2, 2023
535c84c
igore eval in llm (#621)
rayrayraykk Jun 5, 2023
7032473
Add eval for MMLU (#618)
qbc2016 Jun 5, 2023
97cb787
[Feature] Add dataset dolly (#620)
rayrayraykk Jun 6, 2023
027649a
Clean & Merge master (#622)
rayrayraykk Jun 6, 2023
88f8075
Eval llm for gsm8k (#624)
rayrayraykk Jun 7, 2023
963c66c
Fix NaN in LLM train (#625)
rayrayraykk Jun 7, 2023
bff080d
Optimize gsm8k evaluation (#626)
rayrayraykk Jun 8, 2023
39e2920
Fix offsite tuning (#629)
HarliWu Jun 12, 2023
ca804fb
Add code search net for SFT (#627)
rayrayraykk Jun 13, 2023
a671ca3
update eval in gsm8k
rayrayraykk Jun 13, 2023
943c3ec
remove
rayrayraykk Jun 13, 2023
441c622
Merge branch 'dev/llm' into new_gsm
rayrayraykk Jun 13, 2023
9bb350e
Merge pull request #630 from rayrayraykk/new_gsm
qbc2016 Jun 14, 2023
6c2c4b3
Add HumanEval for Code (#631)
rayrayraykk Jun 14, 2023
d96b9d1
add rosetta_alpaca
rayrayraykk Jun 14, 2023
9b55a4a
minor change
rayrayraykk Jun 14, 2023
039084f
format
rayrayraykk Jun 14, 2023
32a3407
remove redundant
rayrayraykk Jun 14, 2023
35df393
update
rayrayraykk Jun 14, 2023
05a2c4a
Add new fine-tune dataset (#632)
qbc2016 Jun 14, 2023
65c9687
fix update
rayrayraykk Jun 15, 2023
423f735
remove final save
rayrayraykk Jun 15, 2023
cf0c076
Optimize llm setup (#635)
rayrayraykk Jun 15, 2023
263730c
keep save final
rayrayraykk Jun 16, 2023
e65e7f8
minor change to rosetta
rayrayraykk Jun 16, 2023
4832248
[Hotfix]Save best model #637 from rayrayraykk
qbc2016 Jun 16, 2023
053cd73
Merge pull request #638 from rayrayraykk/ros
qbc2016 Jun 16, 2023
2591d2e
Offsite-tuning evaluation for raw/plugin model (#633)
HarliWu Jun 19, 2023
1830142
add Dockerfile
rayrayraykk Jun 19, 2023
0cdab29
update README
rayrayraykk Jun 19, 2023
63b37e6
Add exp yaml files (#623)
qbc2016 Jun 20, 2023
458d42e
update setup
rayrayraykk Jun 20, 2023
9911f3a
add README
rayrayraykk Jun 20, 2023
1bf2f44
update conf
rayrayraykk Jun 20, 2023
5c31894
add move to helm
rayrayraykk Jun 20, 2023
bc0f485
Eval HELM in LLM #643 from rayrayraykk/df_helm
qbc2016 Jun 20, 2023
ed63f5b
update readme for helm_fs and yaml for dolly meta (#645)
qbc2016 Jun 21, 2023
776f5d1
optimize memory usage (#646)
rayrayraykk Jun 26, 2023
680a763
update yaml parameters (#648)
qbc2016 Jun 28, 2023
09aa9d6
Fix issues in offsite tuning (#649)
rayrayraykk Jun 28, 2023
0a765ed
optimize memory usage in offsite-tuning
rayrayraykk Jun 28, 2023
24e5925
remove debug
rayrayraykk Jun 28, 2023
2495519
fix save_freq bug
rayrayraykk Jun 28, 2023
e9d126a
Merge pull request #650 from rayrayraykk/opt_ost
ZiTao-Li Jun 29, 2023
4c752f0
Support flops calculation on LLM (#651)
HarliWu Jul 3, 2023
f9151d7
update readme for docker (#654)
qbc2016 Jul 4, 2023
3632d6f
Update docker readme (#655)
qbc2016 Jul 4, 2023
eddd176
LLM readme & Dockerfile (#657)
rayrayraykk Jul 5, 2023
3314d76
add prefix tuning, prompt tuning and p-tuning (#658)
qbc2016 Jul 5, 2023
9cb009f
Update docker readme (#656)
qbc2016 Jul 6, 2023
6c74fb9
fix save bug
rayrayraykk Jul 6, 2023
4478209
fix
rayrayraykk Jul 6, 2023
880d602
fix minor bugs
rayrayraykk Jul 6, 2023
634abad
Fix save path of ckpt #659 from rayrayraykk
qbc2016 Jul 6, 2023
cdc17bb
Fix share_local_model compatibility with model.half() (#660)
rayrayraykk Jul 6, 2023
5b68918
Update readme for fshelm (#662)
qbc2016 Jul 10, 2023
f0c4e42
README for LLM (#661)
rayrayraykk Jul 11, 2023
bed8da9
fix minor bugs in fschat(#663)
rayrayraykk Jul 12, 2023
31e707f
fix share_local_model (#665)
rayrayraykk Jul 13, 2023
3a6a844
Fix yaml and add warnings for count flops (#666)
rayrayraykk Jul 14, 2023
281d9d2
Fix bugs for HumanEval (#667)
HarliWu Jul 19, 2023
1073864
reimplement pFedme (#669)
rayrayraykk Jul 21, 2023
0aad31e
Kd alignment for Offsite-tuning (#668)
rayrayraykk Jul 24, 2023
ec9026d
fix_div_by_zero (#673)
rayrayraykk Aug 1, 2023
c09bfe0
Fix offsite tuning eval (#674)
rayrayraykk Aug 1, 2023
366a180
Fix and update distillation (#675)
rayrayraykk Aug 3, 2023
0cb5040
fix bugs for local train of ot (#678)
qbc2016 Aug 8, 2023
688b55d
Fix save best model(#679)
rayrayraykk Aug 9, 2023
2805af0
Need keep raw model when kd applied (#680)
rayrayraykk Aug 11, 2023
56c6fec
modify mmlu eval in fs (#682)
qbc2016 Aug 25, 2023
d29161a
[Experimental Feature]DeepSpeed for LLM with standalone and distribut…
rayrayraykk Sep 4, 2023
4076c16
docstring and README for FS-LLM (#685)
rayrayraykk Sep 4, 2023
29619c1
Fix URL in LLM banch (#686)
rayrayraykk Sep 4, 2023
841d5dc
add llm part in readme in configuration (#687)
qbc2016 Sep 5, 2023
3b9e6ae
fix half precision for helm (#690)
qbc2016 Sep 5, 2023
68de68e
change branch name to llm in README (#691)
qbc2016 Sep 5, 2023
3293871
build paper list for fl-llm (#693)
qbc2016 Sep 6, 2023
a95bf28
Add unit test for LLMs (#696)
rayrayraykk Sep 6, 2023
13d1b6d
Add HumanEvalX for eval (#692)
rayrayraykk Sep 6, 2023
28a6109
Support fine-tune LLMs in ModelScope (#695)
rayrayraykk Sep 6, 2023
b963f62
add retry option when loss is NaN in train and finetune (#697)
rayrayraykk Sep 11, 2023
8da9f9f
hotfix for get_tokenizer (#704)
qbc2016 Sep 20, 2023
7f08694
fix typo in readme for helm (#738)
qbc2016 Dec 25, 2023
d47149d
model_builder.py modified to work with bfloat16
Oct 6, 2024
3d2a637
model_builder.py modified to work with bfloat16
aleixsant Oct 6, 2024
0945d7d
Add config files (.yaml, .json...)
aleixsant Oct 6, 2024
bb8b6d3
Use_fast changed to True
aleixsant Oct 7, 2024
4b4a03e
New config files
aleixsant Oct 14, 2024
70466b3
New readme
aleixsant Oct 14, 2024
c63b234
New readme
aleixsant Oct 14, 2024
6c1b313
New readme
aleixsant Oct 14, 2024
bdb1f3b
New readme
aleixsant Oct 14, 2024
c605f72
New readme
aleixsant Oct 14, 2024
538bc2a
New readme
aleixsant Oct 14, 2024
2b47c9d
New readme
aleixsant Oct 14, 2024
1fc5889
New readme
aleixsant Oct 14, 2024
04bd483
New readme
aleixsant Oct 14, 2024
d90bd2f
New readme
aleixsant Oct 14, 2024
8f2c0d7
New readme
aleixsant Oct 14, 2024
a50da04
New config files
aleixsant Oct 14, 2024
007b5d2
Modifed README_setup.md
aleixsant Oct 15, 2024
7c170a6
Modifed README_setup.md
aleixsant Oct 15, 2024
20fa2d5
Modifed README_setup.md
aleixsant Oct 15, 2024
029ceeb
Update setup.py
aleixsant Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/test_llm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: UnitTests for Fine-tuning LLMs

on:
pull_request:
types: [opened, synchronize, edited]

jobs:
run:
if: false == contains(github.event.pull_request.title, 'WIP')
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.9']
torch-version: ['2.0.0']
torchvision-version: ['0.15.0']
torchaudio-version: ['2.0.0']
env:
OS: ${{ matrix.os }}
PYTHON: '3.9'
steps:
- uses: actions/checkout@master
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install PyTorch ${{ matrix.torch-version }}+cpu
run: |
pip install numpy typing-extensions dataclasses
pip install torch==${{ matrix.torch-version}}+cpu torchvision==${{matrix.torchvision-version}}+cpu torchaudio==${{matrix.torchaudio-version}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install FS
run: |
pip install -e .[llm,test]
- name: Test GPT2
run: |
python federatedscope/main.py --cfg federatedscope/llm/baseline/testcase.yaml federate.total_round_num 1 eval.count_flops False train.local_update_steps 2 data.splits "[0.998, 0.001, 0.001]"
[ $? -eq 1 ] && exit 1 || echo "Passed"
- name: Test GPT2 with offsite-tuning
run: |
python federatedscope/main.py --cfg federatedscope/llm/baseline/testcase.yaml federate.total_round_num 1 eval.count_flops False llm.offsite_tuning.use True llm.offsite_tuning.emu_l 2 llm.offsite_tuning.emu_r 10 train.local_update_steps 2 data.splits "[0.998, 0.001, 0.001]"
[ $? -eq 1 ] && exit 1 || echo "Passed"
42 changes: 42 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -661,3 +661,45 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

---------------------------------------------------------------------------------
The implementations of LLM dataset in federatedscope/llm/dataset/llm_dataset.py
adapted from https://github.com/tatsu-lab/stanford_alpaca (Apache License)

Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

---------------------------------------------------------------------------------
The implementations of evaluation for MMLU in federatedscope/llm/eval_for_mmlu/eval.py
and federatedscope/llm/eval_for_mmlu/categories.py are adapted from https://github.com/hendrycks/test (MIT License)

Copyright (c) 2020 Dan Hendrycks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
339 changes: 339 additions & 0 deletions README-main.md

Large diffs are not rendered by default.

334 changes: 0 additions & 334 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
89 changes: 89 additions & 0 deletions README_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Installation, Setup and Running of FederatedScope for LLMs Fine-tuning

First, use a virtual environment manager such as pyenv to create a virtual environment. Make sure you are using Python 3.9.0:

```bash
pyenv install 3.9.0
pyenv virtualenv 3.9.0 fs-llm_3.9.0
pyenv activate fs-llm_3.9.0
```

Clone the specific branch of the FederatedScope repository to your machine:

```bash
git clone --branch llm-eloquence https://github.com/jordiluque/FederatedScope.git
```

To ensure that the correct CUDA paths are set, add the following lines to your `.bashrc` (or equivalent shell configuration file). The CUDA version should be around version 12 (e.g., 12.4, 12.5, or 12.6). If you don’t already have the [CUTLASS](https://github.com/NVIDIA/cutlass) repository installed, clone and set it up on your machine.

```bash
export PATH=/usr/local/cuda-12/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12/lib64:/usr/local/cuda-12/lib:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-12
export CUTLASS_PATH=/home/user/repos/cutlass
```

After editing `.bashrc`, don't forget to run:

```bash
source ~/.bashrc
```

Install the following Python libraries. The specific versions are known to work well:
```bash
pip install torch==2.4.1 torchaudio==2.4.1 torchvision==0.19.1
```

From the source of the repository, install the required FederatedScope requirements:
```bash
pip install -e .[llm]
```

Check if the default script runs correctly to verify the installation:

```bash
python federatedscope/main.py --cfg federatedscope/llm/baseline/testcase.yaml
```

Now let's install and configure DeepSpeed. It is is highly recommended for efficiently fine-tuning LLMs. To install it, run:

```bash
pip install deepspeed
```

Install the cupy library for CUDA Acceleration with CUDA 12 support:

```bash
pip install cupy-cuda12x
```

If you are working with recent models (e.g., Phi models), they may not be included in the default version of the transformers library. In this case, upgrade the library:

```bash
pip install --upgrade transformers
```

Before using DeepSpeed, review the configuration file at `federatedscope/llm/baseline/deepspeed/ds_config_4bs.json`. Ensure that the train_batch_size parameter is properly set to match the number of GPUs available on your machine.

Check if fine-tuning an LLM in standalone mode works correctly with DeepSpeed. Run the following script to verify that the fine-tuning process is functioning properly:

```bash
deepspeed federatedscope/main.py --cfg configs/standalone/Phi-3.5-mini-instruct/ds_3c_200r_30ls.yaml
```

To execute federated fine-tuning in distributed mode, separate commands need to be run for the server and each client. In the FederatedScope framework, each client must run on a different machine. The following config files will allow us to test if the setup works with two clients in distributed mode. However, before running the commands, ensure that the `server_host`, `server_port`, `client_host`, and `client_port` fields in the config files are updated with the correct IP addresses and ports for your machines. Additionally, adjust CUDA_VISIBLE_DEVICES to reflect the number of GPUs available on each machine.

To run the server use:
```bash
deepspeed --master_addr=127.0.0.1 --master_port=29500 federatedscope/main.py --cfg configs/distributed/Phi-3.5-mini-instruct/server_ds_2c_200r_30ls.yaml
```

To run a first client in one machine use:
```bash
CUDA_VISIBLE_DEVICES=0,1,2 deepspeed --master_addr=127.0.0.1 --master_port=29500 federatedscope/main.py --cfg configs/distributed/Phi-3.5-mini-instruct/client_1_ds_2c_200r_30ls.yaml
```

To run a second client in another machine:
```bash
CUDA_VISIBLE_DEVICES=0,1,2 deepspeed --master_addr=127.0.0.1 --master_port=29500 federatedscope/main.py --cfg configs/distributed/Phi-3.5-mini-instruct/client_2_ds_2c_200r_30ls.yaml
```
91 changes: 91 additions & 0 deletions benchmark/Backdoor-bench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Benchmark for Back-door Attack on Personalized Federated Learning



Backdoor-bench is a benchmark for backdoor attacks on personalized federated learning. It contains backdoor attacks including [edge-based trigger](https://arxiv.org/abs/2007.05084), [BadNet](https://ieeexplore.ieee.org/document/8685687), [Blended](https://arxiv.org/abs/1712.05526) and [SIG](https://arxiv.org/abs/1902.11237). The attacked pFL methods include: FedAvg, Fine-tuning (FT), Ditto, FedEM, pFedMe, FedBN, FedRep. More details about the benchmark settings and experimental results refer to our KDD [paper](https://arxiv.org/abs/2302.01677).

**Notice**:
Considering FederatedScope is an open-sourced library that updates frequently, to ensure the reproducibility of the experimental results, we create a new branch `backdoor-bench`. The users can reproduce the results by running the configs under the directory [scripts/B-backdoor_scripts attack_config](https://github.com/alibaba/FederatedScope/tree/backdoor-bench/scripts/backdoor_scripts/attack_config). The results of our paper is located in `paper_plot/results_all`.

## Publications

If you find Back-door-bench useful for your research or development, please cite the following [paper](https://arxiv.org/pdf/2302.01677.pdf):

```tex
@inproceedings{
qin2023revisiting,
title={Revisiting Personalized Federated Learning: Robustness Against Backdoor Attacks},
author={Zeyu Qin and Liuyi Yao and Daoyuan Chen and Yaliang Li and Bolin Ding and Minhao Cheng},
booktitle={29th SIGKDD Conference on Knowledge Discovery and Data Mining - Applied Data Science Track},
year={2023},
}
```

## Quick Start

To run the script, you should
- First clone the repository [FederatedScope](https://github.com/alibaba/FederatedScope),
- Then follow [README.md](https://github.com/alibaba/FederatedScope/blob/master/README.md) to build the running environment for FederatedScope,
- Switch to the branch `backdoor-bench` and run the scripts
```bash
# Step-1. clone the repository
git clone https://github.com/alibaba/FederatedScope.git

# Step-2. follow https://github.com/alibaba/FederatedScope/blob/master/README.md to build the running environment

# Step-3. install packages required by the benchmark
pip install opencv-python matplotlib pympler scikit-learn

# Step-3. switch to the branch `backdoor-bench` for the benchmark
git fetch
git switch backdoor-bench

# Step-4. run the baseline (taking attacking FedAvg with Edge type trigger as an example)
cd FederatedScope
python federatedscope/main.py --cfg scripts/backdoor_scripts/attack_config/backdoor_fedavg_resnet18_on_cifar10_small.yaml

```
## Reimplementing Results of Paper

The all scripts of conducting experiments are in file [attack_config](https://github.com/alibaba/FederatedScope/tree/backdoor-bench/scripts/backdoor_scripts/attack_config).
- **Backdoor or not**: Files with 'backdoor' in their filename are experimental instructions related to backdoor poisoning during the training process. Files without 'backdoor' are experimental instructions about normal FL or pFL training process.
- **Models**: Files with different models name represents experiments with using different models, such as "convnet" or "resnet18".
- **Datasets**: Files with different dataset name represents experiments on different datasets, such as "femnist" or "cifar10".
- **pFL Methods**: Files with different method name represents experiments with using different pFL methods.
- **IID vs Non-IID**: Files with 'iid' represents experiments under IID settings.
- **Ablation Study**: Files with 'abl' represents ablation studies of pFL methods conducted in Section 5.
- **FedBN**: Files with 'bn' and 'para' or 'sta' mean experiments of Fed-para and Fed-sta conducted in Section 5.1.
- **Existing Defense**: Experiments about existing defense methods:
* Krum: please set attack.krum: True
* Multi-Krum: please set attack.multi_krum: True
* Norm_clip: please set attack.norm_clip: True and tune attack.norm_clip_value.
* Adding noise: please tune attack.dp_noise.

**Notice:** The Files with 'small' or 'avg' are about experiments with changing attackers since we wish to test whether the size of the local dataset possessed by the attacker will have an impact on the success of the backdoor poisoning. You can ignore them.

----

## Explanations about Attack Config


attack:
setting: 'fix' --fix-frequency attack setting
freq: 10 --the adversarial client is selected for every fixed 10 round.
attack_method: 'backdoor'
attacker_id: 15 --the client id of attacker
label_type: 'dirty' --dirty or clean-label attacks. We now only support dirty-label attacks
trigger_type: gridTrigger --BadNet: gridTrigger; Blended: hkTrigger; edge: edge; SIG: sigTrigger
edge_num: 500 --the number of samples with edge trigger
poison_ratio: 0.5 --poisoning ratio of local training dataset
target_label_ind: 9 --target label of backdoor attacks
self_opt: False --you can ignore it since we do not test it.
self_lr: 0.1 --you can ignore it since we do not test it.
self_epoch: 6 --you can ignore it since we do not test it.
scale_poisoning: False --you can ignore it since we do not test it.
scale_para: 3.0 --you can ignore it since we do not test it.
pgd_poisoning: False --you can ignore it since we do not test it.
mean: [0.4914, 0.4822, 0.4465] --normalizations used in backdoor attacks (different dataset have different settings.)
std: [0.2023, 0.1994, 0.2010]



2 changes: 1 addition & 1 deletion benchmark/FedHPOBench/fedhpobench/utils/cost_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def raw_cost(**kwargs):

def get_info(cfg, configuration, fidelity, data):
cfg = merge_cfg(cfg, configuration, fidelity)
model = get_model(cfg.model, list(data.values())[0])
model = get_model(cfg, list(data.values())[0])
model_size = sum([param.nelement() for param in model.parameters()])
return cfg, model_size

Expand Down
22 changes: 21 additions & 1 deletion benchmark/pFL-Bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
The **pFL-Bench** is a comprehensive benchmark for personalized Federated Learning (pFL), which contains more than 10 diverse datasets, 20 competitive pFL baselines, and systematic evaluation with highlighted benefits and potential of pFL. See more details in our [paper](https://arxiv.org/abs/2206.03655).


This repository includes the experimental data, environments, scripts and codes of **pFL-Bench**. We welcome contributions of new pFL methods and datasets to keep pFL-Bench up-to-date and to evolve it! See more details about contribution [here](https://github.com/alibaba/FederatedScope#contributing).
This repository mainly includes the experimental data, environments, scripts and codes of **pFL-Bench**. We welcome contributions of new pFL methods and datasets to keep pFL-Bench up-to-date and to evolve it! See more details about contribution [here](https://github.com/alibaba/FederatedScope#contributing).
Recently, our new proposed method for efficient pFL, [pFedGate](https://arxiv.org/abs/2305.02776) has been accepted to ICML'23. We provide its initial implementation [here](https://github.com/yxdyc/pFedGate) and will add it and more efficient pFL methods into our benchmark.

**NOTICE:** We are working on seamlessly and consistently fusing the new features in pFL-Bench into the *FederatedScope*. However, since the underling package *FederatedScope* is still being continuously and actively updated, the results can be a little different to the ones in our paper.
To fully reproduce the experimental results reported in the paper, please use the code versioned by this [branch](https://github.com/alibaba/FederatedScope/tree/Feature/pfl_bench) on which the experiments were conducted at the time.
Expand Down Expand Up @@ -111,3 +112,22 @@ wandb login --host=http://xx.xx.xx.xx:8080/
```

3. connect the machine and develop your pFL algorithm


# License
Our codes were released with Apache-2.0 License. Please kindly cite our papers (and the respective papers of the methods used) if our work is useful for you:
```
@inproceedings{chen2022pflbench,
title={p{FL}-Bench: A Comprehensive Benchmark for Personalized Federated Learning},
author={Daoyuan Chen and Dawei Gao and Weirui Kuang and Yaliang Li and Bolin Ding},
booktitle={Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
year={2022},
}

@inproceedings{chen2023pFedGate,
title={Efficient Personalized Federated Learning via Sparse Model-Adaptation},
author={Daoyuan Chen and Liuyi Yao and Dawei Gao and Bolin Ding and Yaliang Li},
booktitle={International Conference on Machine Learning},
year={2023},
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use_gpu: True
device: 0
expname_tag: "ds_1c_200r_30ls_dist"
early_stop:
patience: 0
federate:
mode: "distributed"
client_num: 1
total_round_num: 200
save_to: "models/distributed/Phi-3-mini-128k-instruct/ds_1c_200r_30ls.ckpt"
make_global_eval: False
data:
root: data/
type: 'alpaca@llm'
splits: [0.98,0.01,0.01]
splitter: 'iid'
distribute:
use: True
server_host: '192.168.24.120'
server_port: 11004
client_host: '192.168.24.115'
client_port: 50052
role: 'client'
data_idx: 1
grpc_max_send_message_length: 1048576000
grpc_max_receive_message_length: 1048576000
llm:
tok_len: 1000
chat:
max_len: 2000
adapter:
use: True
args: [ { 'adapter_package': 'peft', 'adapter_method': 'lora', 'r': 8, 'lora_alpha': 16, 'lora_dropout': 0.05, 'target_modules': [ "q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj", "lm_head" ] } ]
deepspeed:
use: True
ds_config: 'federatedscope/llm/baseline/deepspeed/ds_config_4bs.json'
dataloader:
batch_size: 1
model:
type: 'microsoft/Phi-3-mini-128k-instruct@huggingface_llm'
train:
local_update_steps: 30
batch_or_epoch: batch
optimizer:
lr: 0.0003
weight_decay: 0.0
criterion:
type: CrossEntropyLoss
trainer:
type: llmtrainer
eval:
freq: 50
metrics: ['loss']
Loading