Federal learning method based on dynamic local training and gradient compression strategy

Through dynamic local training and gradient compression strategies, combined with sparsification, quantization and Lagrangian methods, the problem of limited communication resources of terminal devices in federated learning is solved, maximizing model performance and optimizing communication overhead.

CN118839752APending Publication Date: 2024-10-25SOUTHEAST UNIV

Patent Information

Application Number
CN202410974061.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-10-25

AI Technical Summary

Technical Problem

In federated learning, terminal devices cannot bear excessive communication overhead due to limited communication resources and high costs. Especially when using complex deep neural networks, the gradient vector uploaded by each client has high dimensions, causing communication to become a bottleneck.

Method used

Adopting dynamic local training and gradient compression strategies, through dynamic communication interval allocation and dynamic gradient compression technology, including sparsification and quantization algorithms, reduce communication frequency and single data upload overhead, combined with the Lagrangian method to optimize communication interval allocation, using Stochastic gradient descent algorithm and stochastic quantization algorithm reduce the complexity of gradient calculation and upload.

Benefits of technology

It effectively reduces communication overhead, maximizes model performance, solves the problem of federated learning model performance degradation, and achieves model performance improvement under communication overhead optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118839752A_ABST
    Figure CN118839752A_ABST
Patent Text Reader

Abstract

The invention discloses a federated learning method based on dynamic local training and a gradient compression strategy. During model training, the communication interval between a terminal and a central server in a local training strategy is dynamically adjusted, and meanwhile, the quantization bit number and the sparsification degree of gradient compression are dynamically adjusted during communication each time, so that the communication overhead is reduced through the mode. According to the method, the problem of overlarge communication overhead in federated learning can be solved, and the model availability is maximized while the communication overhead in the model training process is reduced. Compared with a traditional communication-saving federated learning method, the method provided by the invention can obtain better performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of federated learning, relates to local training and gradient compression, and in particular to a federated learning method based on dynamic local training and gradient compression. Background Art

[0002] Federated learning has been widely used in all aspects of life, and has many practical applications in the fields of medicine, environmental protection, manufacturing, etc. However, although the terminal data does not need to be uploaded to the central server in federated learning, thus saving communication overhead, in the context of federated learning, the terminal devices participating in the training, such as smartphones and tablets, usually face limited communication resources and high-cost network connection problems, and therefore cannot afford excessive communication overhead. In addition, the machine learning applications currently deployed on terminal devices are increasingly using complex deep neural networks. In this case, the gradient vector uploaded by each client has a high dimension, which makes communication a serious bottleneck problem. Therefore, it is necessary to adopt a communication overhead optimization strategy in federated learning to further reduce the communication overhead. The communication overhead optimization algorithm for the data transmission process of federated learning includes reducing the communication frequency and reducing the overhead of a single data upload. The local training method can be used to reduce the communication frequency. In local training, the model is iterated multiple times on the terminal device, and the model update is uploaded after reaching the preset communication interval for the update of the global model. In gradient compression, the amount of data uploaded in a single time can be reduced by using sparse algorithms and quantization algorithms. Summary of the invention

[0003] The purpose of the present invention is to provide a federated learning method based on dynamic local training and gradient compression. On the one hand, this method can meet the demand of reducing communication overhead, and on the other hand, it can maximize model availability, thereby improving model performance and solving the problem of performance degradation of the current federated learning model based on local training and gradient compression.

[0004] In order to solve the above technical problems, the specific technical solutions of the present invention are as follows:

[0005] A federated learning method based on dynamic local training and gradient compression strategy, optionally using dynamic communication interval allocation technology and dynamic gradient compression technology, the method comprising the following steps:

[0006] Step 1: Set the total number of iterations of model training T and the total communication cost B tot , total number of communications R. The central server initializes the model parameters x0 and the communication interval H1;

[0007] Step 2: Terminal 1 to terminal N use local data to calculate the gradient If the communication interval is not reached, the gradient is used to calculate the local model. Otherwise, the model update amount of this local training is sparsely and quantized and then uploaded to the central server.

[0008] Step 3: The central server aggregates the gradients uploaded by each terminal and averages the gradients And update the global model parameters x1 = x0-ηg agg According to problem P1, the communication interval allocation mechanism is obtained to update the communication interval H, and the above parameters are sent to each terminal;

[0009] Step 4: After completing the training of a model, if the number of communications reaches R, stop the training; otherwise, return to step 2.

[0010] Optionally, the privacy budget allocation subproblem P1 is constructed as:

[0011]

[0012] Where T represents the total number of iterations, r represents the rth communication, and R represents the total number of communications. β represents the convergence coefficient, L represents the smoothness coefficient of the loss function, and H r represents the communication interval of the rth communication. η represents the learning rate. d represents the dimension of the gradient. c represents the number of bits allocated to each local model update on average.

[0013] Optionally, the Lagrangian method is used to solve the constrained optimization problem P1. The specific steps include:

[0014] Step 3.1. Write the Lagrangian function of problem P1:

[0015]

[0016] Where λ represents the Lagrange multiplier;

[0017] Step 3.2: Lagrangian function for H r Taking the derivative and setting it to 0, we can get H r :

[0018]

[0019] Among them, β is approximately estimated as F(x) represents the empirical risk function;

[0020] Step 3.3, take the derivative of the Lagrangian function with respect to λ and set the derivative to 0, we have:

[0021]

[0022] Add H from step 3.2 rSubstituting λ into the expression obtained in step 3.2, we can get H r .

[0023] Optionally, local training is used in step 2 to reduce the communication frequency. It is expressed as follows:

[0024]

[0025] in, are the local model parameters of device i at iteration t, is the gradient calculated by device i at time t, η is the learning rate, N is the total number of terminals, and H is the communication interval.

[0026] Optionally, in step 2, a sparse algorithm is used to reduce the single upload bit, wherein the sparse algorithm Rand-K based on random selection is used to convert the d-dimensional gradient g into its sparse representation That is, some elements of g are replaced with 0. The k non-zero elements of are equal to the corresponding elements of g. Sparsification can be viewed as applying a mask vector m∈{0,1} of the same dimension d to the gradient g. d , that is

[0027] Optionally, in step 2, a quantization algorithm is used to reduce the single upload bit, wherein the quantization strategy uses the random quantization algorithm QSGD. For a d-dimensional gradient g, QSGD quantizes its j-th element as:

[0028] Q s (g j )=||g||2*sgn(g j )*ω j (g,s)

[0029] Among them, ||||2 represents the L2 norm, Q s is the QSGD quantization with quantization level s, ω j (g,s) is the absolute value of the jth element of vector g after quantization, ω j (g,s) can be written as:

[0030]

[0031] Among them, l is the quantization interval of the jth element of vector g, and the probability function It can be expressed as:

[0032]

[0033] Optionally, in step 3, the average of the aggregated gradients is used to update the global model, where the aggregated gradient is expressed as:

[0034]

[0035] in, represents the model update calculated by terminal i, which can be expressed as:

[0036]

[0037] in, represents the local model parameters of terminal i at the end of the rth local training, represents the local model parameters of terminal i at the beginning of the rth local training.

[0038] Optionally, the local model update in step 2 uses the stochastic gradient descent algorithm. In the stochastic gradient descent algorithm, the gradient calculation only uses small batches of data. A stochastic gradient calculation includes the following steps:

[0039] Step 2.1: Terminal device i randomly extracts some local data and calculates the loss function:

[0040]

[0041] in For terminal i, the model parameters are When the input data The prediction results;

[0042] Step 2.2: Make the loss function affect the model parameters Derivative, get the stochastic gradient:

[0043]

[0044] in, Utilize data ξ for terminal i i The calculated loss function. Using stochastic gradient descent can reduce the time complexity of a gradient calculation and escape from the local optimal solution.

[0045] The federated learning method based on dynamic local training and gradient compression strategy of the present invention has the following advantages: Compared with the prior art, the present invention solves the allocation scheme of dynamic local training communication intervals, and dynamically adjusts the gradient compression strategy of each data upload, solving the problem of maximizing model performance under the condition of total communication overhead. We provide a general federated learning method based on dynamic local training and gradient compression strategy. Compared with the existing federated learning method based on local training or gradient compression single strategy, the combined method of combining local training and gradient compression of the present invention can greatly improve the performance, and further improve the performance under the requirement of ensuring the reduction of communication overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is a system diagram of the federated learning method based on dynamic local training and gradient compression strategy of the present invention.

[0047] Figure 2 A schematic diagram of a model update performed by the algorithm used in the present invention. DETAILED DESCRIPTION

[0048] In order to better understand the purpose, structure and function of the present invention, the following further describes in detail a federated learning method based on a dynamic local differential privacy strategy of the present invention in conjunction with the accompanying drawings.

[0049] The present invention considers a federated learning system based on dynamic local training and gradient compression, assuming a federated learning based on a client-server architecture. Specifically, the problem of federated learning based on dynamic local training and gradient compression is to maximize model availability under the constraint of total communication overhead.

[0050] The specific steps include:

[0051] Consider a federated learning model based on a client-centric server architecture, such as Figure 1 As shown, under this architecture, federated learning includes 1 central server and N terminal devices. In an embodiment of the present invention, dynamic communication interval allocation technology and dynamic gradient compression technology are adopted, and the method includes the following steps:

[0052] Step 1: Set the total number of iterations of model training T and the total communication cost B tot , total number of communications R. The central server initializes the model parameters x0 and the communication interval H1;

[0053] In an embodiment of the present invention, in order to limit the training time of a neural network training under a federated learning model based on a client-centric server architecture, a total number of iterations needs to be set. In order to limit the size of the total communication overhead to reduce the communication burden, a total communication overhead constraint is set.

[0054] Step 2: Terminal 1 to terminal N use local data to calculate the gradient If the communication interval is not reached, the gradient is used to calculate the local model. Otherwise, the model update amount of this local training is sparsely and quantized and then uploaded to the central server.

[0055] In an embodiment of the present invention, the local model is updated using a stochastic gradient descent algorithm. In the stochastic gradient descent algorithm, the gradient calculation uses only small batches of data, and a stochastic gradient calculation includes the following steps:

[0056] Step 2.1: Terminal device i randomly extracts some local data and calculates the loss function:

[0057]

[0058] in For terminal i, the model parameters are When the input data The prediction results;

[0059] Step 2.2: Make the loss function affect the model parameters Derivative, get the stochastic gradient:

[0060]

[0061] in, Utilize data ξ for terminal i i The calculated loss function. Using stochastic gradient descent can reduce the time complexity of a gradient calculation and escape from the local optimal solution.

[0062] After the gradient is calculated, since local training is used in step 2 to reduce the communication frequency, when the communication interval is not reached, the local model parameters are updated on the local device using the gradient. When the communication interval is reached, the local model parameters are updated and uploaded to the central server. After the central server updates the global parameters, the model parameters are sent back to the terminal device for the next round of local training. It is expressed as follows:

[0063]

[0064] in, are the local model parameters of device i at iteration t, is the gradient calculated by device i at time t, η is the learning rate, N is the total number of terminals, and H is the communication interval.

[0065] When the communication interval condition is met, the terminal device uses the sparse and quantized algorithm to compress the uploaded data. The sparse algorithm Rand-K based on random selection is used to convert the d-dimensional gradient g into its sparse representation. That is, some elements of g are replaced with 0. The k non-zero elements of are equal to the corresponding elements of g. Sparsification can be viewed as applying a mask vector m∈{0,1} of the same dimension d to the gradient g. d , that is

[0066] The quantization strategy uses the random quantization algorithm QSGD. For a d-dimensional gradient g, QSGD quantizes its j-th element as:

[0067] Q s (g j )=||g||2*sgn(gj )*ω j (g,s)

[0068] Among them, Q s is the QSGD quantization with quantization level s, ω j (g,s) is the absolute value of the jth element of vector g after quantization, ω j (g,s) can be written as:

[0069]

[0070] Among them, l is the quantization interval of the jth element of vector g, and the probability function It can be expressed as:

[0071]

[0072] Step 3: The central server aggregates the gradients uploaded by each terminal and averages the gradients And update the global model parameters x1 = x0-ηg agg According to problem P1, the communication interval allocation mechanism is obtained to update the communication interval H, and the above parameters are sent to each terminal;

[0073] In an embodiment of the present invention, the communication interval allocation sub-problem P1 is constructed as:

[0074]

[0075] Where T represents the total number of iterations, r represents the rth communication, and R represents the total number of communications. β represents the convergence coefficient, L represents the smoothness coefficient of the loss function, and H r represents the communication interval of the rth communication. η represents the learning rate. d represents the dimension of the gradient. c represents the number of bits allocated to each local model update on average.

[0076] In an embodiment of the present invention, the Lagrangian method is used to solve the constrained optimization problem P1, and the specific steps include:

[0077] Step 3.1. Write the Lagrangian function of problem P1:

[0078]

[0079] Where λ represents the Lagrange multiplier;

[0080] Step 3.2: Lagrangian function for H r Taking the derivative and setting it to 0, we can get H r :

[0081]

[0082] Among them, β is approximately estimated as F(x) represents the empirical risk function;

[0083] Step 3.3, take the derivative of the Lagrangian function with respect to λ and set the derivative to 0, we have:

[0084]

[0085] Add H from step 3.2 r Substituting λ into the expression obtained in step 3.2, we can get H r .

[0086] Step 4: After completing the training of a model, if the number of communications reaches R, stop the training; otherwise, return to step 2.

[0087] Model training in machine learning is an iterative process that requires adaptive adjustment of model parameters based on model performance. Therefore, iterations must be repeated until the set training end conditions are reached.

[0088] The present invention studies a federated learning method based on dynamic local training and gradient compression strategy. Through this method, federated learning can maximize model performance while reducing communication overhead. This method fully considers the impact of communication saving strategy on model convergence, and dynamically adjusts the communication interval and the amount of data uploaded in a single communication to achieve a balance between model performance and communication overhead. Compared with the federated learning method based on a single communication saving strategy, the dynamic local training and gradient compression joint method proposed in the present invention can achieve better performance while optimizing communication overhead.

[0089] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.

Claims

1. A federated learning method based on dynamic local training and gradient compression strategy, It is characterized in that The method comprises the following steps: Step 1: Set the total number of iterations of model training T and the total communication cost B tot , total number of communications R; the central server initializes the model parameters x 0 , initialize the communication interval H 1 ; Step 2: Terminal 1 to terminal N use local data to calculate the gradient i=1, ..., N, if the communication interval is not reached, the gradient is used to calculate the local model. Otherwise, the model update amount of this local training is sparsely and quantized and then uploaded to the central server; Step 3: The central server aggregates the gradients uploaded by each terminal and averages the gradients in, represents the local aggregate gradient uploaded by device i, N represents the total number of terminals, g agg It represents the global aggregate gradient after the central server averages the aggregate gradients uploaded by each device and updates the global model parameter x 1 =x 0 -ηg agg , where x 0 To initialize the global model parameters, x 1 is the global model parameter after the first model update, η is the learning rate; according to the communication interval dynamic mechanism sub-problem P1, the communication interval allocation mechanism is obtained to update the communication interval H r , send the above parameters to each terminal; Step 4: After completing a model training, if the number of communications reaches R, stop training; otherwise, return to step 2.

2. The federated learning method based on dynamic local training and gradient compression strategy according to claim 1, It is characterized in that The communication interval dynamic mechanism subproblem P1 is constructed as: Where T represents the total number of iterations, r represents the rth communication, R represents the total number of communications, β represents the convergence coefficient, L represents the smoothness coefficient of the loss function, and H r represents the communication interval of the rth communication, η represents the learning rate, d represents the dimension of the gradient, and c represents the average number of bits allocated to each local model update.

3. The federated learning method based on dynamic local training and gradient compression strategy according to claim 2, It is characterized in that The Lagrangian method is used to solve the constrained optimization problem P1. The specific steps include: Step 3.1, give the Lagrangian function of problem P1: Where λ represents the Lagrange multiplier; Step 3.2: Lagrangian function for H r Taking the derivative and setting it to 0, we get H r : Among them, β is approximately estimated as F(x) represents the empirical risk function; Step 3.3, take the derivative of the Lagrangian function with respect to λ and set the derivative to 0, we have: Add the H from step 3.2 r Substituting λ into the expression obtained in step 3.2, we can get H r .

4. The federated learning method based on dynamic local training and gradient compression strategy according to claim 1, It is characterized in that In step 2, local training is used to reduce the communication frequency, which is expressed as follows: in, are the local model parameters of device i at iteration t, is the gradient calculated by device i at time t, η is the learning rate, N is the total number of terminals, and H is the communication interval.

5. The federated learning method based on dynamic local training and gradient compression strategy according to claim 1, It is characterized in that In step 2, a sparse algorithm is used to reduce the single upload bit, where the sparse algorithm Rand-K based on random selection is used to convert the d-dimensional gradient g into its sparse representation That is, some elements of g are replaced with 0; The k non-zero elements of are equal to the corresponding elements of g; Sparsification is seen as applying a mask vector m∈{0,1} of the same dimension d to the gradient g. d , that is 6. The federated learning method based on dynamic local training and gradient compression strategy according to claim 1, It is characterized in that In step 2, a quantization algorithm is used to reduce the single upload bit, where the quantization strategy uses the random quantization algorithm QSGD; for a d-dimensional gradient g, QSGD converts its j-th element g j Quantized to: Q s (g j )=||g|| 2 *sgn(g j )*ω j (g,s) Among them, Q s is the QSGD quantization with quantization level s, ω j (g,s) is the absolute value of the jth element of vector g after quantization, ω j (g,s) can be written as: Among them, l is the quantization interval of the jth element of vector g, and the probability function It is expressed as:

7. The federated learning method based on dynamic local training and gradient compression strategy according to claim 1, It is characterized in that In step 3, the average of the aggregated gradients is used to update the global model, where the aggregated gradient is expressed as: in, represents the model update calculated by terminal i, expressed as: in, represents the local model parameters of terminal i at the end of the rth local training, represents the local model parameters of terminal i at the beginning of the rth local training.

8. The federated learning method based on dynamic local training and gradient compression strategy according to claim 1, It is characterized in that Step 2: The local model is updated using the stochastic gradient descent algorithm. In the stochastic gradient descent algorithm, the gradient calculation only uses small batches of data. A stochastic gradient calculation includes the following steps: Terminal device i randomly extracts some local data to calculate the loss function: in For terminal i, the model parameters are When the input data The prediction results; Make the loss function dependent on the model parameters Derivative, get the stochastic gradient: in, Utilize data ξ for terminal i i The calculated loss function.

Citation Information

Patent Citations

  • Efficient federated learning method based on gradient compression

    CN118333182A

Cited By

  • Federal fine tuning method and device based on interval compression and related product

    CN120124691A

  • Large language model distributed training method and system based on dynamic resource scheduling

    CN120278283A

  • Large language model distributed training method and system based on dynamic resource scheduling

    CN120278283B