blazefl.core.ParallelClientTrainer#

class blazefl.core.ParallelClientTrainer(num_parallels: int, share_dir: Path)[source]#

Bases: SerialClientTrainer[UplinkPackage, DownlinkPackage], Generic[UplinkPackage, DownlinkPackage, DiskSharedData]

Abstract base class for parallel client training in federated learning.

This class extends SerialClientTrainer to enable parallel processing of clients, allowing multiple clients to be trained concurrently.

num_parallels#

Number of parallel processes to use for client training.

Type:

int

share_dir#

Directory path for sharing data between processes.

Type:

Path

cache#

Cache to store uplink packages from clients.

Type:

list[UplinkPackage]

Raises:

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

__init__(num_parallels: int, share_dir: Path) None[source]#

Initialize the ParallelClientTrainer with parallelism settings.

Parameters:
  • num_parallels (int) – Number of parallel processes to use.

  • share_dir (Path) – Directory path for sharing data between processes.

Methods

__init__(num_parallels, share_dir)

Initialize the ParallelClientTrainer with parallelism settings.

get_shared_data(cid, payload)

Retrieve shared data for a given client ID and payload.

local_process(payload, cid_list)

Manage the parallel processing of clients.

process_client(path)

Process a single client based on the provided path.

uplink_package()

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

abstract get_shared_data(cid: int, payload: DownlinkPackage) DiskSharedData[source]#

Retrieve shared data for a given client ID and payload.

Parameters:
  • cid (int) – Client ID.

  • payload (DownlinkPackage) – The data package received from the server.

Returns:

The shared data associated with the client ID and payload.

Return type:

DiskSharedData

local_process(payload: DownlinkPackage, cid_list: list[int]) None[source]#

Manage the parallel processing of clients.

This method distributes the processing of multiple clients across parallel processes, handling data saving, loading, and caching.

Parameters:
  • payload (DownlinkPackage) – The data package received from the server.

  • cid_list (list[int]) – A list of client IDs to process.

Returns:

None

abstract static process_client(path: Path) Path[source]#

Process a single client based on the provided path.

Parameters:

path (Path) – Path to the client’s data file.

Returns:

Path to the processed client’s data file.

Return type:

Path