SemiAsyncFederatedTrainer<T>

Models & Types · AiDotNet.FederatedLearning.Trainers

Implements Semi-Asynchronous Federated Learning — hybrid sync/async with periodic barriers.

Inheritance: FederatedLearningComponentBase<T> → SemiAsyncFederatedTrainer<T>

For Beginners

Pure synchronous FL waits for ALL clients each round (slow, wastes time waiting for stragglers). Pure async FL processes each update immediately (fast, but stale updates can hurt convergence). Semi-Async is the middle ground: the server accepts async updates between synchronization barriers that occur every K rounds. During async phases, fast clients can contribute multiple updates. At barriers, all pending updates are aggregated and a new global model is broadcast. This balances speed with convergence quality.

How It Works

Algorithm:

Reference: Wu, X., et al. (2023). “Semi-Asynchronous Federated Learning: Convergence and Efficiency.” IEEE TPDS 2023.

Constructors

Constructor Summary
SemiAsyncFederatedTrainer(int asyncRoundsPerBarrier, double stalenessDiscount, double asyncLearningRate) Creates a new Semi-Async FL trainer.

Properties

Property Summary
double AsyncLearningRate { get; } Gets the async learning rate.
double StalenessDiscount { get; } Gets the staleness discount factor.
int AsyncRoundsPerBarrier { get; } Gets the number of async rounds per barrier.
int CurrentRound { get; } Gets the current round number.
int PendingUpdateCount { get; } Gets the number of pending buffered updates.

Methods

Method Summary
Dictionary<string, T[]> ApplyAsyncUpdates(Dictionary<string, T[]> globalModel) Applies buffered async updates to the global model with staleness discounting.
Dictionary<string, T[]> SynchronizationBarrier(Dictionary<string, T[]> globalModel, Dictionary<int, Dictionary<string, T[]>> clientModels, Dictionary<int, int> clientSampleCounts) Performs a synchronization barrier: aggregates all buffered updates via weighted average.
bool IsBarrierRound(int round) Determines whether the current round is a synchronization barrier.
void AdvanceRound() Advances the trainer to the next round.
void ReceiveUpdate(int clientId, Dictionary<string, T[]> update, int clientRound) Receives an async client update and buffers it for application.