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

Periodic update #119

Merged
merged 20 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1f5a10e
chore(deps): update ray[default] requirement in /.env
dependabot[bot] Oct 27, 2024
a2e75ab
chore(deps): bump pandas from 2.2.2 to 2.2.3 in /.env
dependabot[bot] Oct 27, 2024
5b55f28
Merge pull request #115 from KarhouTam/dependabot/pip/dot-env/dev/pan…
KarhouTam Oct 27, 2024
4f71e5e
Merge pull request #112 from KarhouTam/dependabot/pip/dot-env/dev/ray…
KarhouTam Oct 27, 2024
337a089
chore(deps): bump faiss-cpu from 1.7.4 to 1.8.0.post1 in /.env
dependabot[bot] Oct 27, 2024
6d5b38f
Merge pull request #113 from KarhouTam/dependabot/pip/dot-env/dev/fai…
KarhouTam Oct 27, 2024
43862cd
chore(deps): bump scipy from 1.13.1 to 1.14.1 in /.env
dependabot[bot] Oct 27, 2024
323b1f4
Merge pull request #114 from KarhouTam/dependabot/pip/dot-env/dev/sci…
KarhouTam Oct 27, 2024
323093d
chore(deps): bump pillow from 10.3.0 to 10.4.0 in /.env
dependabot[bot] Oct 28, 2024
2e8f7d0
Merge pull request #118 from KarhouTam/dependabot/pip/dot-env/dev/pil…
KarhouTam Oct 28, 2024
db30d9d
chore(deps): bump pynvml from 11.5.0 to 11.5.3 in /.env
dependabot[bot] Oct 28, 2024
3c88f8c
Merge pull request #116 from KarhouTam/dependabot/pip/dot-env/dev/pyn…
KarhouTam Oct 28, 2024
1cc71ae
chore(deps): bump pyyaml from 6.0.1 to 6.0.2 in /.env
dependabot[bot] Oct 28, 2024
e9d1576
Merge pull request #117 from KarhouTam/dependabot/pip/dot-env/dev/pyy…
KarhouTam Oct 28, 2024
35a6390
Merge pull request #111 from KarhouTam/dev
KarhouTam Oct 29, 2024
72053df
Merge branch 'master' into dev
KarhouTam Oct 31, 2024
a67631d
refactor(framework): Rename `visible` to `monitor`
KarhouTam Nov 2, 2024
5dbb805
perf(framework): Improve output & logging readability
KarhouTam Nov 5, 2024
aa68921
refactor(framework): `isort` refactor
KarhouTam Nov 5, 2024
d842803
Merge remote-tracking branch 'origin/master' into dev
KarhouTam Nov 7, 2024
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
249 changes: 132 additions & 117 deletions .env/poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions .env/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ numpy = "1.26.4"
pandas = "^2.2.3"
visdom = "^0.2.4"
Pillow = "^10.4.0"
scipy = "^1.13.1"
scipy = "^1.14.1"
matplotlib = "^3.9.0"
scikit-learn = "^1.5.2"
faiss-cpu = "^1.7.4"
pynvml = "^11.5.0"
PyYAML = "^6.0.1"
faiss-cpu = "^1.8.0"
pynvml = "^11.5.3"
PyYAML = "^6.0.2"
ray = { extras = ["default"], version = "2.36.1" }
tensorboard = "^2.17.1"
cvxpy = "^1.5.1"
Expand Down
2 changes: 1 addition & 1 deletion .env/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ faiss-cpu~=1.7.4
scikit-learn~=1.5.2
pynvml~=11.5.0
PyYAML~=6.0.1
ray[default]~=2.36.1
ray[default]~=2.38.0
tensorboard~=2.17.1
cvxpy~=1.5.1
hydra-core~=1.3.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ FL-bench supports `visdom` and `tensorboard`.
# your_config.yaml
common:
...
visible: tensorboard # options: [null, visdom, tensorboard]
monitor: tensorboard # options: [null, visdom, tensorboard]
```
> \[!NOTE\]
> You needs to launch `visdom` / `tensorboard` server by yourself.
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ common:
eval_train: false

verbose_gap: 10 # Interval round of displaying clients training performance on terminal.
visible: null # [null, visdom, tensorboard]
monitor: null # [null, visdom, tensorboard]
use_cuda: true # Whether to use cuda for training.

save_log: true # Whether to save log files in out/<method>/<start_time>.
Expand Down
32 changes: 20 additions & 12 deletions src/server/fedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pickle
import random
import shutil
import traceback
import time
import traceback
import warnings
from collections import OrderedDict
from copy import deepcopy
Expand All @@ -19,7 +19,7 @@
from hydra.core.hydra_config import HydraConfig
from omegaconf import DictConfig, OmegaConf
from rich.console import Console
from rich.json import JSON
from rich.pretty import pprint as rich_pprint
from rich.progress import track
from torchvision import transforms

Expand Down Expand Up @@ -199,16 +199,16 @@ def __init__(
console=stdout,
)

if self.args.common.visible is not None:
if self.args.common.monitor is not None:
self.monitor_window_name_suffix = (
self.args.dataset.monitor_window_name_suffix
)

if self.args.common.visible == "visdom":
if self.args.common.monitor == "visdom":
from visdom import Visdom

self.viz = Visdom()
elif self.args.common.visible == "tensorboard":
elif self.args.common.monitor == "tensorboard":
from torch.utils.tensorboard import SummaryWriter

self.tensorboard = SummaryWriter(log_dir=self.output_dir)
Expand Down Expand Up @@ -613,7 +613,7 @@ def log_info(self):

self.global_metrics[stage][split].append(global_metrics)

if self.args.common.visible == "visdom":
if self.args.common.monitor == "visdom":
self.viz.line(
[global_metrics.accuracy],
[self.current_epoch],
Expand All @@ -627,7 +627,7 @@ def log_info(self):
legend=[self.algorithm_name],
),
)
elif self.args.common.visible == "tensorboard":
elif self.args.common.monitor == "tensorboard":
self.tensorboard.add_scalar(
f"Accuracy-{self.monitor_window_name_suffix}/{split}set-{stage}LocalTraining",
global_metrics.accuracy,
Expand Down Expand Up @@ -688,13 +688,21 @@ def run(self):
"""
self.logger.log("=" * 20, self.algorithm_name, "=" * 20)
self.logger.log("Experiment Arguments:")
self.logger.log(JSON(json.dumps(OmegaConf.to_object(self.args))))
if self.args.common.visible == "tensorboard":
rich_pprint(
OmegaConf.to_object(self.args), console=self.logger.stdout, expand_all=True
)
if self.args.common.save_log:
rich_pprint(
OmegaConf.to_object(self.args),
console=self.logger.logfile_logger,
expand_all=True,
)
if self.args.common.monitor == "tensorboard":
self.tensorboard.add_text(
f"ExperimentalArguments-{self.monitor_window_name_suffix}",
f"<pre>{self.args}</pre>",
f"{json.dumps(OmegaConf.to_object(self.args), indent=4)}",
)

begin = time.time()
try:
self.train()
Expand Down Expand Up @@ -745,7 +753,7 @@ def run(self):
}

self.logger.log(json.dumps(all_test_results, indent=4))
if self.args.common.visible == "tensorboard":
if self.args.common.monitor == "tensorboard":
for epoch, results in all_test_results.items():
self.tensorboard.add_text(
f"Results-{self.monitor_window_name_suffix}",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MODE(Enum):
"eval_val": False,
"eval_train": False,
"verbose_gap": 10,
"visible": None,
"monitor": None,
"use_cuda": True,
"save_log": True,
"save_model": False,
Expand Down