adap / flower

Flower: A Friendly Federated AI Framework
https://flower.ai
Apache License 2.0
5.11k stars 881 forks source link

C++ Client SDK #363

Open danieljanes opened 4 years ago

danieljanes commented 4 years ago

Description

C++ is one of the most defining programming languages of our time. It is used in many critical applications and the go-to language for performance-sensitive applications, such as robotics or automotive. Federated Learning can enable entirely new platforms in these domains and we thus want to support C++ by providing a Flower C++ SDK. Flower communicates between the server and the client using gRPC. At the moment, every C++ user needs to build their own integration with the gRPC message protocol to run Flower.

Prep Work / PoC

The C++ SDK needs to serialize model parameters (and other values that get communicated between client and server) in a way that can be de-serialized by Python on the server-side. ProtoBuf makes this easy for most values, but it might be helpful to build a small proof of concept for serializing/deserializing the model parameters. Flower represents model parameters as a list of byte arrays (think: the parameters of each layer in a neural network can be serialized to a single byte array). A PoC would then serialized these parameters in C++ and deserialized them in Python (and vice versa):

  1. Define a simple machine learning model using C++/libtorch
  2. Extract the model parameters from the model in C++
  3. Serialize the extracted model parameters into a byte array / a list of byte arrays
  4. Save the list of byte arrays to disk
  5. Read the list of byte arrays from Python
  6. Deserialize the model parameters from the list of byte arrays
  7. Load a PyTorch model and update it using the deserialized model parameters
  8. Implement the flow in reverse (serialize in Python, deserialize in C++)

Expected Outcome

The full SDK implementation requires the following tasks:

Required Skills:

sisco0 commented 2 years ago

Bumped as this is very relevant and could bring more developers to the project. Related pull request for this issue is https://github.com/adap/flower/pull/816.

gRPC C++ Client

We could use our current proto files and https://grpc.github.io/grpc/cpp/classgrpc_1_1_client_reader_writer.html functions for client-server interaction in the proposed C++ client application.