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

Vr #32

Closed
wants to merge 2 commits into from
Closed

Vr #32

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
148 changes: 148 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
examples/leaf/
examples/runs/
cifar10/

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
30 changes: 30 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How to run this code
## Setup
```
python3 -m venv venv
source venv/bin/activate
cd ~/FLSim
pip install -e .
```

## Data Processing
In examples/get_data.sh, change line 8 to alter the dataset size. Currently, it's set to download and preprocess femnist.

For example,
./preprocess.sh -s niid --sf 1.0 -k 0 -t sample (full-sized dataset)
./preprocess.sh -s niid --sf 0.05 -k 0 -t sample (small-sized dataset)
Make sure to delete the rem_user_data, sampled_data, test, and train subfolders in the data directory before re-running preprocess.sh

For more info about the options, see (LEAF)[https://github.com/TalwalkarLab/leaf/tree/master/data/femnist]

then run
```
sh get_data.sh
```

## Run
CIFAR-10

```
python3 cifar10_example.py --config-file configs/cifar10_sarah.json
```
42 changes: 42 additions & 0 deletions examples/configs/cifar10_sarah.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"config": {
"trainer": {
"_base_": "base_sync_trainer",
"epochs": 1,
"server": {
"_base_": "base_sarah_server",
"server_optimizer": {
"_base_": "base_fed_avg_with_lr",
"lr": 2.13,
"momentum": 0.9
},
"active_user_selector": {
"_base_": "base_uniformly_random_active_user_selector"
},
"large_cohort_period": 100,
"large_cohort_clients": 1000
},
"client": {
"_base_": "base_sarah_client",
"epochs": 1,
"optimizer": {
"_base_": "base_optimizer_sgd",
"lr": 0.0138,
"momentum": 0
},
"large_cohort_period": 100
},
"users_per_round": 10,
"train_metrics_reported_per_epoch": 1,
"always_keep_trained_model": false,
"report_train_metrics": true,
"eval_epoch_frequency": 1,
"do_eval": true,
"report_train_metrics_after_aggregation": true
},
"data": {
"local_batch_size": 32,
"examples_per_user": 500
}
}
}
Empty file.
4 changes: 2 additions & 2 deletions examples/get_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
git clone https://github.com/TalwalkarLab/leaf.git
cd leaf/data/sent140 || exit
./preprocess.sh --sf 0.01 -s niid -t 'user' --tf 0.90 -k 1 --spltseed 1
cd leaf/data/femnist || exit
./preprocess.sh --sf 0.1 -s niid -t 'user' --tf 0.90 -k 1 --spltseed 1
8 changes: 7 additions & 1 deletion flsim/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .base_client import ClientConfig
from .dp_client import DPClientConfig

from .sarah_client import SarahClientConfig

ConfigStore.instance().store(
name="base_client",
Expand All @@ -21,3 +21,9 @@
node=DPClientConfig,
group="client",
)

ConfigStore.instance().store(
name="base_sarah_client",
node=SarahClientConfig,
group="client",
)