Fair Resource Allocation in Federated Learning

1 INTRODUCTION . 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 . 2 RELATED WORK . 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 ) . 3 FAIR FEDERATED LEARNING . 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 can not 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 ) .

Summary: 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.