Year: 2020

Abstract:
Federated learning involves training statistical models in massive, heterogeneous networks. Naively minimizing an aggregate loss function in such a network may disproportionately advantage or disadvantage some of the devices. In this work, we propose q-Fair Federated Learning (q-FFL), a novel optimization objective inspired by fair resource allocation in wireless networks that encourages a more fair (specifically, a more uniform) accuracy distribution across devices in federated networks. To solve q-FFL, we devise a communication-efficient method, q-FedAvg, that is suited to federated networks. We validate both the effectiveness of q-FFL and the efficiency of q-FedAvg on a suite of federated datasets with both convex and non-convex models, and show that q-FFL (along with q-FedAvg) outperforms existing baselines in terms of the resulting fairness, flexibility, and efficiency.

heading: 1 INTRODUCTION
text: Federated learning is an attractive paradigm for fitting a model to data generated by, and residing on, a network of remote devices (McMahan et al., 2017). Unfortunately, naively minimizing an aggregate loss in a large network may disproportionately advantage or disadvantage the model performance on some of the devices. For example, although the accuracy may be high on average, there is no accuracy guarantee for individual devices in the network. This is exacerbated by the fact that the data are often heterogeneous in federated networks both in terms of size and distribution, and model performance can thus vary widely. In this work, we therefore ask: Can we devise an efficient federated optimization method to encourage a more fair (i.e., more uniform) distribution of the model performance across devices in federated networks?
There has been tremendous recent interest in developing fair methods for machine learning (see, e.g., Cotter et al., 2019; Dwork et al., 2012). However, current approaches do not adequately address concerns in the federated setting. For example, a common definition in the fairness literature is to enforce accuracy parity between protected groups1 (Zafar et al., 2017a). For devices in massive federated networks, however, it does not make sense for the accuracy to be identical on each device given the significant variability of data in the network. Recent work has taken a step towards addressing this by introducing good-intent fairness, in which the goal is instead to ensure that the training procedure does not overfit a model to any one device at the expense of another (Mohri et al., 2019). However, the proposed objective is rigid in the sense that it only maximizes the performance of the worst performing device/group, and has only be tested in small networks (for 2-3 devices). In realistic federated learning applications, it is natural to instead seek methods that can flexibly trade off between overall performance and fairness in the network, and can be implemented at scale across hundreds to millions of devices.
In this work, we propose q-FFL, a novel optimization objective that addresses fairness issues in federated learning. Inspired by work in fair resource allocation for wireless networks, q-FFL minimizes an aggregate reweighted loss parameterized by q such that the devices with higher loss are given higher relative weight. We show that this objective encourages a device-level definition
1While fairness is typically concerned with performance between “groups”, we define fairness in the federated setting at a more granular scale in terms of the devices in the network. We note that devices may naturally combine to form groups, and thus use these terms interchangeably in the context of prior work.
of fairness in the federated setting, which generalizes standard accuracy parity by measuring the degree of uniformity in performance across devices. As a motivating example, we examine the test
Increasing the accuracy of the worst-performing devices
Through extensive experiments on federated datasets with both convex and non-convex models, we demonstrate the fairness and flexibility of q-FFL and the efficiency of q-FedAvg compared with existing baselines. In terms of fairness, q-FFL is able to reduce the variance of accuracies across devices by 45% on average while maintaining the same overall average accuracy. In terms of efficiency, our distributed method, q-FedAvg, is capable of solving the proposed objective orders-ofmagnitude more quickly than other baselines. Finally, while we consider our approaches primarily in the context of federated learning, we also demonstrate that q-FFL can be applied to other related problems such as meta-learning, helping to produce fair initializations across multiple tasks.

heading: 2 RELATED WORK
text: Fairness in Resource Allocation. Fair resource allocation has been extensively studied in fields such as network management (Ee & Bajcsy, 2004; Hahne, 1991; Kelly et al., 1998; Neely et al., 2008) and wireless communications (Eryilmaz & Srikant, 2006; Nandagopal et al., 2000; Sanjabi et al., 2014; Shi et al., 2014). In these contexts, the problem is defined as allocating a scarce shared resource, e.g., communication time or power, among many users. In these cases, directly maximizing utilities such as total throughput may lead to unfair allocations where some users receive poor service. As a service provider, it is important to improve the quality of service for all users while maintaining overall throughput. For this reason, several popular fairness measurements have been proposed to balance between fairness and total throughput, including Jain’s index (Jain et al., 1984), entropy (Rényi et al., 1961), max-min/min-max fairness (Radunovic & Le Boudec, 2007), and proportional fairness (Kelly, 1997). A unified framework is captured through α-fairness (Lan et al., 2010; Mo & Walrand, 2000), in which the network manager can tune the emphasis on fairness by changing a single parameter, α.
To draw an analogy between federated learning and the problem of resource allocation, one can think of the global model as a resource that is meant to serve the users (or devices). In this sense, it is natural to ask similar questions about the fairness of the service that users receive and use similar tools to promote fairness. Despite this, we are unaware of any works that use α-fairness from resource allocation to modify objectives in machine learning. Inspired by the α-fairness metric, we propose a similarly modified objective, q-Fair Federated Learning (q-FFL), to encourage a more fair accuracy distribution across devices in the context of federated training. Similar to the α-fairness metric, our q-FFL objective is flexible enough to enable trade-offs between fairness and other traditional metrics such as accuracy by changing the parameter q. In Section 4, we show empirically that the use of q-FFL as an objective in federated learning enables a more uniform accuracy distribution across devices—significantly reducing variance while maintaining the average accuracy.
Fairness in Machine Learning. Fairness is a broad topic that has received much attention in the machine learning community, though the goals often differ from that described in this work. Indeed,
fairness in machine learning is typically defined as the protection of some specific attribute(s). Two common approaches are to preprocess the data to remove information about the protected attribute, or to post-process the model by adjusting the prediction threshold after classifiers are trained (Feldman, 2015; Hardt et al., 2016; Calmon et al., 2017). Another set of works optimize an objective subject to some fairness constraints during training time (Agarwal et al., 2018; Cotter et al., 2019; Hashimoto et al., 2018; Woodworth et al., 2017; Baharlouei et al., 2020; Zafar et al., 2017a;b; Dwork et al., 2012). Our work also enforces fairness during training, although we define fairness as the uniformity of the accuracy distribution across devices in federated learning (Section 3), as opposed to the protection of a specific attribute. Although some works define accuracy parity to enforce equal error rates among specific groups as a notion of fairness (Zafar et al., 2017a; Cotter et al., 2019), devices in federated networks may not be partitioned by protected attributes, and our goal is not to optimize for identical accuracy across all devices. Cotter et al. (2019) use a notion of ‘minimum accuracy’, which is conceptually similar to our goal. However, it requires one optimization constraint for each device, which would result in hundreds to millions of constraints in federated networks.
In federated settings, Mohri et al. (2019) recently proposed a minimax optimization scheme, Agnostic Federated Learning (AFL), which optimizes for the performance of the single worst device. This method has only been applied at small scales (for a handful of devices). Compared to AFL, our proposed objective is more flexible as it can be tuned based on the desired amount of fairness; AFL can in fact be seen as a special case of our objective, q-FFL, with large enough q. In Section 4, we demonstrate that the flexibility of our objective results in more favorable accuracy vs. fairness trade-offs than AFL, and that q-FFL can also be solved at scale more efficiently.
Federated Optimization. Federated learning faces challenges such as expensive communication, variability in systems environments in terms of hardware or network connection, and non-identically distributed data across devices (Li et al., 2019). In order to reduce communication and tolerate heterogeneity, optimization methods must be developed to allow for local updating and low participation among devices (McMahan et al., 2017; Smith et al., 2017). We incorporate these key ingredients when designing methods to solve our q-FFL objective efficiently in the federated setting (Section 3.3).

heading: 3 FAIR FEDERATED LEARNING
text: In this section, we first formally define the classical federated learning objective and methods, and introduce our proposed notion of fairness (Section 3.1). We then introduce q-FFL, a novel objective that encourages a more fair (uniform) accuracy distribution across all devices (Section 3.2). Finally, in Section 3.3, we describe q-FedAvg, an efficient distributed method to solve the q-FFL objective in federated settings.
3.1 PRELIMINARIES: FEDERATED LEARNING, FEDAVG , AND FAIRNESS
Federated learning algorithms involve hundreds to millions of remote devices learning locally on their device-generated data and communicating with a central server periodically to reach a global consensus. In particular, the goal is typically to solve:
min w f(w) = m∑ k=1 pkFk(w) , (1)
where m is the total number of devices, pk ≥ 0, and ∑ k pk = 1. The local objective Fk’s can be
defined by empirical risks over local data, i.e., Fk(w) = 1nk ∑nk jk=1
ljk(w), where nk is the number of samples available locally. We can set pk to be nkn , where n = ∑ k nk is the total number of samples to fit a traditional empirical risk minimization-type objective over the entire dataset.
Most prior work solves (1) by sampling a subset of devices with probabilities pk at each round, and then running an optimizer such as stochastic gradient descent (SGD) for a variable number of iterations locally on each device. These local updating methods enable flexible and efficient communication compared to traditional mini-batch methods, which would simply calculate a subset of the gradients (Stich, 2019; Wang & Joshi, 2018; Woodworth et al., 2018; Yu et al., 2019). FedAvg (McMahan et al., 2017), summarized in Algorithm 3 in Appendix C.1, is one of the leading methods to solve (1) in non-convex settings. The method runs simply by having each selected device apply E epochs of SGD locally and then averaging the resulting local models.
Unfortunately, solving problem (1) in this manner can implicitly introduce highly variable performance between different devices. For instance, the learned model may be biased towards devices with larger numbers of data points, or (if weighting devices equally), to commonly occurring devices. More formally, we define our desired fairness criteria for federated learning below.
Definition 1 (Fairness of performance distribution). For trained models w and w̃, we informally say that model w provides a more fair solution to the federated learning objective (1) than model w̃ if the performance of model w on the m devices, {a1, . . . am}, is more uniform than the performance of model w̃ on the m devices.
In this work, we take ‘performance’, ak, to be the testing accuracy of applying the trained model w on the test data for device k. There are many ways to mathematically evaluate the uniformity of the performance. In this work, we mainly use the variance of the performance distribution as a measure of uniformity. However, we also explore other uniformity metrics, both empirically and theoretically, in Appendix A.1. We note that a tension exists between the fairness/uniformity of the final testing accuracy and the average testing accuracy across devices. In general, our goal is to impose more fairness/uniformity while maintaining the same (or similar) average accuracy.
Remark 2 (Connections to other fairness definitions). Definition 1 targets device-level fairness, which has finer granularity than the classical attribute-level fairness such as accuracy parity (Zafar et al., 2017a). We note that in certain cases where devices can be naturally clustered into groups with specific attributes, our definition can be seen as a relaxed version of accuracy parity, in that we optimize for similar but not necessarily identical performance across devices.
3.2 THE OBJECTIVE: q-FAIR FEDERATED LEARNING (q-FFL)
A natural idea to achieve fairness as defined in (1) would be to reweight the objective—assigning higher weights to devices with poor performance, so that the distribution of accuracies in the network shifts towards more uniformity. Note that this reweighting must be done dynamically, as the performance of the devices depends on the model being trained, which cannot be evaluated a priori. Drawing inspiration from α-fairness, a utility function used in fair resource allocation in wireless networks, we propose the following objective. For given local non-negative cost functions Fk and parameter q > 0, we define the q-Fair Federated Learning (q-FFL) objective as:
min w fq(w) = m∑ k=1 pk q + 1 F q+1k (w) , (2)
where F q+1k (·) denotes Fk(·) to the power of (q+1). Here, q is a parameter that tunes the amount of fairness we wish to impose. Setting q = 0 does not encourage fairness beyond the classical federated learning objective (1). A larger q means that we emphasize devices with higher local empirical losses, Fk(w), thus imposing more uniformity to the training accuracy distribution and potentially inducing fairness in accordance with Definition 1. Setting fq(w) with a large enough q reduces to classical minimax fairness (Mohri et al., 2019), as the device with the worst performance (largest loss) will dominate the objective. We note that while the (q+1) term in the denominator in (2) may be absorbed in pk, we include it as it is standard in the α-fairness literature and helps to ease notation. For completeness, we provide additional background on α-fairness in Appendix B.
As mentioned previously, q-FFL generalizes prior work in fair federated learning (AFL) (Mohri et al., 2019), allowing for a flexible trade-off between fairness and accuracy as parameterized by q. In our theoretical analysis (Appendix A), we provide generalization bounds of q-FFL that generalize the learning bounds of the AFL objective. Moreover, based on our fairness definition (Definition 1), we theoretically explore how q-FFL results in more uniform accuracy distributions with increasing q. Our results suggest that q-FFL is able to impose ‘uniformity’ of the test accuracy distribution in terms of various metrics such as variance and other geometric and information-theoretic measures.
In our experiments (Section 4.2), on both convex and non-convex models, we show that using the q-FFL objective, we can obtain fairer/more uniform solutions for federated datasets in terms of both the training and testing accuracy distributions.
3.3 THE SOLVER: FEDAVG-STYLE q-FAIR FEDERATED LEARNING (q-FEDAVG)
In developing a functional approach for fair federated learning, it is critical to consider not only what objective to solve but also how to solve such an objective efficiently in a massive distributed network. In this section, we provide methods to solve q-FFL. We start with a simpler method, q-FedSGD, to illustrate our main techniques. We then provide a more efficient counterpart, q-FedAvg, by considering local updating schemes. Our proposed methods closely mirror traditional distributed optimization methods—mini-batch SGD and federated averaging (FedAvg)—but with step-sizes and subproblems carefully chosen in accordance with the q-FFL problem (2).
Achieving variable levels of fairness: tuning q. In devising a method to solve q-FFL (2), we begin by noting that it is crucial to first determine how to set q. In practice, q can be tuned based on the desired amount of fairness (with larger q inducing more fairness). As we describe in our experiments (Section 4.2), it is therefore common to train a family of objectives for different q values so that a practitioner can explore the trade-off between accuracy and fairness for the application at hand.
One concern with solving such a family of objectives is that it requires step-size tuning for every value of q. In particular, in gradient-based methods, the step-size inversely depends on the Lipschitz constant of the function’s gradient, which will change as we change q. This can quickly cause the search space to explode. To overcome this issue, we propose estimating the local Lipschitz constant for the family of q-FFL objectives by using the Lipschitz constant we infer by tuning the step-size (via grid search) on just one q (e.g., q = 0). This allows us to dynamically adjust the step-size of our gradient-based optimization method for the q-FFL objective, avoiding manual tuning for each q. In Lemma 3 below we formalize the relation between the Lipschitz constant, L, for q = 0 and q > 0. Lemma 3. If the non-negative function f(·) has a Lipschitz gradient with constant L, then for any q ≥ 0 and at any point w,
Lq(w) = Lf(w) q + qf(w)q−1‖∇f(w)‖2 (3)
is an upper-bound for the local Lipschitz constant of the gradient of 1q+1f q+1(·) at point w. Proof. At any point w, we can compute the Hessian∇2 (
1 q+1f
q+1(w) ) as:
∇2 ( 1
q + 1 fq+1(w) ) = qfq−1(w)∇f(w)∇T f(w)︸ ︷︷ ︸
‖∇f(w)‖2×I +fq(w)∇2f(w)︸ ︷︷ ︸ L×I . (4)
As a result, ‖∇2 1q+1f q+1(w)‖2 ≤ Lq(w) = Lf(w)q + qf(w)q−1‖∇f(w)‖2.
A first approach: q-FedSGD. Our first fair federated learning method, q-FedSGD, is an extension of the well-known federated mini-batch SGD (FedSGD) method (McMahan et al., 2017). q-FedSGD uses a dynamic step-size instead of the normal fixed step-size of FedSGD. Based on Lemma 3, for each local device k, the upper-bound of the local Lipschitz constant is LFk(w) q + qFk(w) q−1‖∇Fk(w)‖2. In each step of q-FedSGD, ∇Fk and Fk on each selected device k are computed at the current iterate and communicated to the central node. This information is used to compute the step-sizes (weights) for combining the updates from each device. The details are summarized in Algorithm 1. Note that q-FedSGD is reduced to FedSGD when q = 0. It is also important to note that to run q-FedSGD with different values of q, we only need to estimate L once by tuning the step-size on q = 0 and can then reuse it for all values of q > 0.
Improving communication-efficiency: q-FedAvg. In federated settings, communication-efficient schemes using local stochastic solvers (such as FedAvg) have been shown to significantly improve convergence speed (McMahan et al., 2017). However, when q > 0, the F q+1k term is not an empirical average of the loss over all local samples due to the q + 1 exponent, preventing the use of local SGD as in FedAvg. To address this, we propose to generalize FedAvg for q > 0 using a more sophisticated dynamic weighted averaging scheme. The weights (step-sizes) are inferred from the upper bound of the local Lipschitz constants of the gradients of F q+1k , similar to q-FedSGD. To extend the local updating technique of FedAvg to the q-FFL objective (2), we propose a heuristic where we replace the gradient∇Fk in the q-FedSGD steps with the local updates that are obtained by running SGD locally on device k. Similarly, q-FedAvg is reduced to FedAvg when q = 0. We
Algorithm 1 q-FedSGD
1: Input: K, T , q, 1/L, w0, pk, k = 1, · · · ,m 2: for t = 0, · · · , T − 1 do 3: Server selects a subset St of K devices at random (each device k is chosen with prob. pk) 4: Server sends wt to all selected devices 5: Each selected device k computes:
∆tk = F q k (w t)∇Fk(wt) htk = qF q−1 k (w t)‖∇Fk(wt)‖2 + LF qk (w t)
6: Each selected device k sends ∆tk and h t k back to the server 7: Server updates wt+1 as: wt+1 = wt − ∑ k∈St ∆ t k∑
k∈St h t k
8: end for
Algorithm 2 q-FedAvg
1: Input: K, E, T , q, 1/L, η, w0, pk, k = 1, · · · ,m 2: for t = 0, · · · , T − 1 do 3: Server selects a subset St of K devices at random (each device k is chosen with prob. pk) 4: Server sends wt to all selected devices 5: Each selected device k updates wt for E epochs of SGD on Fk with step-size η to obtain w̄t+1k 6: Each selected device k computes:
∆wtk = L(w t − w̄t+1k ) ∆tk = F q k (w t)∆wtk htk = qF q−1 k (w t)‖∆wtk‖2 + LF q k (w t)
7: Each selected device k sends ∆tk and h t k back to the server 8: Server updates wt+1 as: wt+1 = wt − ∑ k∈St ∆ t k∑
k∈St h t k
9: end for
provide additional details on q-FedAvg in Algorithm 2. As we will see empirically, q-FedAvg can solve q-FFL objective much more efficiently than q-FedSGD due to the local updating heuristic. Finally, recall that as q →∞ the q-FFL objective recovers that of the AFL. However, we empirically notice that q-FedAvg has a more favorable convergence speed compared to AFL while resulting in similar performance across devices (see Figure 9 in the appendix).

heading: 4 EVALUATION
text: We now present empirical results of the proposed objective, q-FFL, and proposed methods, q-FedAvg and q-FedSGD. We describe our experimental setup in Section 4.1. We then demonstrate the improved fairness of q-FFL in Section 4.2, and compare q-FFL with several baseline fairness objectives in Section 4.3. Finally, we show the efficiency of q-FedAvg compared with q-FedSGD in Section 4.4. All code, data, and experiments are publicly available at github.com/litian96/fair_flearn.

heading: 4.1 EXPERIMENTAL SETUP
text: Federated datasets. We explore a suite of federated datasets using both convex and non-convex models in our experiments. The datasets are curated from prior work in federated learning (McMahan et al., 2017; Smith et al., 2017; Li et al., 2020; Mohri et al., 2019) as well as recent federated learning benchmarks (Caldas et al., 2018). In particular, we study: (1) a synthetic dataset using a linear regression classifier, (2) a Vehicle dataset collected from a distributed sensor network (Duarte & Hu, 2004) with a linear SVM for binary classification, (3) tweet data curated from Sentiment140 (Go et al., 2009) (Sent140) with an LSTM classifier for text sentiment analysis, and (4) text data built
from The Complete Works of William Shakespeare (McMahan et al., 2017) and an RNN to predict the next character. When comparing with AFL, we use the two small benchmark datasets (Fashion MNIST (Xiao et al., 2017) and Adult (Blake, 1998)) studied in Mohri et al. (2019). When applying q-FFL to meta-learning, we use the common meta-learning benchmark dataset Omniglot (Lake et al., 2015). Full dataset details are given in Appendix D.1.
Implementation. We implement all code in Tensorflow (Abadi et al., 2016), simulating a federated network with one server and m devices, where m is the total number of devices in the dataset (Appendix D.1). We provide full details (including all hyperparameter values) in Appendix D.2.
4.2 FAIRNESS OF q-FFL
In our first experiments, we verify that the proposed objective q-FFL leads to more fair solutions (Definition 1) for federated data. In Figure 2, we compare the final testing accuracy distributions of two objectives (q = 0 and a tuned value of q > 0) averaged across 5 random shuffles of each dataset. We observe that while the average testing accuracy remains fairly consistent, the objectives with q > 0 result in more centered (i.e., fair) testing accuracy distributions with lower variance. In particular, while maintaining roughly the same average accuracy, q-FFL reduces the variance of accuracies across all devices by 45% on average. We further report the worst and best 10% testing accuracies and the variance of the final accuracy distributions in Table 1. Comparing q = 0 and q > 0, we see that the average testing accuracy remains almost unchanged with the proposed objective despite significant reductions in variance. We report full results on all uniformity measurements (including variance) in Table 5 in the appendix, and show that q-FFL encourages more uniform accuracies under other metrics as well. We observe similar results on training accuracy distributions in Figure 6 and Table 6, Appendix E. In Table 1, the average accuracy is with respect to all data points, not all devices; however, we observe similar results with respect to devices, as shown in Table 7, Appendix E.
Choosing q. As discussed in Section 3.3, a natural question is to determine how q should be tuned in the q-FFL objective. Our framework is flexible in that it allows one to choose q to tradeoff between fairness/uniformity and average accuracy. We empirically show that there are a family of q’s that can result in variable levels of fairness (and accuracy) on synthetic data in Table 11, Appendix E. In general, this value can be tuned based on the data/application at hand and the desired amount of fairness. Another reasonable approach in practice would be to run Algorithm 2 with multiple q’s in parallel to obtain multiple final global models, and then select amongst these based on performance (e.g., accuracy) on the validation data. Rather than using just one optimal q for all devices, for example, each device could pick a device-specific model based on their validation data. We show additional performance improvements with this device-specific strategy in Table 12 in Appendix E. Finally, we note that one potential issue is that increasing the value of q may slow the speed of convergence. However, for values of q that result in more fair results on our datasets, we do not observe significant decrease in the convergence speed, as shown in Figure 8, Appendix E.

heading: 4.3 COMPARISON WITH OTHER OBJECTIVES
text: Next, we compare q-FFL with other objectives that are likely to impose fairness in federated networks. One heuristic is to weight each data point equally, which reduces to the original objective in (1) (i.e., q-FFL with q = 0) and has been investigated in Section 4.2. We additionally compare with two alternatives: weighting devices equally when sampling devices, and weighting devices adversarially, namely, optimizing for the worst-performing device, as proposed in Mohri et al. (2019).
Weighting devices equally. We compare q-FFL with uniform sampling schemes and report testing accuracy in Figure 3. A table with the final accuracies and three fairness metrics is given in the appendix in Table 9. While the ‘weighting each device equally’ heuristic tends to outperform our method in training accuracy distributions (Figure 7 and Table 8 in Appendix E), we see that our method produces more fair solutions in terms of testing accuracies. One explanation for this is that uniform sampling is a static method and can easily overfit to devices with very few data points, whereas q-FFL will put less weight on a device once its loss becomes small, potentially providing better generalization performance due to its dynamic nature.
Weighting devices adversarially. We further compare with AFL (Mohri et al., 2019), which is the only work we are aware of that aims to address fairness issues in federated learning. We implement a non-stochastic version of AFL where all devices are selected and updated each round, and perform grid search on the AFL hyperparameters, γw and γλ. In order to devise a setup that is as favorable to AFL as possible, we modify Algorithm 2 by sampling all devices and letting each of them run gradient descent at each round. We use the same small datasets (Adult (Blake, 1998) and subsampled Fashion MNIST (Xiao et al., 2017)) and the same logistic regression model as in Mohri et al. (2019). Full details of the implementation and hyperparameters (e.g., values of q1 and q2) are provided in Appendix D.2.3. We note that, as opposed to AFL, q-FFL is flexible depending on the amount of fairness desired, with larger q leading to more accuracy uniformity. As discussed, q-FFL generalizes AFL in this regard, as AFL is equivalent to q-FFL with a large enough q. In Table 2, we observe that q-FFL can in fact achieve higher testing accuracy than AFL on the device with the worst performance (i.e., the problem that the AFL was designed to solve) with appropriate q. This also indicates that q-FFL obtains the most fair solutions in certain cases. We also observe that q-FFL converges faster
in terms of communication rounds compared with AFL to obtain similar performance (Appendix E), which we speculate is due to the non-smoothness of the AFL objective.
4.4 EFFICIENCY OF THE METHOD q-FEDAVG
In this section, we show the efficiency of our proposed distributed solver, q-FedAvg, by comparing Algorithm 2 with its non-local-updating baseline q-FedSGD (Algorithm 1) to solve the same objective (same q > 0 as in Table 1). At each communication round, we have each method perform the same amount of computation, with q-FedAvg running one epoch of local updates on each selected device while q-FedSGD runs gradient descent with the local training data. In Figure 4, q-FedAvg converges faster than q-FedSGD in terms of communication rounds in most cases due to its local updating scheme. The slower convergence of q-FedAvg compared with q-FedSGD on the synthetic dataset may be due to the fact that when local data distributions are highly heterogeneous, local updating schemes may allow local models to move too far away from the initial global model, potentially hurting convergence; see Figure 10 in Appendix E for more details.
To demonstrate the optimality of our dynamic step-size strategy in terms of solving q-FFL, we also compare our solver q-FedSGD with FedSGD with a best-tuned step-size. For q-FedSGD, we tune a step-size on q = 0 and apply that step-size to solve q-FFL with q > 0. q-FedSGD has similar performance with FedSGD, which indicates that (the inverse of) our estimated Lipschitz constant on q > 0 is as good as a best tuned fixed step-size. We can reuse this estimation for different q’s instead of manually re-tuning it when q changes. We show the full results on other datasets in Appendix E. We note that both proposed methods q-FedAvg and q-FedSGD can be easily integrated into existing implementations of federated learning algorithms such as TensorFlow Federated (TFF).
4.5 BEYOND FEDERATED LEARNING: APPLYING q-FFL TO META-LEARNING
Finally, we generalize the proposed q-FFL objective to other learning tasks beyond federated learning. One natural extension is to apply q-FFL to meta-learning, where each task can be viewed as a device in federated networks. The goal of meta-learning is to learn a model initialization such that it can be quickly adapted to new tasks using limited training samples. However, as the new tasks can be heterogeneous, the performance distribution of the final personalized models may also be non-uniform. Therefore, we aim to learn a better initialization such that it can quickly solve unseen tasks in a fair manner, i.e., reduce the variance of the accuracy distribution of the personalized models.
To achieve this goal, we propose a new method, q-MAML, by combining q-FFL with the popular metalearning method MAML (Finn et al., 2017). In particular, instead of updating the global model in the way described in MAML, we update the global parameters using the gradients of the q-FFL objective
1 q+1F q+1 k (w), with weights inferred from Lemma 3. Similarly, q-MAML with q = 0 reduces to MAML, and q-MAML with q → ∞ corresponds to MAML with a most ‘fair’ initialization and a potentially lower average accuracy. The detailed algorithm is summarized in Algorithm 4 in Appendix C.2. We sample 10 tasks at each round during meta-training, and train for 5 iterations of (mini-batch) SGD for personalization on meta-testing tasks. We report test accuracy of personalized models on the meta-testing tasks. From Figure 5 and Table 3 above, we observe that q-MAML is able to learn initializations which result in fairer personalized models with lower variance.

heading: 5 CONCLUSION
text: In this work, we propose q-FFL, a novel optimization objective inspired by fair resource allocation in wireless networks that encourages fairer (more uniform) accuracy distributions across devices in federated learning. We devise a scalable method, q-FedAvg, to solve this objective in massive networks. Our empirical evaluation on a suite of federated datasets demonstrates the resulting fairness and flexibility of q-FFL, as well as the efficiency of q-FedAvg compared with existing baselines. We show that our framework is useful not only for federated learning tasks, but also for other learning paradigms such as meta-learning.

heading: ACKNOWLEDGMENTS
text: We thank Sebastian Caldas, Chen Dan, Neel Guha, Anit Kumar Sahu, Eric Tan, and Samuel Yeom for their helpful discussions and comments. The work of TL and VS was supported in part by the National Science Foundation grant IIS1838017, a Google Faculty Award, a Carnegie Bosch Institute Research Award, and the CONIX Research Center. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the National Science Foundation or any other funding agency.

heading: A.2 GENERALIZATION BOUNDS
text: In this section, we first describe the setup we consider in more detail, and then provide generalization bounds of q-FFL. One benefit of q-FFL is that it allows for a flexible trade-off between fairness and accuracy, which generalizes AFL (a special case of q-FFL with q →∞). We also provide learning bounds that generalize the bounds of the AFL objective, as described below.
Suppose the service provider is interested in minimizing the loss over a distributed network of devices, with possibly unknown weights on each device:
Lλ(h) = m∑ k=1 λkE(x,y)∼Dk [l(h(x), y)], (29)
where λ is in a probability simplex Λ,m is the total number of devices,Dk is the local data distribution for device k, h is the hypothesis function, and l is the loss. We use L̂λ(h) to denote the empirical
loss:
L̂λ(h) = m∑ k=1 λk nk nk∑ j=1 l(h(xk,j), yk,j), (30)
where nk is the number of local samples on device k and (xk,j , yk,j) ∼ Dk. We consider a slightly different, unweighted version of q-FFL:
min w
fq(w) = 1
m m∑ k=1 F q+1k (w) , (31)
which is equivalent to minimizing the empirical loss
L̃q(h) = max ν,‖ν‖p≤1 m∑ k=1 νi nk nk∑ j=1 l(h(xk,j), yk,j), (32)
where 1p + 1 q+1 = 1 (p ≥ 1, q ≥ 0).
Lemma 12 (Generalization bounds of q-FFL for a specific λ). Assume that the loss l is bounded by M > 0 and the numbers of local samples are (n1, · · · , nm). Then, for any δ > 0, with probability at least 1− δ, the following holds for any λ ∈ Λ, h ∈ H:
Lλ(h) ≤ Aq(λ)L̃q(h) + E [ max h∈H Lλ(h)− L̂λ(h) ] +M √√√√ m∑ k=1 λ2k 2nk log 1 δ , (33)
where Aq(λ) = ‖λ‖p, and 1/p+ 1/(q + 1) = 1.
Proof. Similar to the proof in Mohri et al. (2019), for any δ > 0, the following inequality holds with probability at least 1− δ for any λ ∈ Λ, h ∈ H:
Lλ(h) ≤ L̂λ(h) + E [ max h∈H Lλ(h)− L̂λ(h) ] +M √√√√ m∑ k=1 λ2k 2nk log 1 δ . (34)
Denote the empirical loss on device k 1nk ∑nk j=1 l(h(xk,j), yk,j) as Fk. From Hölder’s inequality, we have
L̂λ(h) = m∑ k=1 λkFk ≤ ( m∑ k=1 λpk ) 1 p ( m∑ k=1 F q+1k ) 1 q+1 = Aq(λ)L̃q(h), 1 p + 1 q + 1 = 1.
Plugging L̂λ(h) ≤ Aq(λ)L̃q(h) into (34) yields the results.
Theorem 13 (Generalization bounds of q-FFL for any λ). Assume that the loss l is bounded by M > 0 and the number of local samples is (n1, · · · , nm). Then, for any δ > 0, with probability at least 1− δ, the following holds for any λ ∈ Λ, h ∈ H:
Lλ(h) ≤ max λ∈Λ (Aq(λ)) L̃q(h) + max λ∈Λ E [max h∈H Lλ(h)− L̂λ(h) ] +M √√√√ m∑ k=1 λ2k 2nk log 1 δ  , (35) where Aq(λ) = ‖λ‖p, and 1/p+ 1/(q + 1) = 1.
Proof. This directly follows from Lemma 12, by taking the maximum over all possible λ’s in Λ. Discussions. From Lemma 12, letting λ = (
1 m , · · · , 1 m
) and q →∞, we recover the generalization
bounds in AFL (Mohri et al., 2019). In that sense, our generalization results extend those of AFL’s. In addition, it is not straightforward to derive an optimal q with the tightest generalization bound from Lemma 12 and Theorem 13. In practice, our proposed method q-FedAvg allows us to tune a family of q’s by re-using the step-sizes.
B α-FAIRNESS AND q-FFL
As discussed in Section 2, while it is natural to consider the α-fairness framework for machine learning, we are unaware of any work that uses α-fairness to modify machine learning training objectives. We provide additional details on the framework below; for further background on αfairness and fairness in resource allocation more generally, we defer the reader to Shi et al. (2014); Mo & Walrand (2000).
α-fairness (Lan et al., 2010; Mo & Walrand, 2000) is a popular fairness metric widely-used in resource allocation problems. The framework defines a family of overall utility functions that can be derived by summing up the following function of the individual utilities of the users in the network:
Uα(x) =
{ ln(x), if α = 1
1 1−αx 1−α, if α ≥ 0, α 6= 1 .
Here Uα(x) represents the individual utility of some specific user given x allocated resources (e.g., bandwidth). The goal is to find a resource allocation strategy to maximize the sum of the individual utilities. This family of functions includes a wide range of popular fair resource allocation strategies. In particular, the above function represents zero fairness with α = 0, proportional fairness (Kelly, 1997) with α = 1, harmonic mean fairness (Dashti et al., 2013) with α = 2, and max-min fairness (Radunovic & Le Boudec, 2007) with α = +∞. Note that in federated learning, we are dealing with costs and not utilities. Thus, max-min in resource allocation corresponds to min-max in our setting. With this analogy, it is clear that in our proposed objective q-FFL (2), the case where q = +∞ corresponds to min-max fairness since it is optimizing for the worst-performing device, similar to what was proposed in Mohri et al. (2019). Also, q = 0 corresponds to zero fairness, which reduces to the original FedAvg objective (1). In resource allocation problems, α can be tuned for trade-offs between fairness and system efficiency. In federated settings, q can be tuned based on the desired level of fairness (e.g., desired variance of accuracy distributions) and other performance metrics such as the overall accuracy. For instance, in Table 2 in Section 4.3, we demonstrate on two datasets that as q increases, the overall average accuracy decreases slightly while the worst accuracies are increased significantly and the variance of the accuracy distribution decreases.

heading: C PSEUDO-CODE OF ALGORITHMS
text: C.1 THE FEDAVG ALGORITHM
Algorithm 3 Federated Averaging McMahan et al. (2017) (FedAvg)
Input: K, T , η, E, w0, N , pk, k = 1, · · · , N for t = 0, · · · , T − 1 do
Server randomly chooses a subset St of K devices (each device k is chosen with probability pk) Server sends wt to all chosen devices Each device k updates wt for E epochs of SGD on Fk with step-size η to obtain wt+1k Each chosen device k sends wt+1k back to the server Server aggregates the w’s as wt+1 = 1
K ∑ k∈St w t+1 k
end for
C.2 THE q-MAML ALGORITHM
Algorithm 4 q-FFL applied to MAML: q-MAML
1: Input: K, T , η, w0, N , pk, k = 1, · · · , N 2: for t = 0, · · · , T − 1 do 3: Sample a batch of St (|St| = K) tasks randomly (each task k is chosen with probability pk) 4: Send wt to all sampled tasks 5: Each task k ∈ St samples data Dk from the training set and D′k from the testing set, and
computes updated parameters on D: wtk = w t − η∇Fk(wt)
6: Each task k ∈ St computes the gradients∇Fk(wtk) on D′ 7: Each task k ∈ St computes:
∆tk = F q k (w t k)∇Fk(wtk) htk = qF q−1 k (w t k)‖∇Fk(wtk)‖2 + LF q k (w t k)
8: wt+1 is updated as:
wt+1 = wt − ∑ k∈St ∆ t k∑
k∈St h t k
9: end for

heading: D EXPERIMENTAL DETAILS

heading: D.1 DATASETS AND MODELS
text: We provide full details on the datasets and models used in our experiments. The statistics of four federated datasets used in federated learning (as opposed to meta-learning) experiments are summarized in Table 4. We report the total number of devices, the total number of samples, and mean and deviation in the sizes of total data points on each device. Additional details on the datasets and models are described below.
• Synthetic: We follow a similar set up as that in Shamir et al. (2014) and impose additional heterogeneity. The model is y = argmax(softmax(Wx+b)), x ∈ R60,W ∈ R10×60, b ∈ R10, and the goal is to learn a global W and b. Samples (Xk, Yk) and local models on each device k satisfies Wk ∼ N (uk, 1), bk ∼ N (uk, 1), uk ∼ N (0, 1); xk ∼ N (vk,Σ), where the covariance matrix Σ is diagonal with Σj,j = j−1.2. Each element in vk is drawn fromN (Bk, 1), Bk ∼ N (0, 1). There are 100 devices in total and the number of samples on each devices follows a power law.
• Vehicle2: We use the same Vehicle Sensor (Vehicle) dataset as Smith et al. (2017), modelling each sensor as a device. This dataset consists of acoustic, seismic, and infrared sensor data collected from a distributed network of 23 sensors Duarte & Hu (2004). Each sample has a 100-dimension feature and a binary label. We train a linear SVM to predict between AAV-type and DW-type vehicles. We tune the hyperparameters in SVM and report the best configuration.
• Sent140: This dataset is a collection of tweets curated from 1,101 accounts from Sentiment140 (Go et al., 2009) (Sent140) where each Twitter account corresponds to a device. The task is text sentiment analysis which we model as a binary classification problem. The model takes as input a 25-word sequence, embeds each word into a 300-dimensional space using pretrained Glove (Pennington et al., 2014), and outputs a binary label after two LSTM layers and one densely-connected layer.
• Shakespeare: This dataset is built from The Complete Works of William Shakespeare (McMahan et al., 2017). Each speaking role in the plays is associated with a device. We subsample 31 speaking roles to train a deep language model for next character prediction. The model takes as input an 80-character sequence, embeds each character into a learnt 8-dimensional space, and outputs one character after two LSTM layers and one densely-connected layer.
• Omniglot: The Omniglot dataset (Lake et al., 2015) consists of 1,623 characters from 50 different alphabets. We create 300 meta-training tasks from the first 1,200 characters, and 100 meta-testing tasks from the last 423 characters. Each task is a 5-class classification problem where each character forms a class. The model is a convolutional neural network with two convolution layers and two fully-connected layers.
D.2 IMPLEMENTATION DETAILS

heading: D.2.1 MACHINES
text: We simulate the federated setting (one server and m devices) on a server with 2 Intel R© Xeon R© E5-2650 v4 CPUs and 8 NVidia R© 1080Ti GPUs.
2http://www.ecs.umass.edu/~mduarte/Software.html

heading: D.2.2 SOFTWARE
text: We implement all code in TensorFlow (Abadi et al., 2016) Version 1.10.1. Please see github.com/litian96/fair_flearn for full details.

heading: D.2.3 HYPERPARAMETERS
text: We randomly split data on each local device into 80% training set, 10% testing set, and 10% validation set. We tune a best q from {0.001, 0.01, 0.1, 0.5, 1, 2, 5, 10, 15} on the validation set and report accuracy distributions on the testing set. We pick up the q value where the variance decreases the most, while the overall average accuracy change (compared with the q = 0 case) is within 1%. For each dataset, we repeat this process for five randomly selected train/test/validation splits, and report the mean and standard deviation across these five runs where applicable. For Synthetic, Vehicle, Sent140, and Shakespeare, optimal q values are 1, 5, 1, and 0.001, respectively. For all datasets, we randomly sample 10 devices each round. We tune the learning rate and batch size on FedAvg and use the same learning rate and batch size for all q-FedAvg experiments of that dataset. The learning rates for Synthetic, Vehicle, Sent140, and Shakespeare are 0.1, 0.01, 0.03, and 0.8, respectively. The batch sizes for Synthetic, Vehicle, Sent140, and Shakespeare are 10, 64, 32, and 10. The number of local epochs E is fixed to be 1 for both FedAvg and q-FedAvg regardless of the values of q.
In comparing q-FedAvg’s efficiency with q-FedSGD, we also tune a best learning rate for q-FedSGD methods on q = 0. For each comparison, we fix devices selected and mini-batch orders across all runs. We stop training when the training loss F (w) does not decrease for 10 rounds. When running AFL methods, we search for a best γw and γλ such that AFL achieves the highest testing accuracy on the device with the highest loss within a fixed number of rounds. For Adult, we use γw = 0.1 and γλ = 0.1; for Fashion MNIST, we use γw = 0.001 and γλ = 0.01. We use the same γw as step-sizes for q-FedAvg on Adult and Fashion MNIST. In Table 2, q1 = 0.01, q2 = 2 for q-FFL on Adult and q1 = 5, q2 = 15 for q-FFL on Fashion MNIST. Similarly, the number of local epochs is fixed to 1 whenever we perform local updates.

heading: E FULL EXPERIMENTS

heading: E.1 FULL RESULTS OF PREVIOUS EXPERIMENTS
text: Fairness of q-FFL under all uniformity metrics. We demonstrate the fairness of q-FFL in Table 1 in terms of variance. Here, we report similar results in terms of other uniformity measures (the last two columns).
Fairness of q-FFL with respect to training accuracy. The empirical results in Section 4 are with respect to testing accuracy. As a sanity check, we show that q-FFL also results in more fair training accuracy distributions in Figure 6 and Table 6.
Average testing accuracy with respect to devices. In Section 4.2, we show that q-FFL leads to more fair accuracy distributions while maintaining approximately the same testing accuracies. Note that we report average testing accuracy with respect to all data points in Table 1. However, we observe similar results on average accuracy with respect to all devices between q = 0 and q > 0 objectives, as shown in Table 7. This indicates that q-FFL can reduce the variance of the accuracy distribution without sacrificing the average accuracy over devices or over data points.
Comparison with uniform sampling. In Figure 7 and Table 8, we show that in terms of training accuracies, the uniform sampling heuristic may outperform q-FFL (as opposed to the testing accuracy results in Section 4). We suspect that this is because the uniform sampling baseline is a static method and is likely to overfit to those devices with few samples. In additional to Figure 3 in Section 4.3, we also report the average testing accuracy with respect to data points, best 10%, worst 10% accuracies, and the variance (along with two other uniformity measures) in Table 9.

heading: E.2 ADDITIONAL EXPERIMENTS
text: Effects of data heterogeneity and the number of devices on unfairness. To study how data heterogeneity and the total number of devices affect unfairness in a more direct way, we investigate into a set of synthetic datasets where we can quantify the degree of heterogeneity. The results are shown in Table 10 below. We generate three synthetic datasets following the process described in Appendix D.1, but with different parameters to control heterogeneity. In particular, we generate an IID data— Synthetic (IID) by setting the same W and b on all devices and setting the samples xk ∼ N (0, 1) for any device k. We instantiate two non-identically distributed datasets (Synthetic (1, 1) and Synthetic (2, 2)) from Synthetic (α, β) where uk ∼ N (0, α) and Bk ∼ N (0, β). Recall that α, β allows to precisely manipulate the degree of heterogeneity with larger α, β values indicating more statistical heterogeneity. Therefore, from top to bottom in Table 10, data are more heterogeneous. For each dataset, we further create two variants with different number of participating devices. We see that as data become more heterogeneous and as the number of devices in the network increases, the accuracy distribution tends to be less uniform.
A family of q’s results in variable levels of fairness. In Table 11, we show the accuracy distribution statistics of using a family of q’s on synthetic data. Our objective and methods are not sensitive to any particular q since all q > 0 values can lead to more fair solutions compared with q = 0. In our experiments in Section 4, we report the results using the q values selected following the protocol described in Appendix D.2.3.
Device-specific q. In these experiments, we explore a device-specific strategy for selecting q in q-FFL. We solve q-FFL with q ∈ {0, 0.001, 0.01, 0.1, 1, 2, 5, 10} in parallel. After training, each device selects the best resulting model based on the validation data and tests the performance of the model using the testing set. We report the results in terms of testing accuracy in Table 12. Interestingly, using this device-specific strategy the average accuracy in fact increases while the variance of accuracies is reduced, in comparison with q = 0. We note that this strategy does induce more local computation and additional communication load at each round. However, it does not increase the number of communication rounds if run in parallel.
Convergence speed of q-FFL. Since q−FFL (q > 0) is more difficult to optimize, a natural question one might ask is: will the q-FFL q > 0 objectives slow the convergence compared with FedAvg? We empirically investigate this on the four datasets. We use q-FedAvg to solve q-FFL, and compare it with FedAvg (i.e., solving q-FFL with q = 0). As demonstrated in Figure 8, the q values that result in more fair solutions also do not significantly slow down convergence.
Efficiency of q-FFL compared with AFL. One added benefit of q-FFL is that it leads to faster convergence than AFL—even when we use non-local-updating methods for both objectives. In Figure 9, we show with respect to the final testing accuracy for the single worst device (i.e., the objective that AFL is trying to optimize), q-FFL converges faster than AFL. As the number of devices increases (from Fashion MNIST to Vehicle), the performance gap between AFL and q-FFL becomes larger because AFL introduces larger variance.
Efficiency of q-FedAvg under different data heterogeneity. As mentioned in Appendix E.1, one potential cause for the slower convergence of q-FedAvg on the synthetic dataset may be that local updating schemes could hurt convergence when local data distributions are highly heterogeneous. Although it has been shown that applying updates locally results in significantly faster convergence in terms of communication rounds (McMahan et al., 2017; Smith et al., 2018), which is consistent with our observation on most datasets, we note that when data is highly heterogeneous, local updating may hurt convergence. We validate this by creating an IID synthetic dataset (Synthetic-IID) where local data on each device follow the same global distribution. We call the synthetic dataset used in Section 4 Synthetic-Non-IID. We also create a hybrid dataset (Synthetic-Hybrid) where half of the total devices are assigned IID data from the same distribution, and half of the total devices are assigned data from different distributions. We observe that if data is perfectly IID, q-FedAvg is more efficient than q-FedSGD. As data become more heterogeneous, q-FedAvg converges more slowly than q-FedSGD in terms of communication rounds. For all three synthetic datasets, we repeat the process of tuning a best constant step-size for FedSGD and observe similar results as before — our dynamic solver q-FedSGD behaves similarly (or even outperforms) a best hand-tuned FedSGD.

Review summaries:
The problem of fairness in federated learning (FL) is important given the popularity of the topic and its immediate impact on the society. Vanilla FL approaches may be subject to poor performance for clients whose data is under-represented across all participants. This paper proposes a new algorithm for federated learning to reduce variance in performance across clients. The inspiration for the algorithm comes from the problem of uniform  resource allocation in wireless networks.