## 4 The DecantFed Algorithm
### Summary of DecantFed
The reason for having staleness in DecantFed is that clients in high tiers may train their local models based on outdated global models. To further mitigate the model staleness problem in DecantFed, we adopt the method in [31] to set up different learning rates for the clients in different tiers, i.e., \[\delta_{j}=\min(\delta_{1}\times\max(\log_{\alpha}j,1),0.1)\] (14) where \(\delta_{j}\) is the learning rate of the clients in tier \(j\), \(\delta_{1}\) is the learning rate of the clients in tier \(1\), and \(\alpha\) (\(\alpha>1\)) is a hyperparameter to adjust the changes in learning rates among tiers. Note that both \(\delta_{1}\) and \(\alpha\) are given before the FL training starts. Basically, Equation (14) indicates that clients in a higher tier would have a larger learning rate (i.e., \(\delta_{j+1}\geq\delta_{j}\)) to update their local models more aggressively such that these clients can catch up with the model update speed of the clients in the lower tiers. Note that Equation (14) also ensures that \(\delta_{j}\) is less than 0.1 to avoid the clients in higher tiers overshooting the optimal model that minimizes the loss function. Once the learning rate is determined, client \(i\) updates its local model based on the gradient descent method, i.e.,  
\[\mathbf{\omega}_{i,l}^{local}(t+1) =\mathbf{\omega}_{i,l}^{local}(t)-\sum_{j\in\mathcal{J}}\delta_{j}x_{ ij}\] \[\times\
abla f\left(\mathbf{\omega}_{i,l}^{local}(t);a_{i,n},b_{i,n} \right), \tag{15}\]  
where \(\mathbf{\omega}_{i,l}^{local}(t)\) is the local model of client \(j\) during the \(t\) and \(t-1\) local iterations, respectively, in the \(l^{th}\) global iteration, \((a_{i,n},b_{i,n})\) is the input-output pair for client \(i^{\prime}\)s \(n^{th}\) data sample, \(\sum_{j\in\mathcal{J}}\delta_{j}x_{ij}\) implies the learning rate of client \(i\), and \(f\left(\mathbf{\omega}_{i,l}^{local}(t);a_{i,n},b_{i,n}\right)\) is the loss function of the model given the model parameter \(\mathbf{\omega}_{i,l}^{local}(t)\) and data sample \((a_{i,n},b_{i,n})\). A typical loss function that has been widely applied in image classification is cross-entropy loss. 2. **Clipping the loss function values**. Owing to the non-IID and dynamic workload optimization, the data samples in a client could be highly uneven. For example, a client has one thousand images labeled as dogs but only two images labeled as cats. If this client has high computing capability and the FL server would assign a high workload in terms of training a machine-learning model to classify dogs and cats by selecting all the images for many epochs, then the local model may overfit the client's local dataset. After being trained by numerous dog images, the local model may diverge if a cat image is fed into the local model to generate an excessive loss value. For example, if the loss function is defined as the cross-entropy loss, then the loss function is \(-\log(\epsilon)\rightarrow\infty\), where \(\epsilon\to 0\) is the probability of labeling the image as a cat by the local model. Infinite loss values lead to large backpropagation gradients, which can subsequently turn both weights and biases into 'NaN'. Although regularization methods can reduce the variance of model updates, especially in IID scenarios, they cannot resolve the infinite loss issues that normally happen when the data distribution is highly non-IID. In such cases, loss clipping serves as an effective and computationally efficient solution to constrain model update, clipping the loss value into a reasonable range, i.e.,  
\[f\left(\mathbf{\omega}_{i,l}^{local}(t);a_{i,n},b_{i,n}\right):=\min\Bigl{\{}f \left(\mathbf{\omega}_{i,l}^{local}(t);a_{i,n},b_{i,n}\right),\zeta\Bigr{\}}, \tag{16}\]  
where \(\zeta\) is a hyperparameter that defines the maximum loss function value.