The Federated Averaging Algorithm (FedAvg) trains a shared machine learning model by combining updates from multiple clients without collecting their raw datasets. Each client improves a copy of the global model using local data, and a coordinating server calculates a weighted average of the resulting model parameters.
Within Federated Learning, FedAvg provides a practical way to reduce communication between participants while allowing them to learn from distributed data. The key is understanding two operations: local training and weighted aggregation. Together, they determine how the global model changes after each training round.
How the FedAvg Algorithm Works
FedAvg follows a repeated training cycle in which selected clients update the same model independently before their results are combined.
The algorithm can be understood through five steps.
Initialize the global model. The server creates a model with an agreed architecture and initial parameter values.
Select participating clients. The server selects a group of available clients for the current communication round. The selected clients receive the same global model parameters.
Train models locally. Each client performs a defined number of training passes over its local dataset using an optimizer such as stochastic gradient descent (SGD). The original training records remain on the client.
Aggregate model updates. Clients return their updated model parameters or equivalent model changes. The server combines the successful contributions using weights based on the number of training examples represented by each client.
Update and evaluate the global model. The aggregated parameters form the next global model. The system evaluates its performance and begins another round when further training is required.
The distinguishing feature of FedAvg is that clients can perform multiple local optimization steps before communicating with the server.
This reduces the need to exchange model information after every individual gradient update.
It also introduces a tradeoff: more local training reduces communication frequency, but client models can move further apart when their datasets contain different statistical patterns.
Understanding that tradeoff is essential before adjusting the algorithm's training parameters.
Federated Averaging Formula
The mathematical operation at the center of FedAvg is a weighted average of the participating models.
For a training round, the aggregation formula is:
w_global = Σ (n_k / N) × w_k
Here:
w_global represents the updated global model parameters.
w_k represents the model parameters returned by client k after local training.
n_k represents the number of training examples assigned to client k for aggregation.
N represents the total number of training examples across the clients whose updates are included in that round.
The summation includes the clients contributing valid updates to the current aggregation.
Each client's contribution is multiplied by its share of the participating training examples.
A client representing 40% of those examples receives an aggregation weight of 0.4.
A client representing 10% receives an aggregation weight of 0.1.
The aggregation weights add up to 1.
Weighted Averaging vs Simple Averaging
The distinction matters when participants have different dataset sizes.
A simple average assigns equal influence to every client, regardless of the number of training examples.
FedAvg uses the example counts to determine each contribution.
This makes the aggregation consistent with an objective that weights clients according to their represented training examples.
However, weighting by dataset size does not guarantee higher model accuracy.
The quality and distribution of each client's data still affect the result.
Nor does weighted aggregation reproduce centralized training exactly after clients have completed multiple independent optimization steps.
The client models have already changed through their local training processes before averaging takes place.
FedAvg Calculation Example
A numerical example makes the aggregation process easier to follow.
Consider three financial institutions collaborating to train a fraud detection model.
Each institution receives the same initial model, trains it on its own transaction data, and returns updated parameters.
To keep the calculation manageable, we will use a model containing just two parameters.
The example is illustrative. A production model applies the same aggregation operation across all relevant parameters.
Step 1: Identify the Local Model Updates
After one training round, the clients return these results:
Client A
Training examples: 100
Model parameters: [0.8, 1.8]
Client B
Training examples: 200
Model parameters: [1.4, 1.2]
Client C
Training examples: 300
Model parameters: [2.0, 0.6]
All three clients started from the same global model.
Their final parameter values differ because each institution trained on its own dataset.
Step 2: Calculate the Aggregation Weights
The total number of participating training examples is:
N = 100 + 200 + 300 = 600
Each client's contribution is calculated by dividing its example count by 600.
Client A: 100 / 600 = 1/6
Client B: 200 / 600 = 1/3
Client C: 300 / 600 = 1/2
Client C contributes half of the examples represented in this round, so it receives half of the aggregation weight.
Step 3: Calculate the New Global Parameters
We apply the weighted average separately to both model parameters.
First parameter:
(100 × 0.8 + 200 × 1.4 + 300 × 2.0) / 600
= (80 + 280 + 600) / 600
= 1.6
Second parameter:
(100 × 1.8 + 200 × 1.2 + 300 × 0.6) / 600
= (180 + 240 + 180) / 600
= 1.0
The updated global model is:
Global model = [1.6, 1.0]
For comparison, a simple average that gives all three clients equal influence produces:
Unweighted model = [1.4, 1.2]
The difference comes entirely from the aggregation weights.
Client C has the largest dataset, so its parameters contribute more heavily to the result.
This example illustrates the key operation behind FedAvg. The server combines numerical model parameters, not the underlying transaction records.
In the next round, participating clients receive the updated global model and continue training from those shared parameters.
FedAvg Training Parameters
The aggregation formula is straightforward, but the behavior of FedAvg depends heavily on how local training is configured.
Three parameters are especially important: the number of local epochs, the batch size, and the learning rate.
Client participation and the total number of communication rounds also influence the training process.
The following table shows how these settings affect the algorithm and what engineers need to measure.

The settings should be evaluated together rather than adjusted independently.
For example, increasing local epochs changes how far each client moves from the shared starting model before aggregation.
If participants have substantially different data distributions, the resulting updates can point toward competing local objectives.
Increasing the learning rate at the same time can amplify this effect.
A stronger evaluation therefore tracks both the global model and performance across individual client datasets.
The goal is not to maximize local computation. It is to obtain a useful global model at an acceptable communication and computing cost.
FedAvg vs Federated SGD
FedAvg and Federated Stochastic Gradient Descent (FedSGD) both support distributed model training, but they differ in the amount of computation performed between communication rounds.
Federated SGD
In FedSGD, clients compute gradients using the current global model.
The server aggregates those gradients and applies a global optimization step.
In the original formulation, clients do not perform multiple successive local updates before communicating.
This keeps the optimization process closely coordinated but requires communication for successive global updates.
Federated Averaging
FedAvg extends this process by allowing clients to perform multiple local SGD steps before aggregation.
Instead of exchanging information after a single local gradient calculation, participants can update their models using several batches or epochs.
The server then combines the resulting models.
This reduces the number of communication rounds needed in the original FedAvg experiments, although the actual savings depend on the dataset, model, and training configuration.
The difference is not simply whether averaging occurs.
FedSGD aggregates information from a common model state after limited local computation. FedAvg allows more local optimization before combining the results.
That additional local computation is the source of both its communication advantage and its optimization challenges.
Communication Efficiency and Model Convergence
Communication is one of the most expensive operations in distributed training.
A client must receive model parameters, complete its assigned training, and transmit the required model information.
For large models, these exchanges can represent substantial network traffic.
FedAvg addresses this by performing more computation locally before the next exchange.
In their original 2017 research, McMahan and colleagues reported reductions of 10 to 100 times in required communication rounds compared with synchronized stochastic gradient descent across the experimental configurations they examined.
These results establish the potential value of local model averaging.
They do not mean every FedAvg deployment achieves the same reduction.
Client Drift and Data Differences
A central limitation appears when clients train on different statistical distributions.
Imagine a fraud detection model trained across three institutions.
One institution processes mostly retail transactions, another handles corporate payments, and the third serves international customers.
The local optimization steps reflect different patterns.
As training continues, the locally updated models can move in different directions.
This behavior is known as client drift.
Weighted averaging combines their parameters, but it does not eliminate the underlying differences between the client objectives.
Excessive local training can therefore reduce convergence stability.
We would evaluate the global model on validation data representing the intended deployment population rather than assuming that a lower local training loss means better shared performance.
Partial Client Participation
FedAvg does not require every registered client to participate in every round.
The server can select a subset of available clients and aggregate their successful updates.
In that case, the aggregation denominator must reflect the training examples represented by those contributing clients.
Using the total dataset size of all registered clients while excluding some of their updates would produce incorrect aggregation weights.
Client selection also affects which populations influence the model.
Repeatedly selecting only the most available participants can create a training population that does not adequately represent the intended users.
Participation design therefore belongs alongside optimizer settings in the evaluation plan.
FedAvg Implementation with Flower and TensorFlow
FedAvg is supported by established machine learning frameworks, making it possible to test the algorithm without developing an entire coordination system from scratch.
Flower
Flower provides a FedAvg strategy for coordinating federated training.
Its configuration supports client selection, training participation requirements, model aggregation, and evaluation.
The current server application interface also supports weighting model updates using a specified metric, with the number of examples as the default weight.
For an existing machine learning project, Flower provides a practical way to simulate multiple clients and examine the effect of training settings.
TensorFlow Federated
TensorFlow Federated provides APIs for defining federated computations and training processes.
Its tutorials demonstrate how local model updates are calculated and combined through federated aggregation.
The framework also supports working with model differences rather than transmitting complete updated parameter values.
For basic FedAvg with a shared starting model, averaging model differences and applying the aggregated change can produce the same mathematical update as averaging the resulting local models.
This distinction becomes useful when designing aggregation mechanisms that include clipping, compression, or additional optimization operations.
Validating an Implementation
Before moving to distributed infrastructure, we recommend verifying the aggregation logic with a small controlled experiment.
A useful test starts with known model parameters and client sample counts.
The expected weighted average is calculated independently.
The framework output is then compared against that result.
This confirms that aggregation weights and parameter ordering are correct before more complex training behavior is introduced.
A second test can examine whether changing local epochs produces the expected change in communication frequency and optimization behavior.
The implementation is ready for broader experimentation only after both aggregation correctness and model evaluation have been established.
Final Thoughts
The Federated Averaging Algorithm combines local model training with weighted aggregation to produce a shared model from distributed datasets.
Its value comes from allowing clients to complete several optimization steps before communicating with the server. That can reduce communication requirements, but it also makes the training process sensitive to local data distributions and parameter choices.
The most useful way to evaluate FedAvg is to begin with a verified aggregation calculation, establish an appropriate training baseline, and measure how changes in local epochs, client participation, and learning rate affect the final model.
FedAvg is more than a weighted average. Its effectiveness depends on the relationship between local optimization, client data, and global model performance.
FAQ
Can we add new clients after FedAvg training has already started?
Yes. New clients can participate in future training rounds after receiving the current global model and meeting the system's compatibility and participation requirements. Their contributions affect subsequent model updates according to the configured aggregation process.
What if a client trains on an older version of the global model?
Updates calculated from an outdated model should not be combined with the current round under standard synchronous FedAvg. The coordinating system must track model versions and reject incompatible updates or use a specifically designed method for delayed contributions.
Can one malicious client damage the global model?
Yes. A malicious participant can submit manipulated model parameters that reduce accuracy or introduce targeted behavior. Participant authentication, update validation, and suitable robust aggregation methods can reduce specific risks. Standard weighted averaging alone does not provide protection against malicious updates.
Can we remove a client's contribution after aggregation?
Excluding a client from future rounds does not remove its influence from a model that has already incorporated its updates. Removing that influence requires an appropriate retraining or validated model unlearning process.
Can we use the trained model without connecting to every client again?
Yes. Once the global model has been trained and deployed, it can perform inference independently of the clients that contributed to training, provided the required input features are available in the deployment environment. Further federated participation is necessary only when the model needs additional collaborative training.
Seen first.



