kosmos.simulator.fl_simulator

Classes

class FLSimulator(network: kosmos.topology.net.Network, train_config: kosmos.ml.config.sl_train.FLTrainConfig, client_nodes: list[kosmos.topology.typing.NodeReference], server_node: kosmos.topology.typing.NodeReference, seed: int = 1)[source]

Bases: kosmos.simulator.simulator.Simulator

Federated learning simulator.

train_config

The federated learning training configuration.

Type:

FLTrainConfig

client_nodes

The client nodes in the federated learning setup.

Type:

list[Node]

server_node

The server node in the federated learning setup.

Type:

Node

manager

The federated learning manager handling training and aggregation.

Type:

FLManager

Initialize the simulator.

Parameters:
  • network (Network) – The network topology.

  • train_config (FLTrainConfig) – The federated learning training configuration.

  • client_nodes (list[NodeReference]) – The node references of the clients.

  • server_node (NodeReference) – The node reference of the server.

  • seed (int) – The seed for the random number generator. Defaults to 1.


Methods

train() collections.abc.Iterator[kosmos.ml.sl_result.SLTrainIterationResult][source]

Run federated training across all configured rounds.

Returns:

An iterator yielding one training result per epoch

for all rounds.

Return type:

Iterator[SLTrainIterationResult]

test() kosmos.ml.sl_result.SLTestIterationResult[source]

Evaluate the global model on the test dataset.

Returns:

The result of the global model evaluation.

Return type:

SLTrainIterationResult