flower
flower copied to clipboard
C++ Client SDK
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):
- Define a simple machine learning model using C++/libtorch
- Extract the model parameters from the model in C++
- Serialize the extracted model parameters into a byte array / a list of byte arrays
- Save the list of byte arrays to disk
- Read the list of byte arrays from Python
- Deserialize the model parameters from the list of byte arrays
- Load a PyTorch model and update it using the deserialized model parameters
- Implement the flow in reverse (serialize in Python, deserialize in C++)
Expected Outcome
The full SDK implementation requires the following tasks:
- [ ] Set up C++ tooling in the Flower codebase
- [ ] Run tests on CI
- [ ] Set up ProtoBuf/gRPC compilation for C++
- [ ] Define the user-facing API of the C++ SDK
- [ ] Define abstract class / interface which Flower users can override
- [ ] Define a function to start the client
- [ ] Implement the API
- [ ] Establish a connection to the server
- [ ] Implement handling of protocol messages
- [ ] Test the new SDK
- [ ] Document everything
- [ ] Build a C++ library and publish it
- [ ] Build a code example using the C++ SDK and libtorch (PyTorch C++ API)
- [ ] Write Blog post about the available feature
Required Skills:
- Strong experience with C++
- Interest in gRPC
- Basic understanding of machine learning
- Optional: Basic libtorch (PyTorch C++ API https://pytorch.org/cppdocs/) understanding
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.