Skip to content

Commit

Permalink
Cleanup (#1422)
Browse files Browse the repository at this point in the history
* DCE, rename variable

Signed-off-by: Shah, Karan <[email protected]>

* Move to module-level loggers

Signed-off-by: Shah, Karan <[email protected]>

* Plan.logger to logger

Signed-off-by: Shah, Karan <[email protected]>

* Fixup

Signed-off-by: Shah, Karan <[email protected]>

* Also for workspaces

Signed-off-by: Shah, Karan <[email protected]>

* Fix again for logger

Signed-off-by: Shah, Karan <[email protected]>

* Remove run_simulation tests

Signed-off-by: Shah, Karan <[email protected]>

* Header creation is stateless and common across both

Signed-off-by: Shah, Karan <[email protected]>

* Remove TASK_REGISTRY code; deprecated with interactive

Signed-off-by: Shah, Karan <[email protected]>

* More use_delta_updates changes

Signed-off-by: Shah, Karan <[email protected]>

* lets see if this revert works

Signed-off-by: Shah, Karan <[email protected]>

* Remove openfl install in notebook

Signed-off-by: Shah, Karan <[email protected]>

* revert few flags

Signed-off-by: Shah, Karan <[email protected]>

* please please please this should work

Signed-off-by: Shah, Karan <[email protected]>

* Migrate stateless function to common

Signed-off-by: Shah, Karan <[email protected]>

* Cleanup outdated docstrings

Signed-off-by: Shah, Karan <[email protected]>

* Remove Interactive API RPCs

Signed-off-by: Shah, Karan <[email protected]>

* Remove set devices call; not used anywhere

Signed-off-by: Shah, Karan <[email protected]>

* Replace checks with inline assertions

Signed-off-by: Shah, Karan <[email protected]>

* Unfold one-liner functions

Signed-off-by: Shah, Karan <[email protected]>

* Remove moot tests

Signed-off-by: Shah, Karan <[email protected]>

---------

Signed-off-by: Shah, Karan <[email protected]>
  • Loading branch information
MasterSkepticista authored Mar 7, 2025
1 parent d5838e1 commit 1c3aaba
Show file tree
Hide file tree
Showing 47 changed files with 463 additions and 846 deletions.
2 changes: 1 addition & 1 deletion docs/about/features_index/secure_aggregation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following plan shows secure aggregation being enabled on `keras/mnist <https
collaborator:
settings:
db_store_rounds: 1
delta_updates: false
use_delta_updates: false
opt_treatment: RESET
template: openfl.component.Collaborator
compression_pipeline:
Expand Down
2 changes: 1 addition & 1 deletion docs/about/features_index/taskrunner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Configurable Settings
`openfl.component.Collaborator <https://github.com/intel/openfl/blob/develop/openfl/component/collaborator/collaborator.py>`_
Defines the settings for the collaborator which is the data owner in the experiment. The settings for collaborator include:

- :code:`delta_updates`: (boolean) Determines whether the difference in model weights between the current and previous round will be sent (True), or if whole checkpoints will be sent (False). Setting to delta_updates to True leads to higher sparsity in model weights sent across, which may improve compression ratios.
- :code:`use_delta_updates`: (boolean) Determines whether the difference in model weights between the current and previous round will be sent (True), or if whole checkpoints will be sent (False). Setting to use_delta_updates to True leads to higher sparsity in model weights sent across, which may improve compression ratios.
- :code:`opt_treatment`: (str) Defines the optimizer state treatment policy. Valid options are : 'RESET' - reinitialize optimizer for every round (default), 'CONTINUE_LOCAL' - keep local optimizer state for every round, 'CONTINUE_GLOBAL' - aggregate optimizer state for every round.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install git+https://github.com/securefederatedai/openfl.git\n",
"!pip install -r workflow_interface_requirements.txt\n",
"!pip install torch\n",
"!pip install torchvision\n",
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/gandlf_seg_test/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/keras/2dunet/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : true
use_delta_updates : true
opt_treatment : RESET

data_loader :
Expand Down
4 changes: 3 additions & 1 deletion openfl-workspace/keras/2dunet/src/taskrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from openfl.federated import KerasTaskRunner

import logging
logger = logging.getLogger(__name__)

class Keras2DUNet(KerasTaskRunner):
"""Initialize.
Expand All @@ -27,7 +29,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

self.model = self.build_model(self.data_loader.get_feature_shape(), use_upsampling=True, **kwargs)
self.model.summary(print_fn=self.logger.info, line_length=120)
self.model.summary(print_fn=logger.info, line_length=120)
self.initialize_tensorkeys_for_functions()


Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/keras/jax/mnist/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
9 changes: 6 additions & 3 deletions openfl-workspace/keras/jax/mnist/src/taskrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from .model import CNNModel
from openfl.federated import KerasTaskRunner

import logging
logger = logging.getLogger(__name__)

class JAXCNN(KerasTaskRunner):
"""A basic convolutional neural network model."""

Expand All @@ -24,10 +27,10 @@ def __init__(self, **kwargs):

self.initialize_tensorkeys_for_functions()

self.model.summary(print_fn=self.logger.info)
self.model.summary(print_fn=logger.info)

self.logger.info(f'Train Set Size : {self.get_train_data_size()}')
self.logger.info(f'Valid Set Size : {self.get_valid_data_size()}')
logger.info(f'Train Set Size : {self.get_train_data_size()}')
logger.info(f'Valid Set Size : {self.get_valid_data_size()}')

def build_model(self,
input_shape,
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/keras/mnist/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
8 changes: 5 additions & 3 deletions openfl-workspace/keras/mnist/src/taskrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from openfl.federated import KerasTaskRunner

import logging
logger = logging.getLogger(__name__)

class KerasCNN(KerasTaskRunner):
"""A basic convolutional neural network model."""
Expand All @@ -27,10 +29,10 @@ def __init__(self, **kwargs):

self.initialize_tensorkeys_for_functions()

self.model.summary(print_fn=self.logger.info)
self.model.summary(print_fn=logger.info)

self.logger.info(f'Train Set Size : {self.get_train_data_size()}')
self.logger.info(f'Valid Set Size : {self.get_valid_data_size()}')
logger.info(f'Train Set Size : {self.get_train_data_size()}')
logger.info(f'Valid Set Size : {self.get_valid_data_size()}')

def build_model(self,
input_shape,
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/keras/tensorflow/mnist/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
9 changes: 6 additions & 3 deletions openfl-workspace/keras/tensorflow/mnist/src/taskrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from .model import CNNModel
from openfl.federated import KerasTaskRunner

import logging
logger = logging.getLogger(__name__)

class CNNTaskruner(KerasTaskRunner):
"""A basic convolutional neural network model."""

Expand Down Expand Up @@ -35,10 +38,10 @@ def __init__(self, **kwargs):

self.initialize_tensorkeys_for_functions()

self.model.summary(print_fn=self.logger.info)
self.model.summary(print_fn=logger.info)

self.logger.info(f'Train Set Size : {self.get_train_data_size()}')
self.logger.info(f'Valid Set Size : {self.get_valid_data_size()}')
logger.info(f'Train Set Size : {self.get_train_data_size()}')
logger.info(f'Valid Set Size : {self.get_valid_data_size()}')

def build_model(self,
input_shape,
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/keras/torch/mnist/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
10 changes: 7 additions & 3 deletions openfl-workspace/keras/torch/mnist/src/taskrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

from .model import CNNModel
from openfl.federated import KerasTaskRunner

import logging
logger = logging.getLogger(__name__)

class KerasCNN(KerasTaskRunner):
"""A basic convolutional neural network model."""

Expand All @@ -23,10 +27,10 @@ def __init__(self, **kwargs):

self.initialize_tensorkeys_for_functions()

self.model.summary(print_fn=self.logger.info)
self.model.summary(print_fn=logger.info)

self.logger.info(f'Train Set Size : {self.get_train_data_size()}')
self.logger.info(f'Valid Set Size : {self.get_valid_data_size()}')
logger.info(f'Train Set Size : {self.get_train_data_size()}')
logger.info(f'Valid Set Size : {self.get_valid_data_size()}')

def build_model(self,
input_shape,
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/torch/histology/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/torch/histology_fedcurv/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/torch/mnist/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ assigner :
collaborator:
settings:
db_store_rounds: 1
delta_updates: false
use_delta_updates: false
opt_treatment: RESET
template: openfl.component.collaborator.Collaborator
compression_pipeline:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/torch/mnist_fed_eval/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/torch/template/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.collaborator.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
2 changes: 1 addition & 1 deletion openfl-workspace/workspace/plan/defaults/collaborator.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
template : openfl.component.Collaborator
settings :
opt_treatment : 'CONTINUE_LOCAL'
delta_updates : True
use_delta_updates : True
db_store_rounds : 1
2 changes: 1 addition & 1 deletion openfl-workspace/xgb_higgs/plan/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ collaborator :
defaults : plan/defaults/collaborator.yaml
template : openfl.component.collaborator.Collaborator
settings :
delta_updates : false
use_delta_updates : false
opt_treatment : RESET

data_loader :
Expand Down
Loading

0 comments on commit 1c3aaba

Please sign in to comment.