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

Rename QffedAvg to QFedAvg #802

Merged
merged 5 commits into from
Aug 15, 2021
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
4 changes: 4 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Incompatible changes:

Prior behaviour was to perform a final round of distributed evaluation on all connected clients, which is often not required (e.g., when using server-side evaluation). The prior behaviour can be enabled by passing :code:`force_final_distributed_eval=True` to :code:`start_server`.

* **Renamed q-FedAvg strategy** (`#802 <https://github.com/adap/flower/pull/802>`_)

The strategy named :code:`QffedAvg` was renamed to `QFedAvg` to better reflect the notation given in the original paper (q-FFL is the optimization objective, q-FedAvg is the proposed solver). Note the the original (now deprecated) :code:`QffedAvg` class is still available for compatibility reasons (it will be removed in a future release).


v0.16.0 (2021-05-11)
--------------------
Expand Down
6 changes: 4 additions & 2 deletions src/py/flwr/server/strategy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from .fedavg import FedAvg as FedAvg
from .fedfs_v0 import FedFSv0 as FedFSv0
from .fedfs_v1 import FedFSv1 as FedFSv1
from .qffedavg import QffedAvg as QffedAvg
from .qfedavg import QFedAvg as QFedAvg
from .qfedavg import QffedAvg as QffedAvg # Deprecated
from .strategy import Strategy as Strategy

__all__ = [
Expand All @@ -33,6 +34,7 @@
"FedAvg",
"FedFSv0",
"FedFSv1",
"QffedAvg",
"QFedAvg",
"QffedAvg", # Deprecated
"Strategy",
]
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from .fedavg import FedAvg


class QffedAvg(FedAvg):
"""Configurable QffedAvg strategy implementation."""
class QFedAvg(FedAvg):
"""Configurable QFedAvg strategy implementation."""

# pylint: disable=too-many-arguments,too-many-instance-attributes
def __init__(
Expand Down Expand Up @@ -236,3 +236,54 @@ def aggregate_evaluate(
),
{},
)


DEPRECATION_WARNING_QFFEDAVG = """
DEPRECATION WARNING: Deprecated strategy

QffedAvg

use

QFedAvg

instead.
"""


class QffedAvg(QFedAvg):
"""Configurable QFedAvg strategy implementation."""

# pylint: disable=too-many-arguments,too-many-instance-attributes
def __init__(
self,
q_param: float = 0.2,
qffl_learning_rate: float = 0.1,
fraction_fit: float = 0.1,
fraction_eval: float = 0.1,
min_fit_clients: int = 1,
min_eval_clients: int = 1,
min_available_clients: int = 1,
eval_fn: Optional[
Callable[[Weights], Optional[Tuple[float, Dict[str, Scalar]]]]
] = None,
on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
accept_failures: bool = True,
initial_parameters: Optional[Parameters] = None,
) -> None:
super().__init__(
q_param=q_param,
qffl_learning_rate=qffl_learning_rate,
fraction_fit=fraction_fit,
fraction_eval=fraction_eval,
min_fit_clients=min_fit_clients,
min_eval_clients=min_eval_clients,
min_available_clients=min_available_clients,
eval_fn=eval_fn,
on_fit_config_fn=on_fit_config_fn,
on_evaluate_config_fn=on_evaluate_config_fn,
accept_failures=accept_failures,
initial_parameters=initial_parameters,
)
print(DEPRECATION_WARNING_QFFEDAVG)
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def main() -> None:
)

if server_setting.strategy == "qffedavg":
strategy = fl.server.strategy.QffedAvg(
strategy = fl.server.strategy.QFedAvg(
q_param=0.2,
qffl_learning_rate=0.1,
fraction_fit=server_setting.sample_fraction,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr_experimental/baseline/tf_hotkey/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def main() -> None:
)

if server_setting.strategy == "qffedavg":
strategy = fl.server.strategy.QffedAvg(
strategy = fl.server.strategy.QFedAvg(
q_param=0.2,
qffl_learning_rate=0.1,
fraction_fit=server_setting.sample_fraction,
Expand Down