๐ฆ Node Stateยถ
NodeState
centralizes critical information, enabling different components within a node to coordinate effectively during federated learning. Thread locks are used to maintain data consistency during concurrent operations like voting and aggregation.
Key Attributesยถ
addr
(str): The nodeโs address.status
(str): The nodeโs current status (e.g., โIdleโ, โLearningโ).experiment
(Experiment): The current experimentโs configuration.simulation
(bool): Whether the node is running in a simulation.models_aggregated
(Dict): Aggregated models received from neighbors.nei_status
(Dict): Neighborsโ current round numbers.train_set
(List): Nodes participating in the current training round.train_set_votes
(Dict): Votes for train set selection.Thread Locks (various): Ensure thread-safe access to shared state.
Experimentยถ
The Experiment
class encapsulates the configuration and state of a federated learning experiment. It tracks the experimentโs name, the total number of rounds, and the current round.
from p2pfl.experiment import Experiment
experiment = Experiment(exp_name="my_experiment", total_rounds=10)
print(f"Experiment name: {experiment.exp_name}")
print(f"Total rounds: {experiment.total_rounds}")
print(f"Current round: {experiment.round}")
experiment.increase_round()
print(f"Current round after increase: {experiment.round}")