## 4 The DecantFed Algorithm
### Summary of DecantFed  
The DecantFed algorithm is summarized in Algorithm 2. Specifically, the FL server performs the following steps: (1) Obtains the states in terms of channel gain \(g_{i}\), CPU frequency \(f_{i}\), and transmission power \(p_{i}\) of all the clients; (2) Calculates the bandwidth allocation \(\mathbf{b}\) and client clustering \(\mathbf{x}\) based on LEAD in Algorithm 1 as well as the workload \(\mathbf{d}\) by using Simplex method to solve \(\mathbf{P2}\); (3) Broadcasts the workload assignment \(\mathbf{d}\), bandwidth allocation \(\mathbf{b}\), client clustering \(\mathbf{x}\), deadline \(\tau\), and the initial global model to all the clients such that all the clients can understand their local training configurations; (4) Conducts FL training for a number of global iterations. Here, in the \(l^{th}\) global iteration, the FL server only collects models from the clients whose tiers are participating in training during the \(l^{th}\) global iteration. That is, if \(l\%j==0\), then tier \(j\) is participating in training during the \(l^{th}\) global iteration. Let \(\mathbf{\mathcal{K}}_{l}\) denote the set of the clients that are participating in the training during the \(l^{th}\) global iteration, i.e., \(\mathbf{\mathcal{K}}_{l}=\{i|\forall i\in\mathbf{\mathcal{I}},\forall j\in\mathbf{ \mathcal{J}},l\%j==0\ \&\&\ x_{ij}==1\}\). Oncethe FL server receives the local models from all the clients in \(\mathcal{K}_{l}\), it then updates the global model based on  
\[\mathbf{\omega}_{l}^{global}=\sum_{i\in\mathcal{K}_{l}}\frac{|\mathbf{\mathcal{D}}_{i}|}{ \sum_{k\in\mathcal{K}_{l}}|\mathbf{\mathcal{D}}_{k}|}\mathbf{\omega}_{i,l}^{local}\,, \tag{13}\]  
where \(\mathbf{\omega}_{i,l}^{local}\) is the local model uploaded from client \(i\) in the \(l^{th}\) global iteration, \(\mathbf{\omega}_{l}^{global}\) is the global model derived in the \(l^{th}\) global iteration, \(\mathbf{\mathcal{D}}_{i}\) is the local dataset of client \(i\), and \(|\mathbf{\mathcal{D}}_{i}|\) is the total number of samples in \(\mathbf{\mathcal{D}}_{i}\). Once the FL server has updated the global model \(\mathbf{\omega}_{l}^{global}\) based on (13), it broadcasts \(\mathbf{\omega}_{l}^{global}\) to the clients in \(\mathcal{K}_{l}\) and then initializes the next global iteration. ```
1 At the FL server:
2 Obtain states of all clients, i.e., \(\forall i\in\mathbf{\mathcal{I}}\), \(g_{i}\), \(f_{i}\), \(p_{i}\)
3 Derive \(\mathbf{b}\) and \(\mathbf{x}\) by executing the LEAD algorithm. 4 Derive \(\mathbf{d}\) by applying the Simplex to solve \(\mathbf{P2}\). 5 Broadcast the workload assignment \(\mathbf{d}\), bandwidth allocation \(\mathbf{b}\), client clustering \(\mathbf{x}\), deadline \(\tau\), and the initial global model to all the clients. 6 forachglobal iteration \(l\)do
7 Receive local models from the clients in \(\mathcal{K}_{l}\);
8 Update the global model \(\mathbf{\omega}_{l}\) based on Equation (13);
9 Broadcast the updated global model \(\mathbf{\omega}_{l}\) to the clients in \(\mathcal{K}_{l}\);
10
11 end for
12
13 end for
14 At each client:
15 Receive \(\mathbf{d}\), \(\mathbf{b}\), \(\mathbf{x}\), \(\tau\), and the initial global model to understand the local training configuration. 16 Calculate the learning rate based on Equation (14). 17 whilea new global model is receiveddo
18 Train its local model over \(d_{i}\) samples based on Equations (15) and (16);
19 Upload its local model to the FL server;
20
21 end while
22
23 end while
```  
**Algorithm 2**DecantFed algorithm  
In DecantFed, each client trains the received global model based on its \(d_{i}\) number of local samples. However, the local training may have the following: (1) The model staleness problem due to the semi-synchronous nature; (2) The model divergence problem due to the non-IID and workload optimization. Here, we apply the following solutions to tackle the model staleness and divergence problems. 1. **Dynamic learning rate**. Similar to asynchronous FL, the model staleness problem may also exist in DecantFed, although it is mitigated.