blazefl.core.ServerHandler#

class blazefl.core.ServerHandler[source]#

Bases: ABC, Generic[UplinkPackage, DownlinkPackage]

Abstract base class for server-side operations in federated learning.

This class defines the essential methods that a server handler must implement to manage communication and coordination with clients during federated learning processes. It uses generic types UplinkPackage and DownlinkPackage to define the types of data exchanged between the server and clients.

Raises:

NotImplementedError – If any of the methods are not implemented in a subclass.

__init__()#

Methods

__init__()

downlink_package()

Prepare the data package to be sent from the server to clients.

global_update(buffer)

Update the global model based on the aggregated data from clients.

if_stop()

Determine whether the federated learning process should be terminated.

load(payload)

Load a given payload into the server's state.

sample_clients()

Select a list of client IDs to participate in the current training round.

Prepare the data package to be sent from the server to clients.

Returns:

The data package intended for client consumption.

Return type:

DownlinkPackage

abstract global_update(buffer: list[UplinkPackage]) None[source]#

Update the global model based on the aggregated data from clients.

Parameters:
  • buffer (list[UplinkPackage]) – A list containing data sent by clients,

  • gradients. (typically representing model updates or)

Returns:

None

abstract if_stop() bool[source]#

Determine whether the federated learning process should be terminated.

Returns:

True if the process should stop; False otherwise.

Return type:

bool

abstract load(payload: UplinkPackage) bool[source]#

Load a given payload into the server’s state.

Parameters:

payload (UplinkPackage) – The data to be loaded into the server.

Returns:

True if the payload was successfully loaded; False otherwise.

Return type:

bool

abstract sample_clients() list[int][source]#

Select a list of client IDs to participate in the current training round.

Returns:

A list of selected client IDs.

Return type:

list[int]