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

[Feature] Refactor FedRunner, optimize trainer module and optimize CI #415

Merged
merged 22 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CodeQL (Code Scanning)

on:
pull_request:
branches: [ "master" ]
schedule:
- cron: '0 8 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
3 changes: 2 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: pre-commit
name: Pre-commit (Required)

on: [push, pull_request]

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: True
matrix:
os: [ubuntu-latest]
env:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/test_distribute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: UnitTests for Distributed Mode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very appreciate for the work on providing unit test for distributed mode


on: [push, pull_request]

jobs:
run:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.9']
torch-version: ['1.10.1']
torchvision-version: ['0.11.2']
torchaudio-version: ['0.10.1']
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 .[test]
- name: Test Distributed (LR on toy)
run: |
python scripts/distributed_scripts/gen_data.py
python federatedscope/main.py --cfg scripts/distributed_scripts/distributed_configs/distributed_server.yaml &
sleep 2
python federatedscope/main.py --cfg scripts/distributed_scripts/distributed_configs/distributed_client_1.yaml &
sleep 2
python federatedscope/main.py --cfg scripts/distributed_scripts/distributed_configs/distributed_client_2.yaml &
sleep 2
python federatedscope/main.py --cfg scripts/distributed_scripts/distributed_configs/distributed_client_3.yaml
[ $? -eq 1 ] && exit 1 || echo "Passed"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ conda activate fs
If your backend is torch, please install torch in advance ([torch-get-started](https://pytorch.org/get-started/locally/)). For example, if your cuda version is 11.3 please execute the following command:

```bash
conda install -y pytorch=1.10.1 torchvision=0.11.2 torchaudio=0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge
conda install -y pytorch=1.10.1 torchvision=0.11.2 torchaudio=0.10.1 torchtext=0.11.1 cudatoolkit=11.3 -c pytorch -c conda-forge
```

For users with Apple M1 chips:
Expand Down
6 changes: 4 additions & 2 deletions doc/source/attack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@ federatedscope.attack.privacy_attacks

.. automodule:: federatedscope.attack.privacy_attacks
:members:
:private-members:


federatedscope.attack.worker_as_attacker
-------------------------------------------

.. automodule:: federatedscope.attack.worker_as_attacker
:members:
:private-members:

federatedscope.attack.auxiliary
--------------------------------

.. automodule:: federatedscope.attack.auxiliary
:members:


:private-members:

federatedscope.attack.trainer
---------------------------------

.. automodule:: federatedscope.attack.trainer
:members:
:private-members:



Expand Down
23 changes: 23 additions & 0 deletions doc/source/autotune.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,33 @@ federatedscope.autotune.choice_types

.. automodule:: federatedscope.autotune.choice_types
:members:
:private-members:

federatedscope.autotune.algos
-----------------------

.. automodule:: federatedscope.autotune.algos
:show-inheritance:
:members:
:private-members:

federatedscope.autotune.hpbandster
-----------------------

.. automodule:: federatedscope.autotune.hpbandster
:members:
:private-members:

federatedscope.autotune.smac
-----------------------

.. automodule:: federatedscope.autotune.smac
:members:
:private-members:

federatedscope.autotune.utils
-----------------------

.. automodule:: federatedscope.autotune.utils
:members:
:private-members:
78 changes: 68 additions & 10 deletions doc/source/core.rst
Original file line number Diff line number Diff line change
@@ -1,33 +1,91 @@
Core Module References
=======================

federatedscope.core.configs
federatedscope.core.fed_runner
-----------------------

.. automodule:: federatedscope.core.configs
.. automodule:: federatedscope.core.fed_runner
:members:
:private-members:

federatedscope.core.workers
-----------------------

federatedscope.core.monitors
.. automodule:: federatedscope.core.workers
:members:
:private-members:

federatedscope.core.trainers
-----------------------

.. automodule:: federatedscope.core.monitors
.. automodule:: federatedscope.core.trainers
:members:
:private-members:

federatedscope.core.fed_runner
federatedscope.core.data
-----------------------

.. automodule:: federatedscope.core.fed_runner
.. automodule:: federatedscope.core.data.base_data
:members:
:private-members:
.. automodule:: federatedscope.core.data.base_translator
:members:
:private-members:
.. automodule:: federatedscope.core.data.dummy_translator
:members:
:private-members:
.. automodule:: federatedscope.core.data.utils
:members:

federatedscope.core.worker
federatedscope.core.splitters
-----------------------
.. automodule:: federatedscope.core.splitters
:members:
:private-members:
.. automodule:: federatedscope.core.splitters.generic
:members:
:private-members:
.. automodule:: federatedscope.core.splitters.graph
:members:
:private-members:

.. automodule:: federatedscope.core.worker
federatedscope.core.configs
-----------------------

.. automodule:: federatedscope.core.configs
:members:
:private-members:

federatedscope.core.trainers

federatedscope.core.monitors
-----------------------

.. automodule:: federatedscope.core.trainers
.. automodule:: federatedscope.core.monitors
:members:
:private-members:

federatedscope.core.aggregators
-----------------------

.. automodule:: federatedscope.core.aggregators
:members:

federatedscope.core.auxiliaries
-----------------------

.. autofunction:: federatedscope.core.auxiliaries.aggregator_builder.get_aggregator()
.. autofunction:: federatedscope.core.auxiliaries.criterion_builder.get_criterion()
.. autofunction:: federatedscope.core.auxiliaries.data_builder.get_data()
.. autofunction:: federatedscope.core.auxiliaries.dataloader_builder.get_dataloader()
.. autofunction:: federatedscope.core.auxiliaries.metric_builder.get_metric()
.. autofunction:: federatedscope.core.auxiliaries.model_builder.get_model()
.. autofunction:: federatedscope.core.auxiliaries.optimizer_builder.get_optimizer()
.. autofunction:: federatedscope.core.auxiliaries.regularizer_builder.get_regularizer()
.. autofunction:: federatedscope.core.auxiliaries.runner_builder.get_runner()
.. autofunction:: federatedscope.core.auxiliaries.sampler_builder.get_sampler()
.. autofunction:: federatedscope.core.auxiliaries.scheduler_builder.get_scheduler()
.. autofunction:: federatedscope.core.auxiliaries.splitter_builder.get_splitter()
.. autofunction:: federatedscope.core.auxiliaries.trainer_builder.get_trainer()
.. autofunction:: federatedscope.core.auxiliaries.transform_builder.get_transform()
.. autofunction:: federatedscope.core.auxiliaries.worker_builder.get_client_cls()
.. autofunction:: federatedscope.core.auxiliaries.worker_builder.get_server_cls()
10 changes: 9 additions & 1 deletion doc/source/cv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@ Federated Computer Vision Module References
federatedscope.cv.dataset
-----------------------

.. automodule:: federatedscope.cv.dataset
.. automodule:: federatedscope.cv.dataset.leaf
:members:
:private-members:

.. automodule:: federatedscope.cv.dataset.leaf_cv
:members:
:private-members:

federatedscope.cv.dataloader
-----------------------

.. automodule:: federatedscope.cv.dataloader
:members:
:private-members:

federatedscope.cv.model
-----------------------

.. automodule:: federatedscope.cv.model
:members:
:private-members:

federatedscope.cv.trainer
-----------------------

.. automodule:: federatedscope.cv.trainer
:members:
:private-members:
4 changes: 4 additions & 0 deletions doc/source/gfl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ federatedscope.gfl.dataset

.. automodule:: federatedscope.gfl.dataset
:members:
:private-members:

federatedscope.gfl.dataloader
-----------------------

.. automodule:: federatedscope.gfl.dataloader
:members:
:private-members:

federatedscope.gfl.model
-----------------------

.. automodule:: federatedscope.gfl.model
:members:
:private-members:

federatedscope.gfl.trainer
-----------------------

.. automodule:: federatedscope.gfl.trainer
:members:
:private-members:
4 changes: 4 additions & 0 deletions doc/source/mf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ federatedscope.mf.dataset

.. automodule:: federatedscope.mf.dataset
:members:
:private-members:

federatedscope.mf.model
-----------------------

.. automodule:: federatedscope.mf.model
:members:
:private-members:

federatedscope.mf.dataloader
-----------------------

.. automodule:: federatedscope.mf.dataloader
:members:
:private-members:

federatedscope.mf.trainer
-----------------------

.. automodule:: federatedscope.mf.trainer
:members:
:private-members:
4 changes: 4 additions & 0 deletions doc/source/nlp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ federatedscope.nlp.dataset

.. automodule:: federatedscope.nlp.dataset
:members:
:private-members:

federatedscope.nlp.dataloader
-----------------------

.. automodule:: federatedscope.nlp.dataloader
:members:
:private-members:

federatedscope.nlp.model
-----------------------

.. automodule:: federatedscope.nlp.model
:members:
:private-members:

federatedscope.nlp.trainer
-----------------------

.. automodule:: federatedscope.nlp.trainer
:members:
:private-members:
1 change: 0 additions & 1 deletion environment/extra_dependencies_torch1.10-application.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ conda install -y nltk
# Speech and NLP
conda install -y sentencepiece textgrid typeguard -c conda-forge
conda install -y transformers==4.16.2 tokenizers==0.10.3 datasets -c huggingface -c conda-forge
conda install -y torchtext -c pytorch

# Tabular
conda install -y openml==0.12.2
Loading