FedGreen: Carbon-aware Federated Learning with Model Size Adaptation
Ali Abbasi Fan Dong Xin Wang Henry Leung Jiayu Zhou Steve Drew







FedGreen: Carbon-aware Federated Learning with Model Size Adaptation
    
Ali Abbasi1, Fan Dong1,  Xin Wang2, Henry Leung1, 
Jiayu Zhou3, Steve Drew1




1Department of Electrical and Software Engineering, University of Calgary, Calgary, AB, Canada 

2Department of Geomatics Engineering, University of Calgary, Calgary, AB, Canada 

3Department of Computer Science and Engineering, Michigan State University, East Lansing, MI, USA 

{ali.abbasi1, fan.dong, xcwang, leungh}@ucalgary.ca, zhou@cse.msu.edu, steve.drew@ucalgary.ca

    April 29, 2024
===========================================================================================================================================================================================================================================================================================================================================================================================================================================================================



plain
plain


Federated learning (FL) provides a promising collaborative framework to build a model from distributed clients, and this work investigates the carbon emission of the FL process.  
Cloud and edge servers hosting FL clients may exhibit diverse carbon footprints influenced by their geographical locations with varying power sources, offering opportunities to reduce carbon emissions by training local models with adaptive computations and communications. 
In this paper, we propose FedGreen, a carbon-aware FL approach to efficiently train models by adopting adaptive model sizes shared with clients based on their carbon profiles and locations using ordered dropout as a model compression technique. 
We theoretically analyze the trade-offs between the produced carbon emissions and the convergence accuracy, considering the carbon intensity discrepancy across countries to choose the parameters optimally. 
Empirical studies show that FedGreen can substantially reduce the carbon footprints of FL compared to the state-of-the-art while maintaining competitive model accuracy. 



    federated learning, carbon emission, model compression, ordered dropout








§ INTRODUCTION

With the proliferation of the Internet of Things (IoT) devices and smartphones, Federated learning (FL) has been extensively studied to leverage the valuable data generated by these devices, where the clients do not share data and only model updates are shared and transmitted to the server. 
FL could involve millions of devices to generate an effective global model collaboratively. 
The coordination following FL protocols could cost an unprecedented scale of distributed computing and communication, continuously consuming energy and generating carbon emissions. Meanwhile, such large-scale coordination offers opportunities for optimizing the workload distribution of computation in FL, leading to overall lower carbon emissions.
With over 120 countries committing to the net-zero emissions goal by 2050 <cit.>, carbon emissions by cloud and edge computing have become a major concern as data centers and edge servers hosting the FL tasks may still be powered by fossil energy <cit.>. Promoting carbon-intensive computing will jeopardize the net-zero goal.

Existing FL methods rarely considered the carbon emissions of the process or assumed that all participants have uniform carbon intensity levels during the training process, leading to all clients transmitting models of the same size mirroring the global model. However, the real-world scenario presents a stark contrast, where edge devices and cloud computing instances, as FL participants, exhibit varying carbon intensity rates and significant disparities in power sources based on locations and computing architectures. Consequently, it becomes imperative to acknowledge and address this inherent system heterogeneity. When applying this concept to deep neural networks, we must consider the carbon intensity concerning the geographical locations of the clients. This variability can manifest in various ways, such as adjustments in neural network depths (i.e., the number of layers) and widths (i.e., the number of hidden channels). Can such variability positively contribute to a carbon-aware FL solution for a greener training process?



The model size is a primary indicator of carbon emissions in FL since both the computation and communication cost positively correlate to the model size <cit.>. To adaptively adjust the size of the models in FL, in this paper, we explore ordered dropout to use dynamically configurable sizes of models for local training and model aggregation based on the carbon intensity of the clients <cit.>. By employing dropout and sending different model sizes to clients with varying carbon footprints, as shown in Fig. <ref>, we aim to reduce the carbon footprint of the overall process in FL. Additionally, we explore and formulate the adjustment of various parameters, including the local training epochs for FL and the combinations of model size scaling rates, to minimize the overall carbon emissions while maintaining the desired level of accuracy.




The remaining sections are organized as follows. Section <ref> reviews the related works. In Section <ref>, we model the carbon emission and introduce our proposed approach. The FedGreen algorithm is then introduced in Section <ref>. We examine our proposed approach with empirical studies in Section <ref>. Section <ref> concludes the paper.




§ RELATED WORK



<cit.> proposed FL as a privacy-preserving method for training the model.  In <cit.>, the authors proposed methods to send adaptive models for clients with heterogeneous capabilities and training data by using model pruning. The authors in <cit.> used neural composition to address the system heterogeneity and training capacity of the clients. <cit.> proposed a method to reduce the Communication and computation overhead in Federated Learning using model pruning.
<cit.> allowed the clients to participate in cooperative training without directly conducting local gradient calculations. 

<cit.> proposed and evaluated a carbon emission model with sources of energy and consumption in both computation and communication aspects. In <cit.>, the authors proposed a method to optimize energy consumption in federated learning using adaptive size models. 
These methods aimed to enhance accuracy and robustness within the context of diverse models in heterogeneous systems. In contrast, FedGreen centers its efforts on reducing the carbon emission in the same rate of convergence accuracy.
FedGreen has also a rigorous study to reduce carbon cost in the context of heterogeneous systems profiles. 
We also provide theoretical analysis for FedGreen.










§ PROPOSED METHOD
 



 §.§ Model Compression


In this paper, we draw inspiration from previous works. Specifically, we explore ordered dropout (OD) <cit.> to organize the representation of knowledge within nested submodels of the original network. The ordered dropout process, initiated by dropping adjacent components of the model rather than random neurons differs from random dropout (RD) <cit.>. It entails resulting in computational advantages and improvements in accuracy rates <cit.>. Compared to reducing network depth, reducing network width can be more effective in terms of parameter and memory footprint reduction during inference, a significant advantage for edge devices <cit.>.

Our approach involves adapting the network width as the method of choice for resource adjustment. Furthermore, networks with adjusted width still belong to the same model class and share similar fundamental characteristics. As observed in previous studies, this continuity in the model architecture is preferable for maintaining stable training and model aggregation <cit.>. Moreover, we utilize a scaling factor denoted as p to adjust the number of active channels in each layer based on the carbon footprints of the computing infrastructure. Slimming down the network width by a factor of p reduces both model size and computational cost by a factor of p^2 <cit.>. 

To distribute different-sized models to clients based on their locations, we consider a predefined set of representative capacity ratios denoted as 𝐩(e.g.,{ p_1, p_2, p_3 }). 



 §.§ Optimizing the Carbon Emission

We observe that the energy usage for each FL client can be categorized into two components: computation usage and communication usage. Suppose there are N clients participating in the FL. We use c_i ∈ [1, N] to denote the client i. A total of R rounds of training will be performed. We use j ∈ [1, R] to represent the round j. We define C_FL as the total carbon emission produced in the entire training process of FL. C_com denotes the carbon cost in the communication process, and C_cmp represents the carbon emission in computation for all N clients over R rounds. Their relationship follows: 
C_FL = C_cmp + C_com.


We apply our problem definition following <cit.> to determine the carbon footprints of FL, demonstrating that for each client, its energy usage and carbon emissions have a linear correlation. We use θ_i,j to define the carbon intensity factor, which means the amount of CO_2 produced for each kWh of electricity at the round j for the c_i. 

The power consumption (e.g., CPU and memory) of c_i at the round j is denoted by e_i,j^cmp. The energy consumption for client c_i at the  round j is influenced by the duration of the computation, denoted by T^cmp_i,j. In Equation (<ref>), p_i,j is the scaling factor of the model for the client c_i in the round j, and f_i,j is the computation frequency of the hardware. W is the total learning time of one data sample. |𝒟_i| is the number of samples on c_i. E is the number of the local rounds. Then we have Equation (<ref>).


    T^cmp_i,j =  p_i,j^2 E W |𝒟_i| /f_i,j, C^cmp_i,j = T^cmp_i,j e_i,j^cmpθ_i,j
 


    C_cmp    = ∑_j=1^R ∑_i=1^N  C^cmp_i,j = ∑_j=1^R ∑_i=1^N θ_i,j p_i,j^2 E W |𝒟_i| e_i,j^cmp/f_i,j



The energy consumption in communication for N clients over R rounds, considering the hardware power for c_i to be e_i^com, can be represented by the formula C_com. Equation (<ref>) incorporates several factors, including the size of the model, denoted by S, in megabytes, the power of the router, e_r, and the power of the idle client, e_idle. The formula also considers the client's upload speed U and download speed D, measured in megabytes per second (MBps). In Equation (<ref>), p_i,j is the scaling factor of the model. Define the duration of the communication for transmitting model updates for client c_i at the round j as T^com_i,j.


    T^com_i,j= p_i,j^2 S (1/D+1/U)



    C^com_i,j   = T^com_i,jθ_i,j e_i,j^com = p_i,j^2 S (1/D+1/U) θ_i,j(e_r + e_i d l e, i)




    C_com   = ∑_j=1^R ∑_i=1^N  C^com_i,j
       = ∑_j=1^R ∑_i=1^N p_i,j^2 S(1/D+1/U) θ_i,j(e_r + e_i d l e, i)





In Equation (<ref>), we calculated the total carbon emitted for the c_i in the round j. In this context, we use a constant a_i,j to represent the constant value associated with the client c_i based on the number of local epochs and other hardware capacity parameters.


    C^FL_i,j   = C^cmp_i,j + C^com_i,j
       = p_i,j^2θ_i,j[ S(1/D+1/U)  (e_r + e_i d l e, i)+E W |𝒟_i| e_i,j^cmp/f_i,j] 
       =p_i,j^2θ_i,ja_i,j



Define a set 𝐩 with scaling rates of p_1, ..., p_m for a total of M clusters, where m ∈ [1, M]. By tuning 𝐩, we can minimize the carbon emissions produced during the training process to reach a target accuracy Ω. Suppose it takes R rounds to reach the target accuracy and if the client c_i belong to cluster m, then p_i,j = p_m. In Equation (<ref>), A_m is the average of ∑_i ∈ N_mθ_i,j a_i,j for the cluster m for R rounds, where N_m represents the set of clients in the cluster m.


    A_m = ∑_j=1^R ∑_i ∈ N_mθ_i,j a_i,j/R



    C_FL   = ∑_i=1^N ∑_j=1^R C^FL_i,j
       = ∑_m=1^M p_m^2 R ∑_j=1^R ∑_i ∈ N_mθ_i,j a_i,j/R = R ∑_m=1^M p_m^2 A_m



    *argmin_p_m ∈𝐩 C_FL(𝐩) = R ∑_m=1^M p_m^2 A_m


In Equation (<ref>), we want to minimize the total carbon cost C_FL(𝐩) by choosing the 𝐩 vector. As we will show in further experiments, R has a positive correlation with the inverse of the mean value of p_m ∈𝐩, denoted by μ(𝐩). R is also positively correlated to the standard deviation of p_m ∈𝐩, denoted by σ(p). 


    R ∝σ(𝐩)^β/μ(𝐩)^λ


In Equation (<ref>), λ is a constant based on the effect of the mean value on the accuracy rate of the model. β is another constant based on the effect of the standard deviation of scaling rate factors on the accuracy rate of the model. These constant parameters are based on the model architecture and diversity of data among the clients. By finding 𝐩, which minimizes the Equation (<ref>) we can find the minimum cost function for the federated system.  



    *argmin_p_m ∈𝐩 C_FL(𝐩) = (  σ(𝐩)^β/μ(𝐩)^λ∑_m=1^M p_m^2 A_m )





§ THE FEDGREEN ALGORITHM





The FedGreen algorithm aims to identify the set 𝐩, i.e., the scaling rate for the model size values that prioritizes minimizing carbon emissions while maintaining reasonable accuracy.
We have observed that carbon intensity of the clients depend on their geolocations and energy sources, which can lead to varying rates of carbon emissions produced by clients in each global round.
In this case, we aim to send models of different sizes to the clients based on the scaling rate of the cluster to which they will be assigned by their carbon profile. Under this method, each cluster of clients would have a scaling rate from parameters in 𝐩, which denotes as p_m. During the communication phase, the server then broadcasts the compressed model to a set of clients S_j in round j. On the client side, each sub-model runs E local iterations using its compressed model. The updated weights w_p(i,j) from each device i in round j are then sent to the server. The aggregation process should also be heterogeneous as the client updates are heterogeneous. To achieve this, the following aggregation method, shown in Equation (<ref>), is utilized to combine the client updates <cit.>.



    w_p_m^j+1\w_p_m-1^j+1=𝐖 𝐀({w_i_p_m^(i, j, E)\w_p_m-1^(i, j, E)}_i ∈𝒮_j^m)


In Equation (<ref>), w_p_m^j+1\w_p_m-1^j+1 are the weights belong to the model of cluster m and not cluster m-1 in the round j+1. 𝐖𝐀 represents the weighted average for updated weights of the clients in S_j^m = {i ∈ S_j : p_i,j≥ p_m}.





In the proposed FedGreen algorithm, the server performs clustering of the clients based on their θ_i values and number of clusters before starting the global epochs. This clustering helps to group clients with similar carbon intensity factors. Each cluster, denoted by m, is assigned a scaling rate of the model compression in 𝐩(the clusters with higher average θ_i will usually have lower scaling rates). In each global epoch, the server creates submodels of the original model based on the assigned scaling rate for each cluster. These submodels are then sent to the corresponding clients in their respective clusters. After the clients receive the submodels, they perform local epoch updates by training the submodel with their local data. Once the local weights w^(i, j, E) are updated, the clients send the weights back to the server for aggregation. Given the heterogeneity of the models, it follows that the updates for each client's model will also exhibit heterogeneity. To address this variation, we adopt the aggregation rule described in Equation (<ref>). Finally, the server updates the global model based on the averaged weights received from the clients. This iterative process of clustering, submodel distribution, local updates, and weight averaging allows FedGreen to dynamically adjust the size of the models sent to clients based on the carbon intensity of their location.









§ EVALUATION RESULTS






 §.§ Experimental Setups



  §.§.§ Simulation environment
 We assessed the performance of FedGreen using the NVIDIA GeForce 4070 Ti GPU as our hardware platform. In all the scenarios, the idle power consumption e_idle = 10 Watts. The power consumption of the clients and the router e_r = 4 Watts. Also, the average client power consumption rate e_client = 40 Watts.



  §.§.§ Dataset and model
 We utilized the EMNIST <cit.>, a dataset for character image classification. It contains 671K 28 × 28 images of digits and letters. As for the model, we employed a shallow CNN architecture with nearly 100,000 parameters, consisting of two convolutional layers.



  §.§.§ Configuration

The total number of clients was set to N = 80. In each global round, 10% of the clients, i.e., 8 clients, were selected for sending the model and learning process.
In this experiment, the mini-batch size was 16 for each step, the learning rate was 0.01, and the number of local epochs was set to E=1 and E=5. We used 80% of the data for training and 20% for testing on each client.



  §.§.§ User heterogeneity

In the context of the EMNIST dataset, we employed a Dirichlet distribution to simulate non-iid data, often denoted as Dir(α), where a smaller α value corresponds to greater data diversity. We illustrated how varying α values impact the statistical diversity within the EMNIST dataset by using 1 and 0.01 for the α values in our experiments.



  §.§.§ Carbon Profile

We set the carbon intensity rate θ using two methods. 
a) Actual carbon intensity. In the first scenario, we relied on data obtained from six different countries' carbon intensity mapsElectricity Maps. https://app.electricitymaps.com/map whose rates are obtained from governmental sources or on the website Climate Transparency. These countries and their corresponding carbon intensity values in grams per kilowatt-hour (g/kWh) for electricity consumption are as follows: Poland (895 g/kWh), Germany (441 g/kWh), Spain (236 g/kWh), Austria (155 g/kWh), France (47 g/kWh), and Sweden (15 g/kWh). b) Simulated carbon intensity. In the second scenario, we employed a simulated carbon intensity approach by considering six different carbon intensity rate values: 0.01 g/kWh, 0.1 g/kWh, 1 g/kWh, 10 g/kWh, 100 g/kWh, and 1000 g/kWh.







 §.§ Experimental Results







  §.§.§ Mean and standard deviation sensitivity analysis for 𝐩


To gauge the influence of the mean value for 𝐩, denoted by μ(𝐩), we manipulated the scaling rate while keeping the number of clusters at 1.
Specifically, when the p_i = 1, the entire model was transmitted to all clients, rendering our algorithm equivalent to the FedAvg <cit.>. Moreover, two distinct scenarios were considered in evaluating the 𝐩's standard deviation assigned to the clusters, denoted by σ(𝐩). In these instances, we held μ(𝐩) while altering the σ(𝐩). Notably, with three clusters, a particular value in the 𝐩 was fixed to match a consistent μ(𝐩).
As presented in Table <ref>, we specifically examined two scenarios: one with α set to 1, indicating a less non-IID data distribution, and another with α set to 0.01, which is a highly non-IID case. Corresponding to different α, fixed accuracy levels of 73% and 78% were employed.

A reduction in the mean value of the scaling rate is observed to correlate with a decrease in the associated carbon emission cost and a concurrent increase in the number of global epochs. This observed pattern holds across diverse non-IID settings and varying numbers of local epochs. Also, these results prove Equation (<ref>) that the number of rounds has an inverse correlation with the μ(𝐩) which the power of this relation λ  is based on the training and model parameters.



Our investigation into standard deviation analysis involved the examination of two distinct scenarios. In the initial scenario, we considered two clusters with a constant mean value for their scaling rate. Subsequently, in the second scenario, we explored three clusters, wherein we maintained the scaling rate of one cluster at the mean value of the three clusters while varying the scaling rates of the remaining two clusters. The results demonstrate that an increase in standard deviation in both the 2-cluster and 3-cluster cases leads to a consistent elevation in the number of epochs required to achieve a predetermined accuracy across all experiments. This escalation is particularly pronounced when the data exhibits greater non-IID characteristics. Specifically, when we had 2 clusters with 1 epoch for each global round, the impact on the increase in epochs was more pronounced, highlighting the sensitivity of the system's performance to non-IID data distribution. These results prove Equation (<ref>) which the number of rounds correlates with the σ(𝐩) which the power of this relation β is based on the data diversity between clients.The observed trend indicates that as the standard deviation rises, the number of epochs required for convergence increases while the carbon emissions per global epoch decreases. This underscores a discernible trade-off associated with increasing the standard deviation, suggesting the need for a judicious balance to achieve optimal outcomes.

From Table <ref>, it is observed that σ(𝐩) is more sensitive when α is smaller. Consequently, in instances of high data heterogeneity, a preliminary warm-up step in determining hyperparameters becomes imperative. 




  §.§.§ Clustering Sensitivity Analysis
 

We delved into the varying cluster numbers and compared outcomes across various scenarios with baseline approaches.

We introduced an augmented degree of standard deviation for scenarios involving two and three clusters, where the vector 𝐩 assumed the values of 0.2, 1 and 0.2, 0.6, 1, respectively, in concordance with the number of clusters under consideration. In this experiment, we explored four distinct scenarios characterized by variations in the α parameter, set at values of 1 and 0.01.
Additionally, we manipulated the local epoch count, considering both E=1 and E=5. In Fig. <ref>, each of the four distinct parameter configurations exhibits two distinct types of graphical representation. One depicts test accuracy as a function of the number of communication rounds, while the other illustrates test accuracy in relation to the carbon emissions measured in kilograms (kg). In these experiments, we used the real intensity scenario for the carbon profile of the clients. 

In Fig. <ref> and Fig. <ref>, it is evident that a substantial accuracy gap(9.6% and 9.4%) exists between the baseline, represented by FedAvg, and the scenarios involving two and three clusters. This discrepancy is noticeably significant, indicating the method's competence in handling highly non-IID data. Furthermore, 2.5% and 3.4% accuracy difference is also apparent between scenarios featuring two and three clusters and the one-cluster setting with equivalent mean values, particularly when employing only a single epoch. The observed gap diminishes as the number of epochs increases. This reduction in the gap can be attributed to the lower difference in the convergence rate of models with varying sizes, particularly when more epochs are employed in the process, as evident from Fig. <ref>.

For a more IID data distribution in Fig. <ref>, the disparity in test accuracy related to communication rounds between the two-cluster, three-cluster, and baselines is notably smaller. However, in Fig. <ref>, a discernible gap still persists, particularly in comparison to the FedAvg baseline, emphasizing the influence of the clustering configurations on carbon emission. In the scenario characterized by more IID data and a local epoch count of 5, the gap between the different cluster configurations is minimized. However, there still exists a noticeable accuracy gap between these configurations and the FedAvg baseline, as illustrated in Fig. <ref>.



  §.§.§ Carbon Intensity Profile Analysis
 
In this experiment, we conducted a comparison between the real carbon intensity profile, which includes data from six European countries, and the simulated carbon intensity profile. The simulated profile is characterized by a more significant value disparity between green and non-green clients, specifically concerning carbon intensity data. To assess the impact of this contrast, we introduced changes in the standard deviation of the 𝐩 vector for scenarios involving two and three clusters, as demonstrated in Fig. <ref>. As the plots illustrate, when the carbon profiles become more diverged, the gap in test accuracy between the three-cluster and two-cluster scenarios widens. In such cases, a higher standard deviation exerts a more pronounced influence, and the optimal point appears to align with this parameter.




§ CONCLUSION

 
In this paper, we proposed FedGreen to mitigate carbon emissions in FL by dynamically assigning model sizes to clients based on the carbon intensity rate of their respective locations. Additionally, we aimed to choose parameters optimally for our model size of different clusters of clients to achieve the best possible trade-off between accuracy rate and carbon emissions. Through a series of experiments, we demonstrated our proposed method's significant advantages and effectiveness.


