Federated Learning Based on Dynamic Regularization
Durmus Alp Emre Acar, Yue Zhao, Ramon Matas Navarro, Matthew Mattina, Paul N. Whatmough, Venkatesh Saligrama
Introduction
In McMahan et al. (2017), the authors proposed federated learning (FL), a concept that leverages data spread across many devices, to learn classification tasks distributively without recourse to data sharing. The authors identified four principle characteristics of FL based on several use cases. First, the communication links between the server and devices are unreliable, and at any time, there may only be a small subset of devices that are active. Second, data is massively distributed, namely the number of devices are large, while amount of data per device is small. Third, device data is heterogeneous, in that data in different devices are sampled from different parts of the sample space. Finally, data is unbalanced, in that the amount of data per device is highly variable.
The basic FL problem can be cast as one of empirical minimization of a global loss objective, which is decomposable as a sum of device-level empirical loss objectives. The number of communication rounds, along with the amount of bits communicated per round, has emerged as a fundamental gold standard for FL problems. Many mobile and IoT devices are bandwidth constrained, and wireless transmission and reception is significantly more power hungry than computation (Halgamuge et al., 2009). As such schemes that reduce communication are warranted. While distributed SGD is a viable method in this context, it is nevertheless communication inefficient.
A Fundamental Dilemma. Motivated by these ideas, recent work has proposed to push optimization burden onto the devices, in order to minimize amount of communications. Much of the work in this context, propose to optimize the local risk objective based on running SGD over mini-batched device data, analogous to what one would do in a centralized scenario. On the one hand, training models on local data that minimize local empirical loss appears to be meaningful, but yet, doing so, is fundamentally inconsistent with minimizing the global empirical lossTo see this consider the situation where losses are differentiable. As such stationary points for global empirical loss demand that only the sum of the gradients of device empirical losses are zero, and not necessarily that the individual device gradients are zero. Indeed, in statistically heterogeneous situations, such as where we have heterogeneous dominance of classes, stationary points of local empirical functions do not coincide. (Malinovsky et al., 2020; Khaled et al., 2020a). Prior works (McMahan et al., 2017; Karimireddy et al., 2019; Reddi et al., 2020) attempt to overcome this issue by running fewer epochs or rounds of SGD on the devices, or attempt to stabilize server-side updates so that the resulting fused models correspond to inexact minimizations and can result in globally desirable properties.
Dynamic Regularization. To overcome these issues, we revisit the FL problem, and view it primarily from a communication perspective, with the goal of minimizing communication, and as such allowing for significantly more processing and optimization at the device level, since communication is the main source of energy consumption (Yadav & Yadav, 2016; Latré et al., 2011). This approach, while increasing computation for devices, leads to substantial improvement in communication efficiency over existing state-of-the-art methods, uniformly across the four FL scenarios (unreliable links, massive distribution, substantial heterogeneity, and unbalanced data). Specifically, in each round, we dynamically modify the device objective with a penalty term so that, in the limit, when model parameters converge, they do so to stationary points of the global empirical loss. Concretely, we add linear and quadratic penalty terms, whose minima is consistent with the global stationary point. We then provide an analysis of our proposed FL algorithm and demonstrate convergence of the local device models to models that satisfy conditions for local minima of global empirical loss with a rate of where is number of rounds communicated. For convex smooth functions, with devices, and devices active per round, our convergence rate for average loss with balanced data scales as , substantially improving over the state-of-art (SCAFFOLD ). For non-convex smooth functions, we establish a rate of .
We perform experiments on both visual and language real-world datasets including MNIST, EMNIST, CIFAR-10, CIFAR-100 and Shakespeare. We tabulate performance studying cases that are reflective of FL scenarios, namely, for (i) varying device participation levels, (ii) massively distributed data, (iii) various levels of heterogeneity, as well as (iv) unbalanced local data settings. Our proposed algorithm, FedDyn, has similar overhead to competing approaches, but converges at a significantly faster rate. This results in a substantial reduction in communication compared to baseline approaches such as conventional FedAvg (McMahan et al., 2017), FedProx (Li et al., 2020) and SCAFFOLD (Karimireddy et al., 2019), for achieving target accuracy. Furthermore, our approach is simple to implement, requiring far less hyperparameter tuning compared to competing methods.
Contributions. We summarize our main results here.
We present, FedDyn, a novel dynamic regularization method for FL. Key to FedDyn is a new concept, where in each round the risk objective for each device is dynamically updated so as to ensure that the device optima is asymptotically consistent with stationary points of the global empirical loss,
We prove convergence results for FedDyn in both convex and non-convex settings, and obtain sharp results for communication rounds required for achieving target accuracy. Our results for convex case improves significantly over state-of-art prior works. FedDyn in theory is unaffected by heterogeneity, massively distributed data, and quality of communication links,
On benchmark examples FedDyn achieves significant communication savings over competing methods uniformly across various choices of device heterogeneity and device participation on massively distributed large-scale text and visual datasets.
Related Work. FL is a fast evolving topic, and we only describe closely related approaches here. Comprehensive field studies have appeared in Kairouz et al. (2019); Li et al. (2020). The general FL setup involves two types of updates, the server and device, and each of these updates are associated with minimizing some local loss function, which by itself could be updated dynamically over different rounds. At any round, there are methods that attempt to fully optimize or others that propose inexact optimization. We specifically focus on relevant works that address the four FL scenarios (massive distribution, heterogeneity, unreliable links, and unbalanced data) here.
One line of work proposes local SGD (Stich, 2019) based updates, wherein each participating device performs a single local SGD step. The server then averages received models. In contrast to local SGD, our method proposes to minimize a local penalized empirical loss.
FedAvg (McMahan et al., 2017) is a generalization of local SGD, which proposes a larger number of local SGD steps per round. Still, FedAvg inexactly solves device side optimization. Identifying when to stop minimizing so that one gets a good accuracy-communication trade-off is based on tuning the number of epochs and the learning rate (McMahan et al., 2017; Li et al., 2020b). Despite the strong empirical performance of FedAvg in IID settings, performance degrades in non-IID scenarios (Zhao et al., 2018).
Several modifications of FedAvg have been proposed to handle non-IID settings. These variants include using a decreasing learning rate (Li et al., 2020b); modifying device empirical loss dynamically (Li et al., 2020a); or modifying server side updates (Hsu et al., 2019; Reddi et al., 2020). Methods that use a decreasing learning rate or customized server side updates still rely on local SGD updates within devices. While these works do recognize the incompatibility of local and global stationary points, their proposed fix is based on inexact minimization. Additionally, in order to establish convergence for non-IID situations, these works impose additional “bounded-non-IID” conditions.
FedProx (Li et al., 2020a) is related to our method. Like us they propose a dynamic regularizer, which is modified based on server supplied models. This regularizer penalizes updates that are far away from the server model. Nevertheless, the resulting regularizer does not result in aligning the global and local stationary points, and as such inexact minimization is warranted, and they do so by carefully choosing learning rates and epochs. Furthermore, tuning requires some knowledge of statistical heterogeneity.
In a similar vein, there are works that augment updates with extra device variables that are also transmitted along with the models (Karimireddy et al., 2019; Shamir et al., 2014). These works prove convergence guarantees through adding device-dependent regularizers. Nevertheless, they suffer additional communication costs and they are not extensively experimented with deep neural networks. Among them, SCAFFOLD (Karimireddy et al., 2019) is a closely related work even though it transmits extra variables and a more detailed comparison is given in Section 2.
Another line of distributed optimization methods (Konečnỳ et al., 2016; Makhdoumi & Ozdaglar, 2017; Shamir et al., 2014; Yuan & Ma, 2020; Pathak & Wainwright, 2020; Liang et al., 2019; Li et al., 2020c; Condat et al., 2020) could be considered in this setting. Moreover, there are works that extend analysis of SGD type methods to FL settings (Gorbunov et al., 2020; Khaled et al., 2020b; Li & Richtárik, 2020). However, these algorithms are proposed for full device participation case which fails to satisfy one important aspect of FL. FedSVRG (Konečnỳ et al., 2016) and DANE (Shamir et al., 2014) need gradient information from all devices at each round and they are not directly applicable to partial FL settings. For example, FedDANE (Li et al., 2019) is a version of DANE that works in partial participation. However, FedDANE performs worse than FedAvg empirically with partial participation (Li et al., 2019). Similar to these works, FedPD (Zhang et al., 2020) method is proposed in distributed optimization with a different participation notion. FedPD activates either all devices or no devices per round which again fails to satisfy partial participation in FL.
Lastly, another set of works aims to decrease communication costs by compressing the transmitted models (Dutta et al., 2019; Mishchenko et al., 2019; Alistarh et al., 2017). They save communication costs through decreasing bit-rate of the transmission. These ideas are complementary to our work and they can be integrated to our proposed solution.
Method
We assume there is a cloud server which can transmit and receive messages from client devices. Each device, consists of training instances in the form of features, and corresponding labels that are drawn IID from a device-indexed joint distribution, .
FedDyn Method. Our proposed method, FedDyn, is displayed in Algorithm 1. In each round, , a subset of devices are active, and the server transmits its current model, , to these devices. Each active device then optimizes a local empirical risk objective, which is the sum of its local empirical loss and a penalized risk function. The penalized risk, which is dynamically updated, is based on current local device model, and the received server model:
Devices compute their local gradient, , recursively, by noting that the first order condition for local optima must satisfy,
Stale devices do not update their models. Updated device models, are then transmitted to server, which then updates its model to as displayed in Algorithm 1.
Intuitive Justification. To build intuition into our method, we first highlight a fundamental issue about the Federated Dynamic Regularizer setup. It is that stationary points for device losses, in general, do not conform to global losses. Indeed, a global stationary point, must necessarily satisfy,
In contrast a device’s stationary point, satisfies, , and in general due to heterogeneity of data ( for ), the individual device-wise gradients are non-zero . This means that the dual goals of (i) seeking model convergence to a consensus, namely, , and (ii) the fact that model updates are based on optimizing local empirical losses is inconsistentAs pointed in related work prior works based on SGD implicitly account for the inconsistency by performing inexact minimization, and additional hyperparameter tuning..
Dynamic Regularization. Our proposed risk objective in Eq. 1 dynamically modifies local loss functions, so that, if in fact local models converge to a consensus, the consensus point is consistent with stationary point of the global loss. To see this, first note that if we initialize at a consensus point, namely, , we have, for . Thus our choice can be seen as modifying the device loss so that the stationary points of device risk is consistent with server model.
Key Property of Algorithm 1. If local device models converge, they converge to the server model, and the convergence point is a stationary point of the global loss. To see this, observe from Eq 2 that if , it generally follows that, , and as a consequence, we have . In turn this implies that , i.e., is independent of . Putting all of this together with our server update equations we have that convergence implies . Now the server state , and as such in the limit we are left with . This implies that we converge to a point that turns out to be a stationary point of the global risk.
Properties outlined in the previous section, motivates our FedDyn convergence analysis of device and server models. We will present theoretical results for strongly convex, convex and non-convex functions.
Assuming a constant number of devices are selected uniformly at random in each round, , for a suitably chosen of , Algorithm 1 satisfies,
strongly convex and smooth functions,
Convex and smooth functions,
Nonconvex and smooth functions,
Theorem 1 gives rates for strongly convex, convex and nonconvex local losses. For strongly convex and smooth functions, in expectation, a weighted average of active device averages converge at a linear rate. For convex and smooth functions, in expectation, the global loss of active device averages, converges at a rate . Following convention, this rate is for the empirical loss averaged across devices. As such this rate would hold with moderate data imbalance. In situations with significant imbalance, which scales with data size, these results would have to account for the variance in the amount of data/device. Furthermore, the factor might appear surprising, but note that our bounds hold under expectation, namely, the error reflects the average over all random choices of devices. Similarly, for nonconvex and smooth functions, in expectation, average of active device models converges to a stationary point at rate. The expectation is taken over randomness in active device set at each round. Similar to known convergence theorems, the problem dependent constants are related to how good the algorithm is initialized. We refer to Appendix B for a detailed proof.
Finally, apart from conceptual differences, there are also implementation differences. SCAFFOLD runs SGD, and adapts hyperparameter tuning for a given number of rounds to maximize accuracy. In contrast, our approach, based on exact minimization, is agnostic to specific implementation, and as such we utilize significantly less tuning.
Experiments
Our goal in this section is to evaluate FedDyn against competing methods on benchmark datasets for various FL scenarios We open sourced our code in https://github.com/alpemreacar/FedDyn.. Our results will highlight trade-offs and benefits of our exact minimization relative to prior inexact minimization methods. To ensure a fair comparison, the usual SGD procedure is adapted for the FedDyn algorithm in the device update as in FedAvg rather than leveraging an off the shelf optimization solver. We provide a brief description of the datasets and the models used in the experiments. A detailed description of our setup can be found in Appendix A.1. Partial participation was handled by sampling devices at random in each round independent of previous rounds.
Datasets. We used benchmark datasets with the same train/test splits as in previous works (McMahan et al., 2017; Li et al., 2020a) which are MNIST (LeCun et al., 1998), CIFAR-10, CIFAR-100 (Krizhevsky et al., 2009), a subset of EMNIST (Cohen et al., 2017) (EMNIST-L), Shakespeare (Shakespeare, 1994) as well as a synthetic dataset. The IID split is generated by randomly assigning datapoints to the devices. The Dirichlet distribution is used on the label ratios to ensure uneven label distributions among devices for non-IID splits as in Yurochkin et al. (2019). For example, in MNIST, device experiments, each device has about and classes that consume of local data at Dirichlet parameter settings of and respectively. To generate unbalanced data, we sample the number of datapoints from a lognormal distribution. Controlling the variance of lognormal distribution gives unbalanced data. For instance, in CIFAR-10, device experiments, balanced and unbalanced data settings have standard deviation of device sample size of and respectively.
Models. We use fully-connected neural network architectures for MNIST and EMNIST-L with hidden layers. The number of neurons in the layers are 200 and 100; and the models achieve and test accuracy in MNIST and EMNIST-L respectively. The model used for MNIST is the same as used in McMahan et al. (2017). For CIFAR-10 and CIFAR-100, we use a CNN model, similar to McMahan et al. (2017), consisting of convolutional layers with filters followed by fully connected layers with 394 and 192 neurons, and a softmax layer. The model achieves and test accuracy for CIFAR-10 and CIFAR-100 respectively. For the next character prediction task (Shakespeare), we use a stacked LSTM, similar to Li et al. (2020a). This architecture achieves a test accuracy of and in IID and non-IID settings respectively. Both IID and non-IID performances are reported since splits are randomly regenerated from the entire Shakespeare writing. Hence centralized data and the centralized model performance is different.
In passing, we note that while the accuracies reported are state-of-art for our chosen models, higher capacity models can achieve higher performance on these datasets. As such, our aim is to compare the relative performance of these models in FL using FedDyn and other strong baselines.
Comparison of Methods. We report the performance of FedDyn, SCAFFOLD, FedAvg and FedProx on synthetic and real datasets. We also experimented with distributed SGD, where devices in each round compute gradients on the server supplied model on local data, and communicate these gradients. Its performance was not competitive relative to other methods. Therefore, we do not tabulate it here. We cover synthetic data generation and its results in Appendix A.1.
The standard goal in FL is to minimize amount of bits transferred. For this reason, we adopt the number of models transmitted to achieve a target accuracy as our metric in our comparisons. This metric is different than comparing communication rounds since not all methods communicate the same amount of information per round. FedDyn, FedAvg and FedProx transmit/receive the same amount of models for a fixed number of rounds whereas SCAFFOLD costs twice due to transmission of states. We compare algorithms for two different accuracy levels which we pick them to be close to performance obtained by centralizing data. Along with transmission costs of each method, we report the communication savings of FedDyn compared to each baseline in parenthesis. For methods that could not achieve aimed accuracy within the communication constraint, we append transmission cost with sign. We observe FedDyn results in communication savings compared to all baselines to reach a target accuracy. We test FedDyn under the four characteristic properties of FL which are partial participation, large number of devices, heterogeneous data, and unbalanced data.
Moderate vs. Large Number of Devices. FedDyn significantly outperforms competing methods in the practically relevant massively distributed scenario. We report the performance of FedDyn on CIFAR-10 and CIFAR-100 with moderate and large number of devices in Table 1, while keeping the participation level constant and the data amounts balanced. Specifically, the moderately distributed setting has devices with images per device. The massively distributed setting has devices with images per device for CIFAR-10, as well as devices with images per device for CIFAR-100. In each distributed setting, the data is partitioned in both IID and non-IID (Dirichlet 0.3) fashion. FedDyn leads to substantial transmission reduction in each of the regimes.
First, the communication saving in the massive setting is significantly larger relative to the moderate setting. Compared to SCAFFOLD, FedDyn leads to and gains respectively on CIFAR-10 IID setting. SCAFFOLD is not able to achieve within rounds in the massive setting (shown in Figure 4(a)), thus actual saving is more than . Similar trend is observed in the non-IID setting of CIFAR-10 and CIFAR-100. Second, all the methods require more communications to achieve a reasonable accuracy in the massive setting as the dataset is more decentralized. For instance, it takes FedDyn rounds to achieve with devices, while it takes rounds to achieve with devices. Similar trend is observed for CIFAR-100 and other methods. FedDyn always achieves the target accuracy with fewer rounds and thus leads to significant saving. Third, a higher target accuracy may result in a greater saving. For instance, the saving relative to SCAFFOLD increases from to in the CIFAR-10 IID massive setting. We may attribute this to the fact that FedDyn aligns device functions to global loss and efficiently optimizes the problem.
Full vs. Partial Participation Levels. FedDyn outperforms baseline methods across different device participation levels. We consider different device participation levels with devices and balanced data in Table 2 where part of CIFAR-10 and CIFAR-100 results are omitted since they are reported in moderate number of devices section of Table 1. The Shakespeare non-IID results are separately shown, since it has a natural non-IID split which does not conform with the Dirichlet distribution. The communication gain, with respect to best baseline, increases with greater participation levels from to ; to and to for CIFAR-10 in different device distribution settings. We observe a similar performance increase in full participation for most of the datasets. This validates our hypothesis that FedDyn more efficiently incorporates information from all devices compared to other methods, and results in more savings in full participation. Similar to previous results, a greater target accuracy gives a greater savings in most of the settings. We also report results for participation regime with different device distribution settings (See Table 5 in Appendix A.1).
Balanced vs. Unbalanced Data. FedDyn is more robust to unbalanced data than competing methods. We fix number of devices (100) and participation level (10%) and consider effect of unbalanced data (Table 4 (Appendix A.1)). FedDyn achieves gains over the best competitor, SCAFFOLD to achieve the target accuracy. As before, gains increase with the target accuracy.
IID vs. non-IID Device Distribution. FedDyn outperforms baseline methods across different device distribution levels. We consider heterogeneous device distributions in the context of varying device numbers, participation levels and balanced-unbalanced settings in Table 1, 2 and 4 (Appendix A.1) respectively. Device distributions become more non-IID as we go from IID, Dirichlet to Dirichlet splits which makes global optimization problem harder. We see a clear effect of this change in Table 2 for participation level and in Table 4 for unbalanced setting. For instance, increasing non-IID level results in a greater communication saving such as from , to in CIFAR-10 participation. Similar statement holds for MNIST, EMNIST-L and Shakespeare in Table 2 and for CIFAR-10 unbalanced setting in Table 4. We do not observe a significant difference in savings for full participation setting in Table 2.
Summary. Overall, FedDyn consistently leads to substantial communication savings compared to baseline methods uniformly across various FL regimes of interest. We realize large gains in the practically relevant massively distributed data setting.
Conclusion
We proposed FedDyn, a novel FL method for distributively training neural network models. FedDyn is based on exact minimization, wherein at each round, each participating device, dynamically updates its regularizer so that the optimal model for the regularized loss is in conformity with the global empirical loss. Our approach is different from prior works that attempt to parallelize gradient computation, and in doing so they trade-off target accuracy with communications, and necessitate inexact minimization. We investigate different characteristic FL settings to validate our method. We demonstrate both through empirical results on real and synthetic data as well as analytical results that our scheme leads to efficient training with convergence rate as where is number of rounds, in both convex and non-convex settings, and a linear rate in strongly convex setting, while being fully agnostic to device heterogeneity and robust to large number of devices, partial participation and unbalanced data.
Acknowledgements
This research was supported by a gift from ARM corporation (DA), and CCF-2007350 (VS), CCF-2022446(VS), CCF-1955981 (VS), the Data Science Faculty Fellowship from the Rafik B. Hariri Institute.
References
Appendix A Appendix
We simulate different settings by allowing only one type of heterogeneity at a time and disabling the randomness from the other two. For instance, if we want to disable type heterogeneity, we draw one single set of optimal parameters and use it to generate datapoints for all devices. Similarly, is set to to disable type heterogeneity and is set to to disable type heterogeneity. We consider four settings in total, including type , , and heterogeneous as well as a homogeneous setting. The number of devices is set to and the number of datapoints per device is on average in the generation process.
Models. We test FedDyn, SCAFFOLD, FedAvg and FedProx using a multiclass logistic classification model with cross entropy loss. We keep batch size to be , weight decay to be .
We test learning rates in and epochs in $\alpha[.1,.01,.001]K\mu[0.01,.0001]$.
Table 6 reports the number models transmitted relative to one round of FedAvg to achieve the target training loss for best hyperparameter selection in various settings with device participation. As shown, FedDyn leads to communication savings in each of the settings in range to .
A.2 Real Data
Datasets. MNIST, EMNIST-L, CIFAR-10 and CIFAR-100 are used for image classification tasks and Shakespeare dataset is used for a next character prediction task. The image size is in MNIST and EMNIST; in CIFAR-10 and CIFAR-100 with overall classes in MNIST and CIFAR-10; classes in EMNIST; and classes in CIFAR-100. We choose the first letters from the letter section of EMNIST (named it as EMNIST-L) similar to (Li et al., 2020a) work. Features in Shakespeare dataset consists of characters and labels are the following characters. Overall, there are different labels for datapoints.
We use the usual train and test splits for MNIST, EMNIST-L, CIFAR-10 and CIFAR-100. The number of training and test samples of the benchmark datasets are summarized in Table 3.
To generate IID splits, we randomly divide training datapoints and assign them to devices. For non-IID splits, we utilize the Dirichlet distribution as in (Yurochkin et al., 2019). Firstly, a vector of size equal to the number of classes are drawn using Dirichlet distribution for each device. These vectors correspond to class priors per devices. Then one label is sampled based on these vectors for each device and an image is sampled without replacement based on the label. This process is repeated until all datapoints are assigned to devices. The procedure allows the label ratios of each device to follow a Dirichlet distribution. The hyperparameter of Dirichlet distribution corresponds to statistical heterogeneity level in the device datapoints. Overall, for a device experiment, each device has , , and datapoints in MNIST, EMNIST-L, CIFAR-10 and CIFAR-100 respectively. For these datasets, three different federated settings are generated including an IID and two non-IID Dirichlet settings with and priors. Figure 3 shows the heterogeneity levels for MNIST dataset in these different settings. The amount of most occurred class labels that consume , and of device data are shown in the histogram plots. For example, every class label is equally represented in IID setting hence , and classes occupy , , and of the local datapoints for each device. If we consider non-IID settings, we see of local data belongs to mostly or different classes for Dirichlet ; and or different classes for Dirichlet settings.
To generate unbalanced data, we sample datapoint amounts from a lognormal distribution. Controlling the variance of lognormal distribution gives unbalanced data per devices. For instance, in CIFAR-10, balanced and unbalanced data settings have standard deviation of data amounts among devices as and respectively.
LEAF (Caldas et al., 2018) is used to generate the Shakespeare dataset used in this work. The LEAF framework allows to generate IID as well as non-IID federated settings. The non-IID dataset is the natural split of Shakespeare where each device corresponds to a role and the local dataset contains this role’s sentences. The IID dataset is generated by combining the sentences from all roles and randomly dividing them into devices. In this work, we consider devices and restrict number of datapoints per device to .
Models. We use fully connected neural network architectures for MNIST and EMNIST-L. Both models take input images as a vector of dimensions followed by hidden layers and a final softmax layer. The number of neurons in the hidden layers are and for MNIST and EMNIST-L respectively. These models achieve and test accuracy in MNIST and EMNIST-L if trained on datapoints from all devices. The model considered for MNIST is the same model used in original FedAvg work (McMahan et al., 2017).
For CIFAR-10 and CIFAR-100, we use a CNN consisting of two convolutional layers with filters, two max pooling layers, two fully connected layers with and neurons, and finally a softmax layer. The models achieve and test accuracy in CIFAR-10 and CIFAR-100 respectively. Our CNN model is similar to the used for CIFAR-10 in the original FedAvg work (McMahan et al., 2017), except that we don’t use Batch Normalization layers.
For the next character prediction task (Shakespeare), we use an LSTM. The model converts an character long input sequence to a sequence using an embedding. This sequence is fed to a two layer LSTM with hidden size of units. The output of stacked LSTM is passed to a softmax layer. Overall, this architecture achieves a test accuracy of and in IID and non-IID settings, respectively, if trained on data from all devices. We report both IID and non-IID performance here because the datasets are randomly regenerated out of the whole Shakespeare writing hence train and test split is different for both cases. This Neural Network model is the same model used in the original FedProx study (Li et al., 2020a).
In passing, we note here that, we are not after state of the art model performances for these datasets, our aim is to compare the performances of these models in federated setting using FedDyn and other baselines.
Hyperparameters. We consider different hyperparameter configurations for different setups and datasets. For all the experiments, we fix batch size as for MNIST, CIFAR-10, CIFAR-100 and EMNIST-L datasets and as for Shakespeare dataset.
We note here that , and hyperparameters are used only in FedProx, FedDyn and SCAFFOLD respectively. is the equivalent of epoch for SCAFFOLD algorithm and we searched values to have the same amount of local computation as in other methods. For example, if each device has datapoints, batch size is and epoch is , local devices apply SGD steps which is equivalent to being .
MNIST. As for the devices, balanced data, full participation setup, hyperparameters are searched for all algorithms in all IID and Dirichlet settings for a fixed communication rounds. The search space consists of learning rates in , epochs in $K\mu[1,.01,.0001]\alpha[.001,.01,.03,.1]10^{-4}.120.1.0001\mu.150.01\alpha.1600K500$ communication rounds.
For the partial participation, devices, balanced data setup, the selected configuration for FedAvg is learning rate and epoch; for FedProx is learning rate and ; for FedDyn is learning rate, epoch and ; and for SCAFFOLD is learning rate and for all IID and Dirichlet settings except that is chosen to be for IID setting. learning rate decay per communication round is used and weight decay of is applied to prevent overfitting for all methods.
For the centralized model, we choose learning rate as , epoch as and learning rate is halved in every epochs.
EMNIST-L. We used similar hyperparameters as in MNIST dataset. The configuration for FedAvg is learning rate and epoch; for FedProx is learning rate and ; for FedDyn is learning rate, epoch and ; and for SCAFFOLD is learning rate and for all IID and Dirichlet full participation settings.
The selected configuration for FedAvg is learning rate and epoch; for FedProx is learning rate and ; for FedDyn is learning rate, epoch; and for SCAFFOLD is learning rate and for all IID and Dirichlet partial settings. is chosen to be for and IID; for Dirichlet and Dirichlet ; for Dirichlet and for Dirichlet settings. learning rate decay per communication round is used and weight decay of is applied to prevent overfitting for all methods.
For the centralized model, we choose learning rate as , epoch as and learning rate is halved in every epochs.
CIFAR-10. The same hyperparameters are applied to all the CIFAR-10 experiments, including: for learning rate, for epochs, and for weight decay. The learning rate decay is selected from the range of . The value is selected from the range of for FedDyn. The s value is selected from the range of .
For the centralized model, we choose learning rate as , epoch as and learning rate decay as .
CIFAR-100. The same hyperparameters are applied to the CIFAR-100 experiments with devices. including: for learning rate, for epochs, and for weight decay. The learning rate decay is selected from the range of . The value is selected from the range of for FedDyn. The s value is selected from the range of .
As for device, balanced data, participation, IID setup, learning rate, , weight decay applied. Epochs in $K\alpha[.1,.01,.001]2K4.01\alpha50010\%.3$ setup.
As for device, unbalanced data, participation, IID and Dirichlet settings, epoch of is selected for FedDyn, FedAvg and FedProx, of is selected for SCAFFOLD. value is applied for FedDyn. is used in FedProx.
For the centralized model, we choose learning rate as , epoch as and learning rate decay as .
Shakespeare. As for devices, balanced data, full participation setup, the hyperparameters are searched with all combinations of learning rate in , s in $\mu[.01,.0001]\alpha[.001,.009,.01,.015]10^{-4}1515.0001\mu15.009\alpha1100K$ in IID and non IID settings.
For the partial participation, devices, balanced data setup, we choose learning rate and epoch for FedAvg; learning rate, epoch and for FedProx; learning rate and K for SCAFFOLD; and learning rate and epoch for FedDyn in all cases. is and for and settings respectively. No learning rate decay is applied for settings and a decay of is applied for settings. Weight decay of is applied to prevent overfitting.
For the centralized model, we choose learning rate as , epoch as and learning rate is halved in every epochs.
Additionally, we performed gradient clipping to prevent overflow in weights for all methods. We found out that, this increases stability of algorithms.
Convergence Plots. We give convergence plots of experiments. The convergence plots of moderate and large number of devices in different device distributions are shown in Figure 4 and 5 for CIFAR-10 and CIFAR-100 datasets. Similarly, convergence curves of different participation levels and distributions are plotted in Figure 6, 7, 8, 9 and 10 for all datasets. Finally, Figure 12 and 13 show convergence plots for balanced data and unbalance data in different device distributions.
We emphasize that convergence curves show accuracy achieved with respect to rounds communicated. However, the metric we want to minimize, the amount of information transmitted, is not the same as number of communication rounds. For instance, SCAFFOLD transmits two models including state of devices per communication round. This difference is accounted in the tables.
We observed that averaging all device models gives more stable convergence curves hence we report the performance of the average model from all devices in each communication round. We note that we do not modify the algorithms, this part is only for reporting purposes.
Additional to experiments stated, we test our algorithm with a more complex model. We consider ResNet18 (He et al., 2016) structure on CIFAR-10 IID, devices, balanced data, participation setting. Batch normalization layers have inherent statistics which can be problematic in FL. Therefore, we use group normalization (Wu & He, 2018) instead of Batch normalization in ResNet18. The convergence curves are shown in Figure 11. FedDyn still outperforms the baseline methods in a higher capacity model setup.
A.3 α𝛼\alpha Sensitivity Analysis of FedDyn
is an important parameter of FedDyn. Indeed, it is the only hyperparameter of the algorithm when devices have access to an optimization solver. In theory, balances two problem dependent constants as shown in Theorem 2, Theorem 3 and Theorem 4. Consequently, optimal value of depends on these constants. Since these constants are independent of , the value of does not asymptotically affect convergence rate.
To test sensitivity, we consider CIFAR-10, IID, devices, participation setting. Figure 1(a) shows convergence plots for different configurations while keeping all other parameters constant in FedDyn. Figure 1(b) presents the best achieved test accuracy with respect to different values. We see that best test performance is obtained when . We note that all configurations converge, but some of them converges to a better stationary points. This aligns with the theory because we guarantee convergence to a stationary point.
A.4 Comparison to A Full Participation Method
Recently, FedSplit (Pathak & Wainwright, 2020) is introduced to target non IID data distributions among devices. The work simplifies FL setting by considering full device participation. It characterizes FedAvg convergence and shows that FedAvg should do only one step update per device in each round to achieve global minima if device losses are different. In such cases, FedAvg becomes decentralized SGD. After pointing out this inconsistency, FedSplit is given as a potential solution.
In this work, we aim to solve FL problem with four principle characteristic which are partial participation due to unreliable communication links, massive number of devices, heterogeneous device data and unbalanced data amounts per device. Partial participation is a critical property, because, it is inconceivable that we will not be in a situation where we have all devices participating in each round. However, FedSplit does not support partial participation.
Nevertheless, we adapt FedSplit to partial participation setting with the following changes. If a device is not active in the current round, its model and its intermediate state are frozen. For the server model, we have two options. First option is to keep the server model as average of all device models, , which is named as FedSplit All. Second option is to have the server model as the average of only current round’s active devices , which is named as FedSplit Act. In passing, we do not claim that these modifications are optimal.
For empirical evaluation, we consider CIFAR-10, 100 devices, and participation settings. Figure 2(a) and 2(b) show comparison between FedSplit and FedDyn for and participation levels respectively. FedSplit All and FedSplit Act are the same in full participation setting hence shown as one method. We observe that FedDyn performs better than FedSplit in both cases. We see that FedSplit All where the server model averages all device models is significantly underperforming than FedSplit Act where the server only averages active devices. This is due to the fact that the server model is too slow to change when all devices are averaged because most of the devices are the same across consecutive rounds. We further note that it might not be easy to get convergence theory of FedSplit in the partial participation setting.
A.5 Figures Omitted in the Main Text
Appendix B Proof
Smoothness implies the following quadratic bound,
If s are convex and smooth we have
For convex and smooth functions and , Algorithm 1 satisfies
consists of active device average and gradient parts. Let’s express active device average and its relation with the server model as,
Due to linear update of , state in the server becomes as .
Let’s define some quantities that we would like to control.
tracks how well local gradients of device models approximate the gradient of optimal model. If models converge to , will be 0. keeps track of how much local models change compared to average of device models from previous round. Again, upon convergence will be 0.
After these definitions, Theorem 2 can be seen as a direct consequence of the following Lemma,
For convex and smooth functions, if , Algorithm 1 satisfies
where
Lemma 1 can be telescoped in the following way,
If , and become positive. By definition, we also have sequences as positive. Eliminating negative terms on RHS gives,
Similar to fundamental gradient descent analysis, is expressed as and expanded in the proof of Lemma 1. The resulting expression has and terms. To tackle these extra terms, we state the following Lemmas and prove long ones at the end.
Similarly, is bounded with the following,
We need to further bound excess term arising in Lemma 3. We introduce two more Lemmas to handle this term.
For convex and smooth functions, Algorithm 1 satisfies
For convex and smooth functions, Algorithm 1 satisfies
where we first expand the square term and use Lemma 2. Following inequality is due to Eq. 6.
Let’s scale Lemma 4 and 5 with and respectively. We note that the coefficients are positive due to the condition on . Summing Eq. 10, Lemma 3, scaled versions of Lemma 5 and 4 gives the statement in Lemma 1. ∎
, triangular inequality satisfies
Using Jensen we get, . Multiplying both sides with gives the inequality. ∎
where first and second come from Eq. 9 and 8. Following inequalities come from Lemma 6, 7, smoothness and Eq. 5. Rearranging terms gives the Lemma.∎
where first equality comes from taking expectation with respect to ; second equality comes from definition of . Inequalities follow from Lemma 6, smoothness and Eq. 5 respectively.∎
B.2 Strongly Convex Analysis
We state convergence for strongly convex and smooth functions as,
For strongly convex and smooth functions and , Algorithm 1 satisfies
With these definitions in mind, Theorem 3 can be seen as a direct consequence of the following Lemma,
For strongly convex and smooth functions, if , Algorithm 1 satisfies
where
Let’s multiply Lemma 8 with and telescope as,
If , and become positive. Dividing both sides with and eliminating negative terms on RHS gives,
We have . Combining two inequalities, we get,
The proof of Lemma 8 is similar to the convex analysis. We generalize Eq. 6 to strongly convex functions fors are strongly convex and smooth as,
Since strongly convex functions are convex functions and we only change Eq. 6, we can directly use Lemma 2, 3, 4 and 5. Let’s rewrite expression as,
where we first expand the square term and use Lemma 2. Following inequalities use Eq. 11 and Lemma 9. Rearranging Eq. 12 gives,
Let’s define . Let’s scale Lemma 4 and 5 with and respectively. We note that the coefficients are positive due to the condition on . Summing Eq. 13, Lemma 3, scaled versions of Lemma 5 and 4 gives the statement in Lemma 8. ∎
B.3 Nonconvex Analysis
We state convergence for nonconvex smooth s as,
For nonconvex and smooth functions and , Algorithm 1 satisfies
Similarly, tracks how well local models approximate the current active device average. Upon convergence and will be 0.
Theorem 4 can be seen as a direct consequence of the following Lemma,
For smooth functions, if , Algorithm 1 satisfies
where .
If , we have and as positive quantities. By definition, we also have sequences as positive. Eliminating negative terms on RHS and summing over time give,
To bound excess term, we introduce two more Lemmas as
For smooth functions, Algorithm 1 satisfies
For smooth functions, Algorithm 1 satisfies
where first equality uses Lemma 2. The following inequalities are due to , Jensen Inq. and smoothness.
Let’s define and scale Lemma 12, 3 and 11 with , and respectively. We note that the coefficients are positive due to the condition on . Summing Eq. 14, scaled versions of Lemma 3, 11 and 12 gives the statement in Lemma 10. ∎
Lastly, we note that the convergence analysis is given with respect to L2 norm in the gradients. L2 norm arises in the analysis because Eq. 4 has L2 norm due to our definition of smoothness. Furthermore, the analysis can be extended to different norms. To do so, smoothness needs to be defined with respect to primal and dual norms as in Eq. 3 in Nesterov et al. (2020).
where first, second and third come from definition of , Eq. 9 and 8. The following inequalities are due to Lemma 6, Jensen Inq. and smoothness. Rearranging terms gives the Lemma.∎
Appendix C Extended Discussion
We analyze a variant of FedDyn that uses only one gradient update in the clients. Algorithm 2 presents FedDynOneGD method. Different from FedDyn, FedDynOneGD does one gradient descent update in the clients so that the device optimization is faster than FedDyn. We show that FedDynOneGD has the same asymptotic convergence rate guarantees We note that our experiments uses FedDyn..
FedDynOneGD is a practical algorithm. In each round, active devices calculate gradients of the local data rather than doing a full minimization. Since the number of data points in each device is small, computing a gradient, .i.e having one dataset pass, is not a costly operation. We present FedDynOneGD to show that a lightweight FedDyn variant also achieves the same convergence rates.
Note that the gold-standard for comparison in federated learning is often the number of communication rounds (McMahan et al., 2017). Nevertheless, we may also want to keep track of computations per round. These are often complementary metrics.
Computation and communications. GD versus SGD. To get a handle on computation, we provide results with performing one gradient descent in FedDynOneGD algorithm. Our results show that one gradient descent step, which amounts to a single-pass through the data points in a device achieves expected target error with the same number of rounds compared to FedDyn as presented in Theorem 5. We may wonder whether SGD would be more beneficial in the computation metric. To understand this point note that prior works, that utilize SGD on each device, the number of computations per-device is no smaller than taking one-pass through the local dataset (Khaled et al., 2020a; Li et al., 2020b; Karimireddy et al., 2019). As such SGD leads to larger noise at this level of computations, and often results in requiring a larger number of communication rounds. Furthermore, unlike GD, SGD is not parallelizable. SGD method needs to update the local model and evaluate the gradient in the updated model in a sequential manner. Differently, GD methods can evaluate the gradient by parallelizing among device datapoints. For this reason, SGD does not appear to offer any advantages over GD with respect to both communication rounds or computations per round.
C.2 FedDynOneGD Convergence Rate
For the sake of completeness, we state convergence results for FedDynOneGD as,
Assuming a constant number of devices are selected uniformly at random in each round, , for a suitably chosen of , FedDynOneGD, Algorithm 2 satisfies,
strongly convex and smooth functions,
Convex and smooth functions,
Nonconvex and smooth functions,
We use and for convex and strongly convex analysis, and for nonconvex analysis. Our proof steps are based on FedDyn analysis so we directly give the building Lemmas.
Let’s bound and terms as,
Lemma 3, which is , is based on Eq. 9 and it directly follows. Next, we bound the excess term with the following lemmas as,
For convex and smooth functions, Algorithm 2 satisfies
For convex and smooth functions, Algorithm 2 satisfies
Lastly, we bound difference as,
We continue with gradient descent like analysis by rewriting as,
where the relations are due to Lemma 13, Eq. 11, Lemma 16 and 17. Using Lemma 3 and rearranging the terms gives,
We add scaled versions of Lemma 14 and 15 to Eq. 17 to get telescopic terms. Firstly, we assume . Then, we multiply Lemma 14 and 15 with and respectively. Due to the assumption on , the multiplication coefficients are positive. If we add the scaled versions of lemmas, add it to Eq. 17 and scale both sides with , we get,
where . If we multiply both sides with and average over time, we get telescoping terms on RHS. Bounding telescoping terms with the initial conditions and upper bounding give,
Dividing both sides with and using Jensen Inq. on LHS give the linear convergence rate in Theorem 5.
where we use Eq. 9, client update rule and Eq. 16. ∎
Algorithm 2 satisfies .
Algorithm 2 satisfies .
where the equations are based on Eq. 9 and the client update rule. The inequalities come from Lemma 6, 18, 17, smoothness and Eq. 5. ∎
where we first take expectation with respect to , then use Lemma 6, smoothness, Lemma 18 and Eq. 5.∎
where we use Jensen Inq, Eq. 9 and Lemma 17. Rearranging the terms gives the statement.∎
C.2.2 Convex Analysis
We follow a similar analysis as in Section C.2.1. By setting , we can rewrite Eq. 18 for convex and smooth functions as,
Applying Jensen on RHS and setting gives the rate in Theorem 5.
C.2.3 Nonconvex Analysis
We need to refine Eq. 14 and 15 for nonconvex functions. We extend these lemmas as,
For smooth functions, Algorithm 2 satisfies
For smooth functions, Algorithm 2 satisfies
We continue with the use quadratic bound of smoothness, Eq. 4, as,
where we use Lemma 13, , Jensen Inq., Lemma 21 and 3.
We scale Lemma 19 and 20 and add it to to Eq. 19 to get telescopic terms. Let’s assume . We multiply Lemma 19 and 20 with and respectively where . Due to the assumption on , the multiplication coefficients are positive. Adding the scaled versions of lemmas to Eq. 19 and scaling both sides with give,
where . If we average over time, we get telescoping terms on RHS. Bounding telescoping terms with the initial conditions and upper bounding give,
Setting gives the convergence rate in Theorem 5.
where we use smoothness, Eq. 9 and Jensen Inq. ∎
where the equations are based on Eq. 9 and the client update rule. The inequalities come from Lemma 6, Jensen Inq., and Lemma 21. ∎
where we use for and smoothness in the first and second inequalities. The following equality is due to taking expectation conditioned on randomness before time . Final inequalities come from Lemma 21 and 3. ∎
C.3 SCAFFOLD and FedDyn Convergence Comparison
Recently, Karimireddy et al. (2019) presented an improved version of convergence analysis which matches FedDyn rate for convex functions. The comparison is given in Remark 11 of Karimireddy et al. (2019). For the nonconvex setting, the convergence rate of SCAFFOLD builds upon ’lag in the control variates’ for each round, (Lemma 17 page 32). We construct an example with quadratic functions and numerically evaluate Lemma 17. However, we can not empirically verify the claim in Lemma 17 Please see the example in https://github.com/alpemreacar/FedDynClarification/blob/main/Lemma17_SCAFFOLD.pdf.. Since Lemma 17 is essential for the convergence rate, it is not clear if SCAFFOLD gets better rate for nonconvex functions compared to FedDyn.