As per our implementation, we require to send model weights from an individual local client model to a server model in order to identify the models to select for training in the subsequent rounds(trust and clustering of weights). However, I am unable to achieve this via flower framework. Can anyone provide any details or some examples detailing the same.
Thank you for your reply and for the provided links!
Actually, what we are trying to do in our approach, is to obtain the weights on the local models after each training round, and use them by the server to construct an aggregation function. For our procedures, we need these weights in each round, for each client, and these weights should be represented as numerical values (e.g., float). The documentation is not very descriptive on how to obtain local model’s weights from each client and save them on the server. We would appreciate if you can suggest any Flower methods using which we can handle this.
The linked tutorial does exactly that. In particular, take a look at this section “Implementing a Flower client”: the
fit method on the client receives initial model weights (“parameters”) from the server, performs 1 epoch of training, and then sends updated model weights (“parameters”) back to the server.
This example is using a Flower-implemented Federated Averaging “strategy” for model weight aggregation. If you have your own aggregation algorithm, take a look at this tutorial “Building a Strategy”.
In general, I strongly recommend you read all of the tutorials in the “Tutorials” section of the Flower documentation. I believe they closely align with what you are describing you need help with.
Thank you for your response.
Is there a method on the server side(or a an attribute in strategy )that allows us to capture the weights of the local client models which are sent over to the server by each individual client? The strategy basically allows us to perform tasks like averaging of the weights of different client. Can this be resolved?
Again, please review the tutorials in the Flower documentation. What you are describing is standard use of Flower. Take a look at the
aggregate_fit method documentation.
Thanks a lot for your reply and clarification. We looked into the docs, tutorials, and source of the methods you suggested, however, we did not find them helpful for the problem we are facing.
Let me try to explain again what we are trying to do.
In our approach, we need to communicate local model parameters of the individual clients to the server, and then use them by the server BEFORE the aggregation to customize the aggregation function. In one of the tutorials you suggested, there described a way to save the model parameters (Save Progress - Flower 1.3.0). However, it seems that the following function
saves only the parameters that are already aggregated. In addition, the tutorials, docs, and how-to-guides do not explain how to map the parameters to the clients that sent these parameters. Indeed, we require this mapping in order to assign the weights to the local clients during the aggregation process, and to decide which clients will receive the global model back.
We tried to look into the flwr documentation, and it seems that ClientProxy or client_manager should map the parameters to the clients. However, the complete information that describes how to work with ClientProxy and client_manager, and any examples, are missing in the documentation.
We apologize for another post here, but we do not have enough experience working with Flower. We would really appreciate it if you can help us to find the answer. May I ask if it is possible to organize another Office Hours session for the team, or a Zoom meeting with a team?
Thanks a lot for your reply!
I believe you are on the right track. The
ClientProxy objects should have the information you’re looking for. The source code for each of these classes are all pretty small amounts of code that are highly type-annotated and easy to read.
For example, client manager objects have a method
all that returns a dictionary of client proxy objects keyed by
cid (client ID). source code
ClientProxy has an attribute
cid that is the client id: source code
Since you can write arbitrary code in
aggregate_fit, you can do whatever you want before you perform the aggregation yourself.
If you haven’t already, please also take a look at the simple examples in the runtime repository:
examples_src/. You can see in the Financial Crime simple example that is provided in the runtime repository, the
aggregate_fit method does something different for the results of fitting on SWIFT vs. fitting on banks.