federer
Version:
Experiments in asynchronous federated learning and decentralized learning
76 lines • 2.7 kB
TypeScript
import { SerializedWeights } from "../weights";
/**
* Mapping of message names to listener callbacks for messages that are sent
* from the clients to the server.
*/
export interface ClientToServerMessages {
/**
* When the client initially connects, it needs to indicate to the server when
* it is ready to start training. When it does this, it attaches some metadata
* about itself.
*/
ready: (metadata: MetadataMessage) => void;
/** When a client uploads a locally trained model to the aggregation server. */
upload: (message: UploadMessage) => void;
}
/**
* Contents of the message that clients send to the server when initially
* connecting, to give the server some more information about the client.
*/
export interface MetadataMessage {
/** Number of datapoints on the client. Used to weigh client's contribution. */
numberDatapoints: number;
/**
* Client ID. This is not needed for FL, but is just used to have consistent
* naming of clients in debug logs, and is used as a unique identifier for the
* client.
*/
clientId: number;
/**
* Number of epochs the client will be running each time it gets a
* {@link DownloadMessage}. This is used to create round summaries, so mostly
* for evaluation.
*
* @note
* Currently, all clients run the same number of epochs. But by sending the
* number of epochs to the server this way, we have support for different
* number of epochs on different clients.
*/
numberEpochs: number;
/**
* Whether the client will be sending updates as full weights, or as a delta
* of the change. This is used by the server to assert that all clients are
* sending the correct type of deltas.
*
* @see {@link ClientStartOptions}
*/
deltaUpdates: boolean;
}
/**
* Contents of the message that clients send to the server when uploading their
* local weights.
*/
export interface UploadMessage {
/** Round number that the client started training at. */
round: number;
/** Newly trained weights. */
weights: SerializedWeights;
}
/**
* Mapping of message names to listener callbacks for messages that are sent
* from the server to the clients.
*/
export interface ServerToClientMessages {
/** When the aggregation server sends a model to a client. */
download: (message: DownloadMessage) => void | Promise<void>;
}
/**
* Contents of the message that the server sends to clients.
*/
export interface DownloadMessage {
/** Current round number. */
round: number;
/** Current model weights. */
weights: SerializedWeights;
}
//# sourceMappingURL=client-server.d.ts.map