{'fraction_non_alphanumeric': 0.03713149650574343, 'fraction_numerical': 0.013434814041288457, 'mean_word_length': 4.392203573362209, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Clustered Scheduling and Communication Pipelining For Efficient Resource Management Of Wireless Federated Learning

This paper proposes using communication pipelining to enhance the wireless spectrum utilization efficiency and convergence speed of federated learning in mobile edge computing applications. Due to limited wireless sub-channels, a subset of the total clients is scheduled in each iteration of federated learning algorithms. On the other hand, the scheduled clients wait for the slowest client to finish its computation. We propose to first cluster the clients based on the time they need per iteration to compute the local gradients of the federated learning model. Then, we schedule a mixture of clients from all clusters to send their local updates in a pipelined manner. In this way, instead of just waiting for the slower clients to finish their computation, more clients can participate in each iteration. While the time duration of a single iteration does not change, the proposed method can significantly reduce the number of required iterations to achieve a target accuracy. We provide a generic formulation for optimal client clustering under different settings, and we analytically derive an efficient algorithm for obtaining the optimal solution. We also provide numerical results to demonstrate the gains of the proposed method for different datasets and deep learning architectures.


I. INTRODUCTION
Federated learning is a promising distributed machine learning approach in which a central server (coordinator) and a number of data-holding clients cooperate in the training of a common machine learning model without exchanging data [1]. Only model parameters are shared and updated using an iterative gradient descent algorithm. Hence, learning from private clients' data becomes possible while preserving the privacy of the clients'. Furthermore, federated learning enables achieving mutual benefits for all participating clients since training the algorithm using larger datasets by aggregating the private data of all participants leads to significant enhancements in the performance of data-hungry models. Moreover, federated learning enables better utilization of the distributed computational and storage resources. In particular, federated learning can be applied in mobile edge computing of wireless networks, e.g. [2], [3].
Research in federated learning has many aspects. One of them is exploring the variations among distributed gradientdescent training algorithms and analyzing the convergence performance of these algorithms with respect to the number of local and global iterations [4]. Another attractive research area is managing and optimizing the distributed computing and communication resources [5]. In particular, one of the main challenges in federated learning is the heterogeneity across the clients in terms of their computing and data resources. In this work, we focus on enhancing the utilization efficiency of wireless spectrum in federated learning. Consequently, enhancing the spectrum utilization leads to enhancing the prediction accuracy of the learning model at the end of the training process. Hence, achieving a target prediction accuracy becomes possible with a fewer number of iterations.
We propose using communication pipelining to enhance the spectrum utilization efficiency and speed up the convergence of federated learning. The primary motivation behind the proposed concept is that the computation time varies a lot between devices due to several reasons, such as different processor speeds or different sizes of the local dataset [6]. So, in an iterative gradient algorithm, the time of each iteration will be limited by the slowest client. To overcome this bottleneck, we propose that instead of just waiting for the slow clients to finish the computation of their local gradients, we can schedule an extra number of clients within the same iteration without requiring extra spectral bandwidth. A mixture of fast and slow clients should be scheduled in each iteration. The fast clients will use the spectrum first, while the slow clients are still running their computation of the local update. In this way, the number of clients who participate in each iteration can be increased while preserving the total duration of each iteration. So, the main idea is to cluster clients based on their computation time and then schedule a balanced mixture of clients from different clusters. The merit of this proposed concept is not necessarily in increasing the number of scheduled clients in each iteration but rather in allocating the wireless resources more efficiently. So, for example, fewer resources can be used while maintaining the number of clients per iteration.
In principle, pipelining is an added degree of freedom in the resource allocation problem that can be adequately utilized to adjust the trade-off between allocated resources and the number of clients to be scheduled to achieve the best outcome of the federated learning process.
It is essential to highlight that the proposed concept of pipelined federated learning (PFL) is a general concept that can be applied to any variation of the gradient descent algorithm, whether batch or stochastic, and for both primal or dual optimization methods. In this paper, we just show, as an example, the formulation for a primal method with client sampling in each iteration and one local iteration of fullgradient (batch) computation in each global iteration. We refer to this method as Clustered-Scheduling Gradient-Descent (CS-GD). The extension of the concept to other cases, such as having more local iterations per client, is straightforward as long as the needed computation time per client is quantified.

A. Related Work
The application of federated learning is discussed in several studies, such as [1], [7]- [9]. A seminal work on federated learning introducing the federated averaging algorithm is proposed in [1]. Federated averaging algorithm aggregates the updated local weights from each client in each global iteration. A comprehensive survey on federated learning is provided in [7], [8] by discussing the arising challenges, problems, and possible solutions regarding federated learning. The idea of federated learning is applied to the traffic prediction in [9].
In [10], the authors investigated the problem of client scheduling and resource block (RB) allocation to enhance the performance of model training using FL. In [11], the authors adopted FL in wireless networks as a resource allocation optimization problem that captures the trade-off between FL convergence wall clock time and energy consumption of UEs with heterogeneous computing and power resources. In [12], the authors proposed a novel over-the-air computation basedapproach for fast global model aggregation via exploring the superposition property of a wireless multiple-access channel. This is achieved by joint device selection and beamforming design using the difference of convex function representation. In the same direction, the authors of [13] proposed a novel digital version of broadband over-the-air aggregation, called one-bit broadband digital aggregation (OBDA), featuring onebit gradient quantization followed by digital quadrature amplitude modulation (QAM) at edge devices and over-the-air majority-voting based decoding at edge server.
Some other interesting works in the literature have considered the client scheduling problem, e.g. [14]- [19]. In [14], three practical scheduling policies, which are random scheduling, round Robin scheduling, and proportional fair scheduling, were compared. In [15], a probabilistic scheduling framework that considers both channel quality and local update importance was proposed. In [16], a multi-armed bandit-based framework was proposed for online client scheduling. In [17], scheduling based on a metric called "age of information" was proposed, and in [18], joint client scheduling and resource allocation was proposed. The training and wireless transmission parameters are jointly optimized in [20]. The works mentioned above do not take into consideration the variations in computational time among the clients. This is an essential factor to consider when scheduling the clients in order to avoid wasted time waiting for clients that need extended computing times. This is the main motivation for this work. The computational heterogeneity of the clients was considered in [19]. In this work, we develop the concept further by introducing client clustering and communication pipelining.

B. Contributions
We have three major contributions in this paper, which are summarized as follows: • We propose a novel federated learning concept PFL in which the communication for the model parameter updates is performed in a pipelined manner. The client updates in each round are pipelined by assigning the clients into clusters by their computation time. • We investigate the problem of optimal client clustering in a generic form that can be applicable to all particular scenarios. We show how to formulate the problem, and then we present rigorous analytical steps to derive an optimal and efficient algorithm to solve the problem. The solutions steps involve the change of variables step, Lagrangian dual-problem formulation, manipulations of the Karush-Kuhn-Tucker (KKT) necessary and sufficient conditions for optimality, hypothesis testing approach to find the active inequality constraints, and finally, an elegant geometric interpretation that helps in obtaining an efficient algorithm to solve the optimization problem. • We demonstrate the advantages of the proposed PFL using extensive numerical examples for different federated learning tasks. We compare the gain introduced by the proposed pipelining scheme compared to the conventional federated learning scheme using the MNIST [21], the federated EMNIST [22], and the federated Shakespeare [1], [23] datasets by employing a variety neural network architectures such as multi-layer perceptron (MLP), convolutional neural network (CNN), and recurrent neural network (RNN). The simulation results suggest that employing PFL decreases the number of communication rounds required to train a deep neural network.
The rest of the paper is organized as follows. The novel PFL scheme is introduced in Section II. A generic client clustering algorithm is proposed and solved in Section III. Extensive simulations are performed to validate the proposed method in Section IV. Finally, the conclusions are drawn in Section V. A summary of symbols and notations is provided in Table I.

II. PIPELINED FEDERATED LEARNING (PFL)
A typical federated learning problem is considered with a total of M clients participating in the optimization algorithm without sharing their own data sets. Each client has n m data samples, where m is the index of the client. The total number Nearest integer L Lagrangian λ k , ν Lagrangian dual variables of data samples is n = M m=1 n m . The goal is to minimize a loss function defined as: where p m = nm n , and where l(w, x i m , y i m ) is the loss function for the model and w, x i m , and y i m are the model weights, the input values, and the output values, respectively. The model training mechanism is based on a number T of iterations. In each iteration t, the server selects a sub-set of the total clients S[t] and broadcasts an updated model w[t] to the selected clients. The selected clients calculate the local gradient using their data samples and send the gradient to the server. A local gradient computation, at a given global round t, is based on averaging the gradient of all data points in the data set of the client: Then the server averages the gradients and updates the model according to: where η t > 0 is the learning rate in the t-th iteration. The uplink communication channel is considered to be an OFDM channel with a total of N sub-channels. So, at a given time, no more than N users can communicate with the server. Each sub-channel consists of multiple sub-carriers, and the data packets may cover multiple OFDM frames in order to fit the exchanged gradient data between the clients and the server. The number of gradients may be in the order of a million since the deep learning architectures usually have a large number of trainable variables. Furthermore, the total number of clients is assumed to be much larger than the number of sub-channels N ≪ M . Therefore, the server should randomly select a subset of the clients at each iteration based on the available communication resources (i.e., the number of sub-channels).
The computation time to obtain the local gradients varies among the clients for several reasons, such as different processor speeds and different computation loads. Note that the computation load to calculate (3) depends on the total number of local data samples n m . So, even if two clients have the same processor speed, a larger dataset will need a larger computation time than a client with a smaller dataset. This variation in computation time represents a practical consideration. On the other hand, since the packet size for communicating a local update to the server is the same across all clients (and it depends on the size of the gradient vector g), the communication time is considered to be the same for all clients. We know that wireless channels' quality differs among different users due to small-scale and large-scale fading. So, some studies in the literature have taken the channel quality into consideration in the selection of the clients per iteration [14], [15]. However, in this work, we do not want to compromise machine learning best practices for other advantages related to opportunistic communication in order to enhance transmission data rate. Hence, we design a system that can give all clients an almost equal chance to be selected. In particular, we aim to use the largest possible amount of data in training by involving all clients and learning a model that is not biased towards the data of only a subset of the clients who get selected more frequently than others. In our communication scheme, we assume that the communication over the sub-channels applies a fixed rate that is independent of the particularly selected user. We assume that the fixed transmission rate can be reliably decoded by all users. This is a common scheme in practical communication systems. The wireless channel data rate efficiency could be enhanced by applying adaptive modulation and coding based on the channel conditions. However, this is out of the scope of this manuscript. We denote the computation time for client m as τ m , the communication time of every client as τ com , and the combined time for the server to update the global model and broadcast it to the clients alongside information about the scheduled clients for next round as τ server . In order for the server to update the global model and broadcast the new model w[t] to the clients, it must wait for all local updates. So, the bottleneck will be to wait for the slowest client until it finishes its local computation. Therefore, the duration of one global iteration t is given as: τ m + τ com (6) and the total time to complete the whole training process over T iterations is given as: τ m (7) One might think of excluding the clients with large values of τ m to speed up the training process. However, this is not a good option since those clients are likely to be the clients with the largest datasets, and hence, their local updates have higher weights (i.e., they have higher importance). Furthermore, it is advantageous to involve more data samples in the training process in order to enhance the overall learning accuracy. So, client exclusion is not recommended. Instead, client scheduling in each global iteration should be based on random sampling so that each client gets a chance to be involved in each global iteration. On the other hand, just waiting for the slowest client to finish its computation is a waste of the valuable spectral resources since the utilization efficiency ǫ of the N uplink sub-channels will be In this work, we propose to enhance the spectrum utilization without the need to exclude any client by scheduling a mixture of slow and fast clients in each iteration and making them use the available channels in a pipelined manner. So, the clients are grouped into a number K of clusters based on their computation speed. More details about how to cluster the clients will be given in the next section. In each iteration, the server randomly samples N clients from each cluster. In this way, the total number of clients per iteration will be KN . The proposed PFL as illustrated in Fig. 1. The utilization efficiency of the wireless sub-channels based on our proposal becomes: Thus, PFL does not only produce a significant increase in the utilization efficiency of the spectrum resources, but it does also improve the performance of the learning algorithm since adding more clients in each iteration will make it converge faster into the globally optimal solution of (1). So, while PFL does not decrease the time per iteration (6), it can help to achieve a targeted accuracy level for solving (1) with less number of iterations T . So, it does indeed speed up the convergence performance of the learning algorithm. This will be demonstrated in the numerical examples section.

III. CLIENT CLUSTERING
Clients are grouped into K clusters, denoted as C 1 , C 2 , · · · , C K . Each client is placed in just one cluster. So, The computation time for a given cluster k is denoted as θ k . This represents the time duration given to the selected clients in the cluster to complete their gradient computations. Then, they synchronously get scheduled to access the communication channels at time θ k , for a communication duration τ com , as illustrated in Fig. 1.
Clustering the clients has some flexibility and it can be done in several ways. However, there are two strict constraints to be taken into consideration and two favorable, but not strict, requirements. First, all clients in a given cluster must satisfy the constraint that Furthermore, we have a constraint for scheduling the clusters into consequent communication frames. Assuming that the clusters are ordered in an ascending way based on their θ k , the constraint is given as A favorable, but not strict, requirement is to make the sizes of the clusters (i.e., number of clients) almost equal in order to give equal chance for all clients to participate in the training process. Hence, we have Another favorable requirement is to satisfy that in order to fully utilize the wireless resources to the maximum possible efficiency. The Clustered-Scheduling Gradient-Descent (CS-GD) algorithm is summarized in Algorithm 1. This is a generic algorithm that can be applied for any arbitrary client clustering method given that (10) and (11) are satisfied. Next, we elaborate on the optimization of clustering based on (12) while maintaining the other two constraints in (10) and (11).

A. Generic Optimization Problem Formulation
First, we sort the clients in ascending order of their computation time τ m , and assign the integer index S m for the order of client m. for cluster k = 1 to K do 3: Uniformly sample C k to obtain a set of N clients, denoted by S k [t] 4: Compute the gradient g m [t] according to (3) 7: Send gradient g m [t] to the server according to the pipeline timing θ k of its cluster 8: end for 9: end for 10: The server aggregates the gradients according to (4), and updates the model according to (5) By definition, T [S m ] is monotonically non-decreasing. Here, we would like to provide a generic optimization framework for client clustering that is applicable for any arbitrary monotonically non-decreasing T . Extension into some special cases will be straightforward. An example of special cases is the case when the computation time is uniformly distributed among the clients between τ min and τ max , which results in Next, we use the notation ω k to denote the index S m of the client that has the largest computation time among all clients in cluster C k . Hence, we have Based on the introduced notations for sorting the clients by their computation time, clustering the clients will be based on the following rule: where ω K = M , and ω 0 = 0. Based on (17), it is straightforward to show that |C k | = ω k − ω k−1 . Now, we can formulate the optimization problem to reduce the variance among the number of clients per cluster since it is favorable to have clusters with almost equal sizes, according to (12) where the constraint (18b) is based on (10). We do not need to include ω K as an optimization variable, but rather we added it as a constraint in (18c) to enforce the optimal solution to include all clients in the clustering method and do not exclude any client. Before we discuss the solution steps of (18), we will comment first on the selection of constrained thresholds θ k in (18b). First, introduce an extra hyper-parameter in the problem formulation to allow for some extra overall time that can be added at each global iteration. The added extra time is denoted by ∆ global , where ∆ global ≥ 0. The purpose of this added hyperparameter is to enable more flexibility in adjusting the number of clients per cluster and consequently to enable reducing the variations among the clusters' sizes. Furthermore, the extra time ∆ global can also be useful in enabling having a larger number of clusters K if needed. However, there is a tradeoff here since adding more time per iteration will reduce the spectrum utilization efficiency to become ǫ = Kτ com τ com + τ server + max τ m + ∆ global (19) We consider ∆ global and the total number of clusters K to be hyper-parameters that are set in advance before solving (18). The selection of ∆ global will affect the values of the thresholds θ k in the optimization problem constraint (18b). We can start by examining θ K of the last cluster, i.e., the one with largest computation time, which can be adjusted as θ K = τ max + ∆ global , and then we apply (11) with equality to adjust θ k for clusters K − 1, K − 2, · · · , 1 sequentially. As a result, we will have It should be noted that using the procedure mentioned above to adjust the values of the thresholds θ k in (20) aims at setting these thresholds at the maximum possible values in order to enlarge the space of feasible solutions of the main optimization problem (18), and hence, to enable achieving a lower value of the objective function (18a) at the optimal solution of the problem.
The upper bound of the possible number of clusters K can be obtained by setting θ 1 ≥ τ min , which can be simplified as τ max + ∆ global − (K − 1)τ com ≥ τ min . This inequality is equivalent to Furthermore, since the number of clusters is an integer, we can write where ⌊x⌋ is the floor (rounding to highest lower integer) of x.
The above upper bound of K is theoretically correct. However, it is not plausible in practice since it is based on assuming θ 1 ≥ τ min is satisfied at strict equality. This means that the first cluster will have just a single client that has the lowest computation time among all clients. This violates (12). Therefore, we alternatively prefer, from practical perspectives, to adjust K by reducing the upper bound by one, which gives

B. Optimal Solution
It is not straightforward to solve the primal optimization problem in (18) analytically since the objective function will have non-linear terms after expanding the square in (18a). Therefore, we propose here a change of variable step to transform the problem formulation into a convex optimization problem. We use the number of clients per cluster |C k |, denoted as M k , where k = 1, 2, . . . , K, as the optimization variables instead of ω k . Thus, M k = ω k − ω k−1 . Since the optimization variables M k are integers, we relax the problem into the continuous domain by replacing M k by δ k , which is a real number. The resulting reformulated optimization problem will be min δ1,...,δK where the thresholds π k satisfy π k = |{m : τ m ≤ θ k }|, which can be equivalently written as By solving (23) for M k , k = 1, . . . , K, we can then easily obtain ω k = k i=1 M i , for k = 1, . . . , K. Then, we can apply clustering using (17). Problem (23) is a convex optimization problem and it can be solved analytically. After obtaining δ k , k = 1, . . . , K, we can obtain M k for k = 1, . . . , K by rounding to the nearest integer. We can also directly obtain ω k (k = 1, . . . , K − 1) of the primal optimization problem (18) by using where [x] is the rounding operator to the nearest integer of x. It should be noted that rounding to lowest higher integer should not cause any concern regarding violating the inequality constraints in (23b) or equivalently in (18b), since the thresholds π k in (23b) are by definition integers. So, if k i=1 δ i is not an integer, rounding this summation to the lowest higher integer will also satisfy the constraint. When we obtain a relaxed (continuous-valued) number of clients per cluster, it is clear that the optimal value in the discrete domain should be by rounding the relaxed number of clients to the nearest integer. Any other value will give a higher variance. Furthermore, rounding to the lower or upper integer will give equal value. So, for example, if we have 7 users and want to distribute them into two groups. The optimal relaxed value will be 3.5 per group. If we round this value, we could have the first group has 4 and the second group has 3, or the first group has 3 and the second group has 4. Both solutions have exactly the same variance. So, in principle, rounding the nearest integer will always be optimal, although it may not be the unique optimal solution. The Lagrangian dual problem is given by min L(δ 1 , . . . , δ K , λ 1 , . . . , λ K−1 , ν) subject to λ i ≥ 0, ∀k ∈ {1, 2, . . . , K − 1}, where the Lagrangian L in (25a) can be written as where λ k (k = 1, . . . , K − 1) are the dual variables associated with the inequality constraints of the primal problem (23b), and ν is the dual variable associated with the equality constraint of the primal problem (23c). Based on the KKT necessary and sufficient conditions for optimality [24], the optimal solution of our problem must satisfy the following: 1) The primal equality constraint (23c), 2) The primal inequality constraints in (23b), which are K − 1 inequalities in total, 3) The dual constraints in (25b), which are also K − 1 inequalities, 4) The complementary slackness, given by which gives K equations in total.
Furthermore, since the problem is convex, the solution that satisfies all KKT conditions is unique. To solve this system of equations and equalities, we will first perform some analytical manipulations based on these conditions. Then, we will develop a hypothesis testing approach to get to the optimal solution in an efficient and quick way. Based on the KKT conditions, we can characterize the optimal solution as follows:

Lemma 1 (Primal Variables and Lagrangian Multipliers). The optimal solution must satisfy
Proof: From (28) we obtain which can be re-arranged to obtain Based on (30), and by evaluating δ k − δ k−1 , we obtain (29).

(31)
Proof: This is a direct consequence of Lemma 1 since the Lagrangian multipliers λ k are non-negative based on the dual constraint (25b).

Lemma 3 (Two Possibilities Per Complementary Slackness
Condition). The optimal solution must satisfy that either or Proof: From the complementary slackness conditions in (27), the optimal solution must satisfy that either λ k = 0, which results in (32a) by substituting for λ k = 0 in (29), or k i=1 δ i −π k = 0, which can be re-arranged as in (32b). These two possibilities correspond to satisfying the primal inequality constraints in (23b) at strict inequality in the first case or strict equality in the second case. The primal constraint in the latter case can be described as "active".

C. Hypothesis Testing Approach
The main bottleneck in solving (25) using the KKT conditions is that we cannot know in advance which inequality constraints will be active and which ones will be inactive at the optimal solution. All possibilities are likely in the generic problem formulation in which the thresholds π k (k = 1, . . . , K − 1) can take any arbitrary ordered values. So, to overcome this bottleneck, we propose a hypothesistesting approach to solve the KKT conditions. We can start by guessing which inequality constraints in (23b) will be active and which ones will be inactive. This will be a hypothesis that will be tested for validity. Based on the initial assumption of the hypothesis, we can then obtain all primal optimization variables δ k (k = 1, 2, . . . , K) based on (32a) and (32b) of Lemma 3, in addition to (23c). We will have K independent equations and K variables, so the solution of this system of equations will be unique. After we obtain the solution, we can check for the validity of the hypothesis by examining two things. First, we check that there is no contradiction in the hypothesis's initial assumption by examining if all primal inequality constraints that were assumed to be inactive are indeed inactive after we substitute the obtained values of δ k (k = 1, 2, . . . , K). Second, we check if the obtained δ k (k = 1, 2, . . . , K) satisfy (31) of Lemma 2. This check is for the optimality of the solution since the result in Lemma 2 is based on manipulations of the last KKT condition about vanishing gradient of the Lagrangian. So, in summary, we need to make sure that the hypothesis is both (i) non-contradicting and (ii) generating the unique optimal solution of the problem.
Since we have in total K −1 inequality constraints in (23b), we can have a maximum of 2 K−1 hypotheses to be tested. In a practical deployment scenario, the number of clusters K is assumed to be limited to a single-digit number. So, checking all possible hypotheses would not be a prohibitively expensive step in such scenarios. Having said that, we also propose a search algorithm to find the correct hypothesis quickly. This can be particularly useful for scenarios of large K. However, before discussing the search algorithm, we will give numerical examples of hypothesis testing to clarify the concept. Then, we will formulate the hypothesis testing procedure in a systematic way that can be implemented in an algorithm.
Example 1 (Three Scenarios of Hypothesis Testing). Assume that K = 4, M = 100, π 1 = 10, π 2 = 46, and π 3 = 80. We can distinguish between three cases: • Case A: Assuming that only the second inequality constraint is active is a contradicting hypothesis. • Case B: Assuming that only the first and second inequality constraints are active is a non-contradicting but not an optimal hypothesis. • Case C: Assuming that only the first inequality constraint is active is both a non-contradicting and optimal hypothesis.
In Case A, since the second inequality constraint is assumed to be active, we should use (32b) for k = 2, and use (32a) for k = 1 and k = 3. The system of four equations that should be solved is given as: The numerical solution of these equations yields δ 1 = δ 2 = 23, and δ 3 = δ 4 = 27. By checking the first inequality constraint, we will find a contradiction since δ 1 = 23 > π 1 = 10. So, this is a contradicting hypothesis. In Case B, we will have the same system of equations (33), but with replacing (33a) by δ 1 = π 1 . The solution of the system of four equations in this case yields δ 1 = 10, δ 2 = 36, and δ 3 = δ 4 = 27. By checking for all inequality constraints, we do not find any contradiction. However, this solution is not optimal since δ 2 = 36 > δ 3 = 27, and this violates the optimality condition (31) that was proven in Lemma 2.
Finally, in Case C, we will have (33a) replaced by δ 1 = π 1 , and (33b) replaced by δ 2 = δ 3 . The other two equations will be the same. The solution in this case yields δ 1 = 10, and δ 2 = δ 3 = δ 4 = 30. This solution does not violate any inequality constraint and satisfies the optimality check in (31). So, it is the optimal solution of the problem.
To formulate the hypothesis testing approach in a systematic algorithm, we use the notation h for a binary vector of K entries that indicates which primal inequality constraints are assumed to be active by the hypothesis. The final entry in h is for the equality constraint (23c), which is by definition always active. The entry of h that corresponds to the index k of an active constraint is given the value 1, and the entry that corresponds to the index of an inactive inequality is given the value 0. So, for Case A in the previous example we have h = (0, 1, 0, 1). For Case B, we have h = (1, 1, 0, 1), and for Case C, we have h = (1, 0, 0, 1). We also use the notation p(h) for a vector that is obtained from h by indicating the indices of the entries that have value 1. So, in our previous examples, if h = (0, 1, 0, 1), then p = (2,4), and if h = (1, 1, 0, 1), then p = (1, 2, 4), and if h = (1, 0, 0, 1), then p = (1, 4), and so on. It should be noted that while the number of entries of h is fixed at K, the number of entries in p(h) varies depending on the sum of all entries of the hypothesis h. Furthermore, we use the notation p (i) to indicate the i-th entry of p. So, for example, if p = (1, 2, 4), then p (1) = 1, p (2) = 2 and p (3) = 4.
Based on the introduced notations for h and p, we can obtain that for a given hypothesis h, the resulting system of equations to obtain δ k , k = 1, . . . , K, will have the following generalized formula to obtain the solution for any p(h): where j = 1, 2, . . . , |p|, p (0) = 0, π 0 = 0 and π K = M . Implementing (34) in an algorithm is straightforward by running a for-loop for the values of j, and obtaining all δ i 's that are associated with j in (34). After running through all j values, all δ i , i = 1, . . . , K will be obtained.

D. Quick Search Over Space Of Possible Hypotheses
To be able to find the non-contradicting and optimal hypothesis in the minimum number of steps, we need to make some theoretical characterization of the space of possible hypotheses so that we can exclude many possibilities directly and find the optimal solution in a quick search.
Theorem 1 (Inactive Primal Constraints). If π k in the k-th inequality constraint in (23b) satisfies then this constraint will be inactive at the optimal solution of the problem.
Proof: Assume that (35) is true and the k-th inequality constraint is active. The latter means If the solution is optimal, then we must have (31) satisfied as proven in Lemma 2. Thus, we must have δ k ≥ δ k−1 ≥ · · · ≥ δ 1 . Consequently, we must have that δ k ≥ π k k , which can be bounded based on (35) to have Furthermore, by simple manipulations of the equality constraint in (23c) with (36), we obtain If the solution is optimal, then we must have (31) satisfied, which yields δ K ≥ δ K−1 ≥ · · · ≥ δ k+1 . Consequently, we must have δ k+1 ≤ M−π k K−k , which can be bounded based on (35) to have From (37) and (39), we find that δ k > M K > δ k+1 . However, based on the optimality check in (31), we must have δ k+1 ≥ δ k . So, there is a contradiction. Thus, if (35) is true, then the associated constraint must be inactive at optimality.
The statement in Theorem 1 can help in excluding many hypotheses directly from the search algorithm. Furthermore, we can narrow the space of possible hypotheses even further based on the following theorem.
Theorem 2 (Generalized Check For Inactive Primal Constraints). Assume that we have any arbitrary two integers a and b such that 1 ≤ a < b ≤ K. If π k associated with the k-th inequality constraint in (23b) satisfies then this constraint will be inactive at the optimal solution of the problem.
Before presenting the proof, it should be noted that the statement in Theorem 2 is a generalized version of the statement in Theorem 1. The latter is a special case in which we have a = 0 and b = K, and similar to (34), we use the notation π 0 = 0 and π K = M .
Proof: Assume that both (40) is true and the k-th inequality constraint is active. The latter means that (36) and (38) are true as discussed in the proof of Theorem 1. Furthermore, we need to use the a-th and the b-th primal constraints in the construction of the proof. So, we have By simple manipulations of (36) and (41a), we obtain that k i=a+1 δ i ≥ π k − π a . Furthermore, if the solution is optimal, then we must have (31) satisfied. Thus, we must have δ k ≥ δ k−1 ≥ · · · ≥ δ a+1 . Consequently, we must have that δ k ≥ π k −πa k−a , which can be bounded based on (40) to have Next, we can do simple manipulations on the equality constraint in (23c) with (41b) to obtain that K i=b+1 δ i ≥ M −π b , which can be combined with (38) to obtain b i=k+1 δ i ≤ (M − π k ) − (M − π b ) = π b − π k . Moreover, if the solution is optimal, then we must have (31) satisfied, which yields δ b ≥ δ b−1 ≥ · · · ≥ δ k+1 . Consequently, we must have that Looking back at (40), we can re-write the inequality as π k > π a + k−a b−a (π b −π a ), which can be used to bound (43) as follows From (42) and (44), we find that δ k > π b −πa b−a > δ k+1 . However, based on the optimality check in (31), we must have δ k+1 ≥ δ k . So, there is a contradiction. Thus, if (40) is true, then the associated constraint must be inactive at optimality.
Actually, we can adopt a geometric interpretation of Theorem 2 as shown in Fig. 2, since the left term of the inequality in (40) is the slope of the line connecting the two points (a, π a ) and (k, π k ), while the right term is the slope of the line connecting the two points (a, π a ) and (b, π b ). Thus, we can equivalently reinterpret Theorem 2 as stating that the k-th inequality constraint will be inactive at the optimal solution if the point (k, π k ) is located above the line segment that connects the two points (a, π a ) and (b, π b ). This statement is true for any value of a < k and any value of b > k. Hence, we can establish a nice geometric interpretation of our problem. Actually, finding the active inequality constraints can be interpreted as finding the lower convex hull in a two-dimensional Cartesian coordinate system for the set of inequality thresholds, represented as: Furthermore, the active constraints are only those that are located on the vertices of the piecewise linear boundary of the lower convex hull of P, as illustrated in Fig. 3, which shows a numerical example of P = {(0, 0), (1,10), (2,46), (3,80), (4, 100)}. This particular P is related to the previously discussed Example 1. As shown in Fig. 3, the point (1, 10) is a vertex in the boundary of the lower convex hull of P, while the points (2, 46) and (3, 80) are not located on the boundary of the lower convex hull. Thus, the first constraint should be active at the optimal solution, while the second and third constraints should be inactive. This conclusion was already verified in Example 1. So, the geometric interpretation is consistent with the analytical algebraic derivations.
The significance of the geometric interpretation is that it enables us to define an efficient and quick procedure to find the optimal solution by searching for the boundary of the lower convex hull of P of our problem. This can be done sequentially segment-by-segment starting from the lower-left corner point

4:
Use the obtained b * to set the output values

IV. PERFORMANCE ANALYSIS AND COMPARISON
In this section, as a numerical example, we compare the performance of a conventional federated learning scheme (in which N clients are randomly selected per iteration t regardless of their number of data samples) with our suggested PFL scheme (which follows Algorithm 1 and the solution in Algorithm 2). We analyze the proposed PFL method using different datasets such as the MNIST [21], the federated EMNIST [22], and the federated Shakespeare [1], [23] datasets and neural network architectures such as MLP, CNN, and RNN to cover a wide range of federated learning applications from the literature. We used Python programming language and Tensorflow Federated framework [25] for the simulations.
Without loss of generality, we assume a scenario in which all clients have similar processors' speeds, and the variation in computation time τ m is solely dependent on the number of data sample per client, i.e., τ m = σn m , where σ is the computation time per data sample.

A. MNIST Dataset
First, we have validated the proposed method using the MNIST dataset [21], which consists of hand-written digits. In the simulation scenario, we assumed that there are M = 1500 clients. We assumed that the number of data samples (i.e., images of hand-written digits) per client n m is uniformly distributed between n min = 10 samples and n max = 70 samples. We compared the results of PFL to the conventional federated learning scheme where there is only one cluster. We considered four possible scenarios for the ratio between the variation in computation time to communication time in (22). We performed the simulations for 1, 2, 3, and 4 clusters, respectively. We also studied the effect of the number of subchannels on the performance of PFL. Hence, we varied the number of sub-channels as 1, 2, 4, and 8, respectively. Each sub-channel can be used by a single client only at a given time instant. We used two different deep learning models for the training of the MNIST dataset. The first model is a twolayer CNN model with 32 and 64 5 × 5 filters, respectively. The second model is an MLP model with two layers with 200 nodes in each layer. We run the training algorithm for up to 1000 rounds of global model (server) updates. We obtained the model prediction accuracy by testing the trained model on a separate test dataset as a function of the number of communication rounds. The batch size is chosen as 16, and the number of local epochs is set to 1. The client learning rate is optimized using a multiplicative parameter grid, and the server learning rate (the scaling factor) is set to 1. The number of required rounds to reach 97% accuracy for the CNN model trained on the MNIST dataset is shown in Table II. Similarly, the number of required rounds to reach 96% accuracy for the MLP model trained on the MNIST dataset is shown in Table III.
As seen in Table II and Table III, applying clustered scheduling enables achieving faster convergence (in terms of the number of iterations) in comparison with a baseline federated learning approach with no clustering. The conventional federated learning scheme with the CNN model achieves 97% accuracy in 273, 180, 152, and 118 rounds with 1, 2, 4, and 8 sub-channels, respectively. The proposed PFL scheme provides 32% gain compared to the conventional federated learning scheme in terms of required rounds by employing only 2 clusters. The gain provided by clustering is improved for each  additional cluster in the system. The marginal gain provided by the PFL scheme decreases with the increasing number of sub-channels since the effective number of data samples per communication round is already enough for the conventional federated learning. The benefit of the proposed clustered pipelining scheme can be realized in a different way by decreasing the bandwidth requirements. Thus, we can decrease the number of subchannels needed to achieve the desired accuracy value. For instance, by using 4 clusters with 1 sub-channel, we reach the same performance as the one achieved by the conventional federated learning with 4 sub-channels.
The MLP model converges slower compared to the CNN model. The conventional federated learning scheme achieves 96% accuracy in 981, 767, 528, and 445 rounds with 1, 2, 4, and 8 sub-channels, respectively. Similar to the results with the CNN model, introducing clustering into the federated learning setup decreases the number of required training rounds significantly. However, the PFL method provides little to no gain compared to the conventional federated learning scheme if the number of sub-channels is high, e.g., if the number of sub-channels is 8 in our simulation setup.

B. Federated EMNIST Dataset
In this section, we use the extended version of the MNIST dataset, namely, EMNIST [22]. We use the federated EMNIST dataset in which the data is already distributed to the clients by their writing styles. The EMNIST dataset has letters additionally; however, we will use only the digits dataset. The federated EMNIST digits dataset has a total of 341, 873 train and 40, 832 test samples distributed among 3, 383 clients. There are 10 classes in the dataset, each corresponding to a hand-written digit. The data distribution among the clients is shown in Fig. 4. As seen from Fig. 4, the distribution of the number of data samples among the clients is unbalanced and not uniform. We formulate the client clustering problem as shown in (23) for clustering the clients for the federated EMNIST dataset, and then we solve the problem efficiently using Algorithm 2. Accordingly, in the training step, we first cluster the clients using the proposed optimization problem. Then, we train the model using the PFL scheme. We performed the simulations for 1, 2, 3, and 4 clusters and 1, 2, 4, and 8 subchannels, respectively. We used a two-layer CNN model with 32 and 64 5 × 5 filters as the neural network model. The batch size is chosen as 16, and the learning rate is optimized using a multiplicative parameter grid. The number of local epochs is chosen as 1 in order to assess the convergence speed. The required number of rounds to achieve 97% accuracy for the EMNIST digits dataset is given in Table IV.   The number of communication rounds required is 686 for the 1 sub-channel and 1 cluster case. The number of communication rounds drops by 64% to 274 rounds by introducing 1 additional cluster. The number of communication rounds gets lower and lower with the increasing number of clusters. The gain from the proposed PFL scheme decreases if the number of available sub-channels increases. Therefore, we could conclude that the proposed scheme may not be feasible if the number of sub-channels is sufficiently large, e.g., more than 4 sub-channels in this case. As seen from Table IV, the model converges faster for a higher number of clusters in the system. However, the marginal gain obtained by each additional cluster decreases with the number of clusters already present in the system.

C. Federated Shakespeare Dataset
For modeling time-series data, we used federated Shakespeare dataset [1], [23] for training a stacked two-layer long short-term memory (LSTM) network. Federated Shakespeare dataset is built by combining all works of Shakespeare. The dataset consists of the speaking roles of 715 characters in each play, corresponding to the clients in our federated learning setup. The dataset is unbalanced since most of the plays have a few lines, and a small number of clients have a high count of lines in their plays. Additionally, the number of data samples is not distributed uniformly to the clients. It is also clear that the dataset is not independent identically distributed (i.i.d.) since the dataset is distributed to the clients according to the played character. We use Algorithm 2 for determining the clusters for the clients. Then, we train the model using the proposed PFL scheme. The neural network model used for this task has an embedding layer at the input, which embeds the input characters into an 8 dimensional space. After the embedding layer, it has two LSTM layers with 256 hidden nodes. Finally, it has an output layer with softmax activation with an output for each character. In training, we set the batch size to be 10 and optimized the learning rate through a multiplicative parameter grid. The simulation results for the application of PFL for the training of the two-layer LSTM network on the Shakespeare dataset are given in Table V. The rows represent the number of clusters, and the columns represent the number of sub-channels. The values are given in terms of the number of rounds required to reach 40% accuracy in the training. By examining the simulation results for both federated the EMNIST and the Shakespeare datasets, we conclude that the proposed pipelining scheme improves the results for nonuniformly distributed data more significantly. V. CONCLUSIONS One of the main challenges of federated learning is the heterogeneity across the participating clients in terms of their computation duration and the size of the local data set. To mitigate this challenge, we have proposed using communication pipelining to enhance the spectrum utilization efficiency and speed up the convergence of federated learning. The main idea is to cluster clients based on their computation time and then schedule a balanced mixture of clients from the different clusters. The faster clients access the spectrum first, while the slower clients are still running their computation. By allowing more clients to be involved in each iteration, the time required to converge into a targeted prediction accuracy of the trained model can be reduced significantly. The time per iteration does not change in comparison with conventional federated learning. Nevertheless, the required number of iterations and the total time to train the model are reduced. We provided a generic formulation for the optimal client clustering under different settings and an efficient algorithm for obtaining the optimal solution. We demonstrated that the required number of communication rounds also depends on the number of subchannels, and the gain obtained from the proposed method is lower for a high number of sub-channels.