Asynchronous federated learning method based on grouping management
Through the asynchronous federated learning method based on group management, dynamically adjusting the client group number M, the problem of slow model convergence caused by device heterogeneity in the traditional asynchronous federated learning method is solved, and faster model training and higher model balance are achieved.
Patent Information
- Application Number
- CN202411682342.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-11
AI Technical Summary
The traditional asynchronous federated learning method causes the global model to converge slowly and even fail to converge due to device heterogeneity.
Async federated learning method based on group management is adopted to construct feature vectors through the client's device type and performance parameters, cluster grouping, and dynamically adjust the number of groups M to accelerate model training and convergence.
The convergence speed of the global model is improved, the impact of device heterogeneity on model accuracy is reduced, the balance of the model is increased, and resource waste is reduced.
Smart Images

Figure CN119599098A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of federated learning, and more specifically, the present invention relates to an asynchronous federated learning method based on group management. Background Art
[0002] Federated Learning (FL) is a distributed machine learning method in which multiple participants conduct model training, exchange model parameters and collaboratively train the optimal global model. There is no need to exchange local raw data containing user privacy information, which effectively avoids the emergence of data islands. It is widely used in market trade, intelligent transportation, smart healthcare, the Internet of Things and other fields. Researchers are still strengthening the privacy protection capabilities of federated learning.
[0003] Traditional federated learning uses a synchronous strategy to upload local model parameters of different clients. The server must wait for all clients to complete the same round of upload tasks before it can aggregate parameters and send the next round of model parameters, which greatly increases the training time. In order to reduce the time consumed by each round of aggregation in federated learning, an asynchronous federated learning method is proposed. The client that completes a round of local training immediately uploads the model, and the server selects the first few clients to upload for global training, instead of training the current round of global models based on the local models uploaded by all clients after all clients have completed local training.
[0004] However, due to the heterogeneity of client devices, the time required for each client to complete local training may vary greatly, which will affect the convergence speed of the global model, and more seriously, will cause the global model to fail to converge. Summary of the invention
[0005] The present invention provides an asynchronous federated learning method based on group management, aiming to improve the above problems.
[0006] The present invention is implemented as follows: an asynchronous federated learning method based on group management, the method comprising the following steps:
[0007] (1) After the client completes local training, it uploads the local model parameters w to the server;
[0008] (2) After receiving the local model parameters w uploaded by the specified number of groups of clients, the server aggregates the uploaded local model parameters w, updates the global model parameters W, and completes the current round of global training;
[0009] (3) The server updates the number of groups M participating in the next round of global training and sends the updated global model parameters W to the client that uploaded the local model;
[0010] (4) The client that receives the global model parameter W updates the local model parameter w to the received global model parameter W and starts the next round of local training.
[0011] Furthermore, the local training process of the client is as follows:
[0012] (11) The client v that has completed local training i The trained local model w i Sent to other clients in the group that have completed local training v j ;
[0013] (12) Client v j Received from client v i Model sent i , the model w i Add to waiting list j In the waiting list L j The models in are arranged in order from the front to the back based on the reception time;
[0014] (13) Client v j From the waiting list j Read the first model w j_1 , based on the currently read model w j_1 For client v j Its own local model w j Conduct training;
[0015] (14) After completing the training, the client v j Updated local model and deleted waiting list L j The first model in j_1 , detection list L j Is it empty? If the test result is yes, the client v j Upload the currently obtained local model to the server. If the detection result is no, execute step (13).
[0016] Furthermore, the training process is divided into an early training stage and a late training stage. The detection method for entering the late training stage is as follows:
[0017] The server detects whether there are any stale clients among all the clients. If so, it calculates the round interval ΔT between the current round and the last stale round T. If the round interval ΔT is greater than 2T0, the current round enters the late training stage. If the detection result is no, the current round is still in the early training stage.
[0018] Furthermore, the dynamic adjustment method of the M value in the early training stage is as follows:
[0019] (31) The server detects whether there is an outdated client among all the clients. If not, the current M value is used as the number of groups participating in the next round of global training; if so, a feature vector is constructed according to the performance parameters of the client, and the corresponding clients are clustered based on the feature vector to obtain the number of clusters n, each cluster is divided into a group, and steps (32) and (32) are executed;
[0020] (32) Update M to M = M + 1 - (n 0 -n), the updated M value is used as the number of groups participating in the next round of global training;
[0021] (33) The last obsolete round T is replaced by the current round.
[0022] Furthermore, the dynamic adjustment method of the M value in the later training stage is as follows:
[0023] (34) Let the last stale round T 0 = -∞;
[0024] (35) The server detects whether there is an outdated client among all the clients. If so, the M value is updated to M=M-1, and the updated M value is used as the number of groups participating in the next round of global training. If not, the current M value is used as the number of groups participating in the next round of global training.
[0025] Furthermore, the client grouping method is as follows:
[0026] Based on the device type and performance parameters of the client, the feature vector of the corresponding client is constructed, and the feature vectors of all clients are clustered to form multiple clusters, each of which corresponds to a group.
[0027] After the client completes the current round of local training, the weights w of all neurons in the last connection layer of the local model are calculated. last The mean value μ and variance σ of the training time t of the current round and the weights w of all neurons in the last connection layer last The mean μ and variance σ of are used as performance parameters.
[0028] Furthermore, the process of detecting whether the client is stale is as follows:
[0029] Determine the round T1 in which the current client last participated in global aggregation, calculate the round interval between the current round and round T1, and if the interval is greater than the set interval threshold, it is determined that the corresponding client is obsolete in the current round.
[0030] Furthermore, the initial value of the number of groups M is n / 2, where n is the number of groups formed by the first clustering.
[0031] Further, based on the waiting list L j The first model in j_1 For its own local model w j When continuing training, relative entropy and cross entropy are used as model w j_1 , model w j The loss function of .
[0032] The asynchronous federated learning method based on group management provided by the embodiment of the present invention has the following beneficial technical effects:
[0033] (1) The server dynamically selects several groups of clients for aggregation in each round, allowing the server to increase the average difference of the groups in the early stage of training. This solves the model imbalance phenomenon caused by the client blindly aggregating fast clients in asynchronous training. In the later stage of training, the grouping is reduced to speed up the aggregation speed and reduce unnecessary time consumption caused by balancing the model;
[0034] (2) A dynamic grouping strategy is adopted for clients, and the server dynamically selects several groups of clients for aggregation in each round. Clients with similar attributes are grouped together through feature vectors. At the same time, the model adjustment strategy further accelerates the consensus of models in the same group. The server can aggregate models from different groups with large differences each time, which reduces the impact of device heterogeneity on model accuracy and increases the balance of the overall model.
[0035] (3) During the model adjustment process, the fast client adjusts its own model based on the slow client, making the client models in the same group more consistent. During dynamic grouping, more consistent clients can be grouped together, reducing the probability of clients becoming obsolete, which means that model training can enter the later process faster. Since the clients are no longer re-clustered and grouped in the later process, the resource waste caused by repeated clustering is reduced, which speeds up the convergence of the overall model. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flow chart of the asynchronous federated learning method for group management provided in an embodiment of the present invention;
[0037] Figure 2 A schematic diagram of a client local training process provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The specific implementation modes of the present invention are further explained in detail below by describing the embodiments with reference to the accompanying drawings, so as to help those skilled in the art to have a more complete, accurate and in-depth understanding of the inventive concept and technical solution of the present invention.
[0039] Figure 1A flow chart of a group-managed asynchronous federated learning method provided in an embodiment of the present invention, the method is specifically as follows:
[0040] (1) After the client completes local training, it uploads the local model parameters w and the client performance parameters of the current round to the server;
[0041] In this embodiment of the present invention, after the client completes the current round of local training, the weights w of all neurons in the last connection layer of the local model are calculated. last The mean value μ and variance σ of the training time t of the current round and the weights w of all neurons in the last connection layer last The mean μ and variance σ of are used as client performance parameters and uploaded to the server together with the trained local model parameters.
[0042] In the embodiment of the present invention, since the speed at which each group of clients completes local training is also different, the fast client adjusts its own model based on the model formed by the slow client, so that the local models of the clients in the same group tend to be more consistent. When performing subsequent client grouping, more consistent clients can be grouped together, reducing the probability of clients becoming obsolete, which means that model training can enter the later process faster. Since the clients are no longer re-clustered and grouped in the later process, the waste of resources caused by repeated clustering is reduced, and the convergence speed of the overall model is accelerated. The process of training its own local client based on the model sent by other clients is specifically as follows:
[0043] (11) The client v that has completed local training i The trained local model w i Sent to other clients in the group that have completed local training v j ;
[0044] (12) Client v j Received from client v i Model sent i , the model w i Add to waiting list j In the waiting list L j The models in are arranged in order from the front to the back based on the reception time;
[0045] (13) Client v j From the waiting list j Read the first model w j_1 , based on the currently read model w j_1 For client v j Its own local model w j Conduct training;
[0046] (14) After completing the training, the client vj The local model is updated and the waiting list L is deleted j The first model in j_1 , detection list L j Is it empty? If the test result is yes, the client v j Upload the currently obtained local model to the server. If the detection result is no, execute step (13).
[0047] For each client, after basic training of the local model based on local samples, it is necessary to wait for the list L j The first model in j_1 For its own local model w j It should be noted that the last client in this group to complete basic training does not need to continue training its local model based on the models of other clients in this group. The basic training process uses cross entropy as the first loss function, while the loss function of the continued training process uses relative entropy and cross entropy as the second loss function. In the training process, the model w is calculated based on the second loss function. j_1 With local model w j The loss of the two models is calculated by adjusting the model w j_1 , local model w j , so that the sum of the two losses is minimized.
[0048] Combination Figure 2 The above process is explained in Section G. k The clients in the group are v1, v2, v3, and v4, and the training speed decreases in order from client v1 to client v4. After completing basic training, client v1 obtains model w1. After completing basic training, client v2 obtains model w2 and sends model w2 to client v1. After completing basic training, client v3 obtains model w3 and sends model w3 to client v1 and client v2 respectively. And so on. Client v1 will receive model w2, model w3 and model w4 sent by client v2, client v3 and client v4. Taking client v1 as an example, the training process is continued. First, model w1 and model w2 are jointly trained. Client v1 obtains an updated model w1′ of model w1. Then model w1′ and model w3 are jointly trained. Client v1 obtains an updated model w1″ of model w1′. Then model w1″ and model w4 are jointly trained. Client v1 obtains an updated model w″′1 of model w1″. Client v1 uploads model w″′1 to the server.
[0049] (2) After receiving the local model parameters w uploaded by all clients in the specified number of groups, the server aggregates the local model parameters w uploaded by the clients, updates the global model parameters W, and completes the current round of global training;
[0050] (3) The server updates the number of groups M participating in the next round of global training and sends the updated global model parameters W to the client that uploaded the local model;
[0051] In the group asynchronous process, when the server receives the local models sent by all clients in group M, it performs a global aggregation. When M is equal to the number of groups n, it needs to wait for all clients to complete a round of training before performing global aggregation. At this time, the semi-asynchronous process degenerates into a synchronous process. The time required to complete a global training is too long. Therefore, the value of M should not be too large. The initial M=n / 2. In the initial stage of training, a suitable initial value should be set for M to speed up the training process of the model. In the later stage of training, it should be gradually reduced to speed up the convergence of the model. Therefore, the present invention designs a dynamic adjustment method for M.
[0052] In the embodiment of the present invention, the training process is divided into two stages, an early training stage and a late training stage. The dynamic adjustment method of the M value in the early training stage is different from the dynamic adjustment method of the M value in the late training stage. The specific method for detecting whether the training process enters the late training stage is as follows:
[0053] The server detects whether there is a stale client among all the clients. If so, it calculates the time between the current round and the last stale round T 0 If the round interval ΔT is greater than 2T 0 , then the current training enters the late stage, if the test result is no, then the current is still in the early stage of training.
[0054] In the embodiment of the present invention, the method for dynamically adjusting the M value in the early training stage is specifically as follows:
[0055] (31) The server detects whether there is an outdated client among all the clients. If not, the M value is not updated, and the current M value is used as the number of groups participating in the next round of global training; if so, a feature vector is constructed according to the performance parameters of the client, and the corresponding clients are clustered based on the feature vector to obtain the number of clusters n, each cluster is divided into a group, and steps (32) and (32) are executed;
[0056] (32) Update M to M = M + 1 - (n 0 -n), the updated M value is used as the number of groups participating in the next round of global training;
[0057] (33) The last stale round T 0More current round.
[0058] When the server detects that there is an outdated client among all the clients, it means that the current client has not participated in global aggregation for a long time, and the model parameters of the corresponding client have not been updated in time. The M value should be increased to increase the possibility of the corresponding client participating in global aggregation.
[0059] In the early training stage, in order to dynamically adjust the grouping, the server needs to save the latest local model uploaded by each client, build the client's feature vector based on the local model parameters, and regroup all clients by clustering. Since the new grouping may change, n 0 Indicates the original number of groups, (n 0 -n) represents the number of reduced groups, M = M + 1-(n 0 -n) represents a relative increase so that M is closer to the maximum number of packets n.
[0060] In the example of the present invention, the clients are grouped based on the client performance parameters, and the clients with similar client performance are grouped into one group. The client grouping method is specifically as follows:
[0061] (21) uniquely encoding the device type of the client, and combining the device type of the client and the performance parameter into a feature vector corresponding to the client;
[0062] The types of client devices are divided into five categories according to their performance, namely IoT devices (smart homes, smart watches), mobile phones, tablets, laptops and desktop computers, and these devices are one-hot encoded to facilitate the subsequent construction of feature vectors.
[0063] Table 1 Encoding of different devices
[0064]
[0065]
[0066] The client's feature vector is represented as follows:
[0067] I′=[index,t,μ,σ 2 ]
[0068] Among them, one-hot encoding index = {[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,0,0]}
[0069] (22) The clients are normalized, and the feature vectors of each client are clustered based on the DBSCAN clustering algorithm to divide the clients into n groups.
[0070] In order to prevent the influence of different eigenvalues, the training time t of the current round in the eigenvector and the weights w of all neurons in the last connection layer are calculated. last The mean μ and variance σ of the feature vector are normalized so that the value of each feature vector I is in the range [0,1];
[0071]
[0072] Among them, I′ min I′ is the minimum value of training time t, mean μ, or variance σ among all client feature vectors. max is the maximum value of the training time t, mean μ, or variance σ among the feature vectors of all clients.
[0073] The DBSCAN clustering algorithm is used for clustering. Each feature vector is regarded as a point in the high-order space. For each point p, the distance between point p and other points q is calculated in turn. If the distance between point p and point q is less than the distance threshold ε, point q is added to the ε neighborhood N of point p. ε (p), expressed as:
[0074] N ε (p)={q∈D|dist(p,q)≤ε};
[0075] Wherein, D is a data set, dist(p,q) is the distance between point p and point q, and the present invention uses the Euclidean distance;
[0076] If |N ε (p)|≥MinPts, point q and its neighborhood N ε (p) The internal points correspond to the clients divided into a group, |N v (p)|<MinPts, then point q is considered as a noise point and point q is divided into a group separately, where |N ε (p)| represents the neighborhood N ε The number of points in (p).
[0077]
[0078] Wherein, |Y| represents the total number of label types of the samples, and ε is selected as a smaller number, ε=0.2. Based on the above clustering process, the number of client groups n and the group to which each client belongs can be determined.
[0079] In an embodiment of the present invention, the method for dynamically adjusting the M value in the later training stage is specifically as follows:
[0080] (34) Let the last stale round T 0 = -∞, in order to avoid jumping to the early and late training stages again;
[0081] (35) The server detects whether there is an outdated client among all the clients. If so, the M value is updated to M=M-1, and the updated M value is used as the number of groups participating in the next round of global training. If not, the M value is not updated, and the current M value is used as the number of groups participating in the next round of global training.
[0082] In the embodiment of the present invention, when the service detects whether there is a stale client in the current round, it needs to detect whether each client is stale. The detection process is as follows:
[0083] Determine the round T1 in which the current client last participated in global aggregation, calculate the round interval between the current round and round T1, and if the interval is greater than the set interval threshold, it is determined that the corresponding client is obsolete in the current round.
[0084] (4) The client that receives the global model parameter W updates the local model parameter w to the received global model parameter W and starts the next round of local training until the global model converges or the global training reaches the number threshold at this time, then the training process is stopped.
[0085] The present invention has been described exemplarily. Obviously, the specific implementation of the present invention is not limited to the above-mentioned method. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention, or the concept and technical solution of the present invention are directly applied to other occasions without improvement, they are all within the protection scope of the present invention.
Claims
1. An asynchronous federated learning method based on group management, characterized in that: The method comprises the following steps: (1) After the client completes local training, it uploads the local model parameters w to the server; (2) After receiving the local model parameters w uploaded by the specified number of groups of clients, the server aggregates the uploaded local model parameters w, updates the global model parameters W, and completes the current round of global training; (3) The server updates the number of groups M participating in the next round of global training and sends the updated global model parameters W to the client that uploaded the local model; (4) The client that receives the global model parameter W updates the local model parameter w to the received global model parameter W and starts the next round of local training.
2. The asynchronous federated learning method based on group management as claimed in claim 1, characterized in that: The local training process of the client is as follows: (11) The client v that has completed local training i The trained local model w i Sent to other clients in the group that have completed local training v j ; (12) Client v j Received from client v i Model sent i , the model w i Add to waiting list j In the waiting list L j The models in are arranged in order from the front to the back based on the reception time; (13) Client v j From the waiting list j Read the first model w j_1 , based on the currently read model w j_1 For client v j Its own local model w j Conduct training; (14) After completing the training, the client v j Updated local model and deleted waiting list L j The first model in j_1 , detection list L j Is it empty? If the test result is yes, the client v j Upload the currently obtained local model to the server. If the detection result is no, execute step (13).
3. The asynchronous federated learning method based on group management as claimed in claim 1, characterized in that: The training process is divided into the early training stage and the late training stage. The detection method for entering the late training stage is as follows: The server detects whether there is a stale client among all the clients. If so, it calculates the time between the current round and the last stale round T 0 If the round interval ΔT is greater than 2T 0 , then the current training enters the late stage, if the test result is no, then the current is still in the early stage of training.
4. The asynchronous federated learning method based on group management as claimed in claim 3, characterized in that: The dynamic adjustment method of the M value in the early training stage is as follows: (31) The server detects whether there is an outdated client among all the clients. If not, the current M value is used as the number of groups participating in the next round of global training; If it exists, construct a feature vector according to the performance parameters of the client, cluster the corresponding clients based on the feature vector, obtain the number of clusters n, divide each cluster into a group, and execute steps (32) and (32); (32) Update M to M = M + 1 - (n 0 -n), the updated M value is used as the number of groups participating in the next round of global training; (33) The last stale round T 0 More current round.
5. The asynchronous federated learning method based on group management as claimed in claim 3, characterized in that: The dynamic adjustment method of the M value in the later training stage is as follows: (34) Let the last stale round T 0 = -∞; (35) The server detects whether there is an outdated client among all the clients. If so, the M value is updated to M=M-1, and the updated M value is used as the number of groups participating in the next round of global training. If not, the current M value is used as the number of groups participating in the next round of global training.
6. The asynchronous federated learning method based on group management as claimed in claim 4, characterized in that: The client grouping method is as follows: Based on the device type and performance parameters of the client, the feature vector of the corresponding client is constructed, and the feature vectors of all clients are clustered to form multiple clusters, each of which corresponds to a group. After the client completes the current round of local training, the weights w of all neurons in the last connection layer of the local model are calculated. last The mean value μ and variance σ of the training time t of the current round and the weights w of all neurons in the last connection layer last The mean μ and variance σ of are used as performance parameters.
7. The asynchronous federated learning method based on group management as claimed in claim 4 or 5, characterized in that: The process of detecting whether a client is stale is as follows: Determine the round T1 in which the current client last participated in global aggregation, calculate the round interval between the current round and round T1, and if the interval is greater than the set interval threshold, it is determined that the corresponding client is obsolete in the current round.
8. The asynchronous federated learning method based on group management as claimed in claim 1, characterized in that: The initial value of the number of groups M is n / 2, where n is the number of groups formed by the first clustering.
9. The asynchronous federated learning method based on group management as claimed in claim 2, characterized in that: Based on the waiting list L j The first model in j_1 For its own local model w j When continuing training, relative entropy and cross entropy are used as model w j_1 , model w j The loss function of .