Skip to content

Releases: adap/flower

0.16.0

11 May 09:00
834e791
Compare
Choose a tag to compare

What's new?

  • New built-in strategies (#549)

    • (abstract) FedOpt
    • FedAdagrad
  • Custom metrics for server and strategies (#717)

    The Flower server is now fully task-agnostic, all remaining instances of task-specific metrics (such as :code:accuracy) have been replaced by custom metrics dictionaries. Flower 0.15 introduced the capability to pass a dictionary containing custom metrics from client to server. As of this release, custom metrics replace task-specific metrics on the server.

    Custom metric dictionaries are now used in two user-facing APIs: they are returned from Strategy methods :code:aggregate_fit/:code:aggregate_evaluate and they enable evaluation functions passed to build-in strategies (via :code:eval_fn) to return more than two evaluation metrics. Strategies can even return aggregated metrics dictionaries for the server to keep track of.

    Stratey implementations should migrate their :code:aggregate_fit and :code:aggregate_evaluate methods to the new return type (e.g., by simply returning an empty :code:{}), server-side evaluation functions should migrate from :code:return loss, accuracy to :code:return loss, {"accuracy": accuracy}.

    Flower 0.15-style return types are deprecated (but still supported), compatibility will be removed in a future release.

  • Migration warnings for deprecated functionality (#690)

    Earlier versions of Flower were often migrated to new APIs, while maintaining compatibility with legacy APIs. This release introduces detailed warning messages if usage of deprecated APIs is detected. The new warning messages often provide details on how to migrate to more recent APIs, thus easing the transition from one release to another.

  • Improved docs and docstrings (#691, #692, #713)

  • MXNet example and documentation

  • FedBN implementation in example PyTorch: From Centralized To Federated (#696, #702, #705)

Incompatible changes:

  • Serialization-agnostic server (#721)

    The Flower server is now fully serialization-agnostic. Prior usage of class :code:Weights (which represents parameters as deserialized NumPy ndarrays) was replaced by class :code:Parameters (e.g., in :code:Strategy). :code:Parameters objects are fully serialization-agnostic and represents parameters as byte arrays, the :code:tensor_type attributes indicates how these byte arrays should be interpreted (e.g., for serialization/deserialization).

    Built-in strategies implement this approach by handling serialization and deserialization to/from :code:Weights internally. Custom/3rd-party Strategy implementations should update to the slighly changed Strategy method definitions. Strategy authors can consult PR #721 to see how strategies can easily migrate to the new format.

  • Deprecated :code:flwr.server.Server.evaluate, use :code:flwr.server.Server.evaluate_round instead (#717)

0.15.0

12 Mar 08:05
799540e
Compare
Choose a tag to compare

What's new?

  • Server-side parameter initialization (#658)

    Model parameters can now be initialized on the server-side. Server-side parameter initialization works via a new Strategy method called initialize_parameters.

    Built-in strategies support a new constructor argument called initial_parameters to set the initial parameters. Built-in strategies will provide these initial parameters to the server on startup and then delete them to free the memory afterward.

      # Create model
      model = tf.keras.applications.EfficientNetB0(
          input_shape=(32, 32, 3), weights=None, classes=10
      )
      model.compile("adam", "sparse_categorical_crossentropy", metrics=["accuracy"])
    
      # Create strategy and initilize parameters on the server-side
      strategy = fl.server.strategy.FedAvg(
          # ... (other constructor arguments)
          initial_parameters=model.get_weights(),
      )
    
      # Start Flower server with the strategy
      fl.server.start_server("[::]:8080", config={"num_rounds": 3}, strategy=strategy)

    If no initial parameters are provided to the strategy, the server will continue to use the current behavior (namely, it will ask one of the connected clients for its parameters and use these as the initial global parameters).

Deprecations

  • Deprecate flwr.server.strategy.DefaultStrategy (migrate to flwr.server.strategy.FedAvg, which is equivalent)

0.14.0

18 Feb 12:59
e38e8a8
Compare
Choose a tag to compare

What's new?

  • Generalized Client.fit and Client.evaluate return values (#610, #572, #633)

    Clients can now return an additional dictionary mapping str keys to values of the following types: bool, bytes, float, int, str. This means one can return almost arbitrary values from fit/evaluate and make use of them on the server side!

    This improvement also allowed for more consistent return types between fit and evaluate: evaluate should now return a tuple (float, int, dict) representing the loss, number of examples, and a dictionary holding arbitrary problem-specific values like accuracy.

    In case you wondered: this feature is compatible with existing projects, the additional dictionary return value is optional. New code should however migrate to the new return types to be compatible with upcoming Flower releases (fit: List[np.ndarray], int, Dict[str, Scalar], evaluate: float, int, Dict[str, Scalar]). See the example below for details.

    Code example: note the additional dictionary return values in both FlwrClient.fit and FlwrClient.evaluate:

    class FlwrClient(fl.client.NumPyClient):
        def fit(self, parameters, config):
            net.set_parameters(parameters)
            train_loss = train(net, trainloader)
            return net.get_weights(), len(trainloader), {"train_loss": train_loss}
    
        def evaluate(self, parameters, config):
            net.set_parameters(parameters)
            loss, accuracy, custom_metric = test(net, testloader)
            return loss, len(testloader), {"accuracy": accuracy, "custom_metric": custom_metric}
  • Generalized config argument in Client.fit and Client.evaluate (#595)

    The config argument used to be of type Dict[str, str], which means that dictionary values were expected to be strings. The new release generalizes this to enable values of the following types: bool, bytes, float, int, str.

    This means one can now pass almost arbitrary values to fit/evaluate using the config dictionary. Yay, no more str(epochs) on the server-side and int(config["epochs"]) on the client side!

    Code example: note that the config dictionary now contains non-str values in both Client.fit and Client.evaluate:

    class FlwrClient(fl.client.NumPyClient):
        def fit(self, parameters, config):
            net.set_parameters(parameters)
            epochs: int = config["epochs"]
            train_loss = train(net, trainloader, epochs)
            return net.get_weights(), len(trainloader), {"train_loss": train_loss}
    
        def evaluate(self, parameters, config):
            net.set_parameters(parameters)
            batch_size: int = config["batch_size"]
            loss, accuracy = test(net, testloader, batch_size)
            return loss, len(testloader), {"accuracy": accuracy}

0.13.0

08 Jan 13:01
802f11b
Compare
Choose a tag to compare

What's new?

  • New example: PyTorch From Centralized To Federated (#549)
  • Improved documentation
    • New documentation theme (#551)
    • New API reference (#554)
    • Updated examples documentation (#549)
    • Removed obsolete documentation (#548)

Bugfix:

  • Server.fit does not disconnect clients when finished, disconnecting the clients is now handled in flwr.server.start_server (#553, #540).

0.12.0

07 Dec 10:09
6e4ac64
Compare
Choose a tag to compare

Important changes:

  • Added an example for embedded devices (#507)
  • Added a new NumPyClient (in addition to the existing KerasClient) (#504, #508)
  • Deprecated flwr_examples package and started to migrate examples into the top-level examples directory (#494, #512)

0.11.0

30 Nov 16:26
7cdfe7b
Compare
Choose a tag to compare

Incompatible changes:

  • Renamed strategy methods (#486) to unify the naming of Flower's public APIs. Other public methods/functions (e.g., every method in Client, but also Strategy.evaluate) do not use the on_ prefix, which is why we're removing it from the four methods in Strategy. To migrate rename the following Strategy methods accordingly:
    • on_configure_evaluate => configure_evaluate
    • on_aggregate_evaluate => aggregate_evaluate
    • on_configure_fit => configure_fit
    • on_aggregate_fit => aggregate_fit

Important changes:

  • Deprecated DefaultStrategy (#479). To migrate use FedAvg instead.
  • Simplified examples and baselines (#484).
  • Removed presently unused on_conclude_round from strategy interface (#483).
  • Set minimal Python version to 3.6.1 instead of 3.6.9 (#471).
  • Improved Strategy docstrings (#470).

0.10.0

11 Nov 16:43
6bdc1a5
Compare
Choose a tag to compare
v0.10.0

Upgrade pip to 20.2.4 (#466)