-
Notifications
You must be signed in to change notification settings - Fork 35
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
Make choice of aggregator dynamic at session level and additional aggregators (FedOpt) #498
Changes from 1 commit
357198a
f59e0bf
fa791cf
7a20a6b
9aaf22e
8cceef3
353dcf4
e01eb8e
be80527
846fafa
be5051b
e8238b0
94f23c4
a88e557
9e5ad43
5868624
d214884
6583fc6
dc9502b
3df3036
21f8065
6e0611b
d16f671
33742e4
29212a6
6a8396d
db1eb74
f000351
d6049ea
a35d1fe
847d6ba
bd3c411
5a80fcf
f70a7d5
b1b57ae
109b62e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,18 +19,18 @@ class AggregatorBase(ABC): | |
:type server: class: `fedn.network.combiner.Combiner` | ||
:param modelservice: A handle to the model service :class: `fedn.network.combiner.modelservice.ModelService` | ||
:type modelservice: class: `fedn.network.combiner.modelservice.ModelService` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundController` | ||
:type control: class: `fedn.network.combiner.round.RoundController` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundHandler` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. roundhelper |
||
:type control: class: `fedn.network.combiner.round.RoundHandler` | ||
""" | ||
|
||
@abstractmethod | ||
def __init__(self, storage, server, modelservice, control): | ||
def __init__(self, storage, server, modelservice, round_handler): | ||
""" Initialize the aggregator.""" | ||
self.name = self.__class__.__name__ | ||
self.storage = storage | ||
self.server = server | ||
self.modelservice = modelservice | ||
self.control = control | ||
self.round_handler = round_handler | ||
self.model_updates = queue.Queue() | ||
|
||
@abstractmethod | ||
|
@@ -58,7 +58,7 @@ def on_model_update(self, model_update): | |
and then puts the update id on the aggregation queue. | ||
Override in subclass as needed. | ||
|
||
:param model_update: A ModelUpdate message. | ||
:param model_update: fedn.network.grpc.fedn.proto.ModelUpdate | ||
:type model_id: str | ||
""" | ||
try: | ||
|
@@ -114,7 +114,7 @@ def load_model_update(self, model_update, helper): | |
:rtype: tuple | ||
""" | ||
model_id = model_update.model_update_id | ||
model = self.control.load_model_update(helper, model_id) | ||
model = self.round_handler.load_model_update(helper, model_id) | ||
# Get relevant metadata | ||
data = json.loads(model_update.meta)['training_metadata'] | ||
config = json.loads(json.loads(model_update.meta)['config']) | ||
|
@@ -141,8 +141,8 @@ def get_aggregator(aggregator_module_name, storage, server, modelservice, contro | |
:type server: class: `fedn.network.combiner.Combiner` | ||
:param modelservice: A handle to the model service :class: `fedn.network.combiner.modelservice.ModelService` | ||
:type modelservice: class: `fedn.network.combiner.modelservice.ModelService` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundController` | ||
:type control: class: `fedn.network.combiner.round.RoundController` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundHandler` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. roundhelper |
||
:type control: class: `fedn.network.combiner.round.RoundHandler` | ||
:return: An aggregator instance. | ||
:rtype: class: `fedn.combiner.aggregators.AggregatorBase` | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,15 @@ class Aggregator(AggregatorBase): | |
:type server: class: `fedn.network.combiner.Combiner` | ||
:param modelservice: A handle to the model service :class: `fedn.network.combiner.modelservice.ModelService` | ||
:type modelservice: class: `fedn.network.combiner.modelservice.ModelService` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundController` | ||
:type control: class: `fedn.network.combiner.round.RoundController` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundHandler` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. roundhelper |
||
:type control: class: `fedn.network.combiner.round.RoundHandler` | ||
|
||
""" | ||
|
||
def __init__(self, storage, server, modelservice, control): | ||
def __init__(self, storage, server, modelservice, round_handler): | ||
"""Constructor method""" | ||
|
||
super().__init__(storage, server, modelservice, control) | ||
super().__init__(storage, server, modelservice, round_handler) | ||
|
||
self.name = "fedavg" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,14 @@ class Aggregator(AggregatorBase): | |
:type server: class: `fedn.network.combiner.Combiner` | ||
:param modelservice: A handle to the model service :class: `fedn.network.combiner.modelservice.ModelService` | ||
:type modelservice: class: `fedn.network.combiner.modelservice.ModelService` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundController` | ||
:type control: class: `fedn.network.combiner.round.RoundController` | ||
:param control: A handle to the :class: `fedn.network.combiner.round.RoundHandler` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. roundhelper |
||
:type control: class: `fedn.network.combiner.round.RoundHandler` | ||
|
||
""" | ||
|
||
def __init__(self, storage, server, modelservice, control): | ||
def __init__(self, storage, server, modelservice, round_handler): | ||
|
||
super().__init__(storage, server, modelservice, control) | ||
super().__init__(storage, server, modelservice, round_handler) | ||
|
||
self.name = "fedopt" | ||
self.v = None | ||
|
@@ -81,7 +81,7 @@ def combine_models(self, helper=None, delete_models=True): | |
total_examples += metadata['num_examples'] | ||
|
||
if nr_aggregated_models == 0: | ||
model_old = self.control.load_model_update(helper, model_update.model_id) | ||
model_old = self.round_handler.load_model_update(helper, model_update.model_id) | ||
pseudo_gradient = helper.subtract(model_next, model_old) | ||
else: | ||
pseudo_gradient_next = helper.subtract(model_next, model_old) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add this to gitignore after it has been commited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I also moved it into the mnist-pytorch example