ποΈ ComponentsΒΆ
P2PFL is built on a modular architecture centered around the Node
class. This modularity provides flexibility and extensibility, allowing you to easily customize and integrate different components. The Node
class interacts with various modules to orchestrate the operations of a federated learning node.
Letβs briefly introduce each module:
Node
: The core component, orchestrating the federated learning process. It acts as the central hub, interacting with all other modules to manage the nodeβs lifecycle and operations.Logger
: Handles logging and tracking of training events and metrics. Provides valuable information about node behavior and assists in debugging and monitoring.State
: Manages the nodeβs internal state, storing essential information and tracking its progress throughout the federated learning process.CommunicationProtocol
: Facilitates communication between nodes, enabling them to exchange models, gradients, and other necessary data. It uses the template pattern to support various communication protocols while maintaining a consistent API.Command
: Deines the set of commands that can be executed over theCommunicationProtocol
. It leverages the command pattern, allowing the creation of new commands that can be executed independently of the underlying communication protocol.Learner
: Handles the machine learning aspects, encapsulating the training and evaluation of models. It employs the template pattern to seamlessly integrate different machine learning frameworks (like PyTorch, TensorFlow, or Flax) under a unified API.Dataset
: Manages the dataset used for training the models. It provides an interface to load, preprocess, and distribute data across nodes.Aggregator
: Responsible for aggregating model updates from different nodes. It uses the strategy pattern, making it easy to implement and switch between various aggregation strategies (e.g., FedAvg, Scaffold, FedMedian).Workflow
: Defines the sequence of steps a node takes during the federated learning process. It also uses the strategy pattern to support different workflows, allowing for customization based on specific requirements (e.g., BaseNode workflow, ProxyNode workflow).