Server
The server is the orchestrator of the training, aggregating the results from the clients to improve the global model. As the clients, it is independent of the machine learning tools. The server can evaluate the global model by proxying an evaluate() function.
App
Entry point to start the CentralNode. The server must be started before launching clients.
Fed.Server.build_router — Functionbuild_router(central_node::CentralNode)Build the routes to the central node endpoints.
Fed.Server.start — Functionstart(central_node::CentralNode)Start a Fed.jl HTTP server.
CentralNode
Data structure containing the server's configuration and its API for communicating with the nodes.
Fed.Server.CentralNode — TypeCentralNode(host, port, weights, strategy, evaluate, config)Orchestrate the entire federated learning process. It handles the clients registration and requests them to train on their local data.
Fed.Server.fit — Functionfit(central_node::CentralNode)Fit the global model by orchestrating the federated training.
Fed.Server.fit_client — Functionfit_client(url::String, payload::Vector{UInt8})Ask one client to train on its local data, by using the model weights contained in the payload. Return the serialized updated weights.
Fed.Server.fit_clients — Functionfit_clients(endpoint::String, clients::Vector{String}, payload::Vector{UInt8})Ask asynchronously each client from clients to train on their local data by using the model weights contained in the payload. Return a Vector where each element is the serialized weights of one client.
Fed.Server.register_client! — Functionregister_client!(cm::ClientManager, req::HTTP.Request)Register a new client in the ClientManager. The body of the request should contain the client URL: http://hostname:port.
API Endpoint: this is an HTTP server endpoint.
ClientManager
The ClientManager handles the nodes registrations and synchronize the server to make it start when the clients are ready.
Fed.Server.ClientManager — TypeClientManager()Structure which manages the clients registration and syncrhonizes the server to make it work with them.
Base.length — Methodlength(cm::ClientManager)Return the number of client managed by the ClientManager.
Fed.Server.num_available_clients — Functionnum_available_clients(cm::ClientManager)Return the number of available clients.
Fed.Server.register! — Functionregister!(cm::ClientManager, client_url::String)Register a new client_url.
Example
register!(cm, "http://127.0.0.1:8081")Fed.Server.sample_clients — Functionsample_clients(cm::ClientManager, fraction::Float32)Sample randomly fraction% of the clients, without replacement. Return at least one client if the number of available clients > 0.
Fed.Server.wait_for — Functionwait_for(cm::ClientManager, num_clients::Int)Block until at least num_clients are available.
Strategy
Fed.Server.federated_averaging — Functionfederated_averaging(round_weights)Implement the federated averaging algorithm descibed in:
round_weights must be an array containing the weights from each clients participating in the round.