A model training method and device

By selecting a subset of gradients for model updates in federated learning, the problem of gradient direction discrepancies caused by non-independent and identically distributed user data is resolved, communication overhead is reduced, and model training efficiency is improved.

CN115907041BActive Publication Date: 2026-05-08HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2022-11-02
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

In federated learning, when user data is not independent and identically distributed, the gradient directions of each user node after iteration differ significantly, causing the server to be unable to obtain effective model gradient update directions, resulting in slow model convergence and excessive communication consumption.

Method used

The server selects a subset of gradients for model updates, including selecting the gradients corresponding to the updated first parameter and the unupdated second parameter from the previous iteration of federated learning. By aggregating and fusing these gradients, the target model is updated, and the updated information is transmitted to the terminal device.

Benefits of technology

This effectively reduces the amount of gradient transmission from the server to the terminal, ensuring that the downlink communication compression effect is not degraded and improving the efficiency of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115907041B_ABST
    Figure CN115907041B_ABST
Patent Text Reader

Abstract

The application discloses a model training method applied to the field of federated learning, and comprises the following steps: obtaining a plurality of first gradients and a plurality of second gradients; the plurality of first gradients are gradients corresponding to a plurality of first parameters in a target model; the plurality of second gradients are gradients corresponding to a plurality of second parameters in the target model; the plurality of first parameters are updated in a last round iteration of federated learning, and the plurality of second parameters are not updated in the last round iteration of federated learning; selecting part of the gradients from the plurality of first gradients and the plurality of second gradients, the part of the gradients being used for updating the target model in a current round iteration of federated learning; and delivering information of the updated target model to a plurality of first devices; wherein the plurality of first devices belong to the plurality of terminals. In the application, the server only selects and updates the values of part of the parameters in the target model each time, so that the gradient transmission amount of the server to the terminals can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular to a model training method and apparatus. Background Technology

[0002] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0003] Federated learning systems train machine learning models based on data generated from interactions between a large number of users and their devices (e.g., smartphones), without needing to retrieve data from the devices. For example, each iteration selects a subset of online devices, and the current version of the machine learning model is sent to those selected devices. Each of those selected devices is tasked with computing an update to the model using data it generates and stores locally. The model update is then sent back to the server, averaged, and applied to the server's model to produce a new version of the model for the next iteration with the users (e.g., the next subset of devices).

[0004] Federated learning consists of two steps: model distribution and model upload. The central node distributes the model to the terminal devices via the network; each terminal device uses local data to calculate the gradient of the model; each distributed node encrypts the gradient and uploads it to the central node; the central node aggregates the gradients of each terminal distributed node and updates the parameters of the central node model using a parameter averaging algorithm.

[0005] At the start of training, the server sends an initial model to each client. Subsequently, each client iterates the model using local data and feeds back the changes in the model (i.e., the gradients corresponding to the parameters) to the server. The server performs a weighted average of the fed-back gradients, updates the initial model with the resulting average gradient, and distributes the updated model to each client user, restarting the next iteration.

[0006] The problem with existing federated training frameworks is that when user data is not independently and identically distributed, the significant differences in gradient directions among user nodes after iterations prevent the server from obtaining an effective model gradient update direction. This leads to slow convergence of the server model and necessitates extensive back-and-forth gradient propagation between users and the server, consuming substantial communication bandwidth. Furthermore, in the current network environment, the growth rate of overall network bandwidth is far slower than the growth rate of neural network model size. Therefore, effectively reducing communication overhead is a critical issue that needs to be addressed in federated learning. Summary of the Invention

[0007] This application provides a model training method that can effectively reduce the amount of gradient transmission from the server to the terminal.

[0008] In a first aspect, this application provides a model training method applied to a server, the server communicating with multiple terminals, the method comprising: acquiring multiple first gradients and multiple second gradients; the multiple first gradients being gradients corresponding to multiple first parameters in a target model; the multiple second gradients being gradients corresponding to multiple second parameters in the target model; the multiple first parameters being updated in the previous iteration of federated learning, and the multiple second parameters not being updated in the previous iteration of federated learning; selecting a portion of gradients from the multiple first gradients and the multiple second gradients, the portion of gradients being used to update the target model in the current iteration of federated learning; and transmitting the updated target model information to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

[0009] Since the target model only selects and updates the values ​​of some parameters each time, the amount of gradient transmission from the server to the terminal can be effectively reduced.

[0010] In one possible implementation, the partial gradient is the largest of the plurality of first gradients and the plurality of second gradients.

[0011] In one possible implementation, the plurality of first gradients are obtained by aggregating a plurality of third gradients sent by a plurality of second devices in the current iteration round; the plurality of second gradients are obtained based on the gradients corresponding to the plurality of second parameters determined in the previous iteration round and the plurality of fourth gradients sent by the plurality of second devices in the current iteration round; the plurality of second devices belong to the plurality of terminals.

[0012] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the first model, the first model being a model obtained by updating the target model in iterations prior to the current iteration; before obtaining the multiple first gradients and multiple second gradients, the method further includes: broadcasting the updated parameter values ​​of the first model to the multiple terminals.

[0013] By employing the above methods, the number of gradient differences between the latest target model and the end-user model is reduced, thereby ensuring that the downlink traffic compression effect is not degraded.

[0014] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

[0015] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is a model obtained by the first target device updating the target model in the iterations prior to the current iteration; the step of transmitting the updated target model information to the plurality of first devices includes: transmitting the parameter update amount of the updated target model relative to the third model to the first target device.

[0016] In one possible implementation, the iteration round preceding the current iteration round specifically refers to the iteration round in which the first target device last updated the target model before the current iteration round.

[0017] The server can maintain a list of existing target models for end-users. When sending updates, it performs a difference calculation with the corresponding common model parameters on the end-user, thereby improving the communication compression of gradient transmission. Through this method, the server maintains the latest model parameter list for end-users, thus reducing the number of gradient differences between the latest target model and the end-user model when transmitting gradients, thereby maximizing the downlink communication compression effect.

[0018] Secondly, this application provides a system comprising a server and multiple terminals, wherein the server communicates with the multiple terminals, wherein...

[0019] The server is used to obtain multiple first gradients and multiple second gradients; the multiple first gradients are gradients corresponding to multiple first parameters in the target model; the multiple second gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters are updated in the previous iteration of federated learning, and the multiple second parameters are not updated in the previous iteration of federated learning.

[0020] Selecting a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of the federated learning;

[0021] The updated target model information is transmitted to multiple first devices; wherein the multiple first devices and the multiple second devices belong to the multiple terminals.

[0022] In one possible implementation, the partial gradient is the largest of the plurality of first gradients and the plurality of second gradients.

[0023] In one possible implementation, multiple second devices among the multiple terminals are used to send multiple third gradients and multiple fourth gradients to the server; the multiple third gradients are gradients corresponding to multiple first parameters in the target model; the multiple fourth gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning; the multiple second parameters were not updated in the previous iteration of federated learning.

[0024] The server is specifically used to aggregate the multiple third gradients to obtain multiple first gradients;

[0025] The multiple fourth gradients are aggregated and fused with the gradients corresponding to the multiple second parameters determined in the previous iteration to obtain multiple second gradients.

[0026] In one possible implementation, the multiple second devices among the multiple terminals are specifically used to determine multiple gradients corresponding to the target model in the previous iteration of federated learning; and to randomly select the multiple third gradients and multiple fourth gradients from the multiple gradients.

[0027] In one possible implementation, the plurality of second devices among the plurality of terminals are specifically used to perform lossless compression or linear unbiased compression on the information indicating the plurality of third gradients and the plurality of fourth gradients, and send the compression result to the server.

[0028] Linear unbiased compression refers to a compression method that possesses linearity. The compressed data can be subjected to linear operations before decompression, and the result obtained is the same as that obtained by performing the same linear operations on the uncompressed original data.

[0029] Unbiased compression refers to compression where the error between the compressed result and the original data is zero-mean.

[0030] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is a model obtained by updating the target model in the iterations prior to the current iteration;

[0031] The server is also configured to broadcast the updated parameter values ​​of the first model to the multiple terminals before acquiring the multiple first gradients and multiple second gradients.

[0032] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

[0033] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is a model obtained by the first target device updating the target model in the iterations prior to the current iteration;

[0034] The server is specifically used to transmit the updated parameter update amount of the target model relative to the third model to the first target device.

[0035] In one possible implementation, the iteration round preceding the current iteration round specifically refers to the iteration round in which the first target device last updated the target model before the current iteration round.

[0036] Thirdly, this application provides a model training device applied to a server, the server communicating with multiple terminals, the device comprising:

[0037] An acquisition module is used to acquire multiple first gradients and multiple second gradients; the multiple first gradients are gradients corresponding to multiple first parameters in the target model; the multiple second gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning, and the multiple second parameters were not updated in the previous iteration of federated learning.

[0038] A gradient selection module is used to select a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of federated learning;

[0039] A sending module is used to transmit the updated target model information to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

[0040] In one possible implementation, the partial gradient is the largest of the plurality of first gradients and the plurality of second gradients.

[0041] In one possible implementation, the plurality of first gradients are obtained by aggregating a plurality of third gradients sent by a plurality of second devices in the current iteration round; the plurality of second gradients are obtained based on the gradients corresponding to the plurality of second parameters determined in the previous iteration round and the plurality of fourth gradients sent by the plurality of second devices in the current iteration round; the plurality of second devices belong to the plurality of terminals.

[0042] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is a model obtained by updating the target model in the iterations prior to the current iteration;

[0043] The sending module is further configured to: broadcast the updated parameter values ​​of the first model to the multiple terminals before acquiring the multiple first gradients and multiple second gradients.

[0044] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

[0045] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is a model obtained by the first target device updating the target model in the iterations prior to the current iteration;

[0046] The sending module is specifically used to: transmit the updated parameter update amount of the target model relative to the third model to the first target device.

[0047] In one possible implementation, the iteration round preceding the current iteration round specifically refers to the iteration round in which the first target device last updated the target model before the current iteration round.

[0048] Fourthly, embodiments of this application provide a model training apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the first aspect and any optional method of the first aspect.

[0049] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect or any of its alternatives.

[0050] Sixthly, embodiments of this application provide a computer program that, when run on a computer, causes the computer to perform the first aspect and any of its optional methods described above.

[0051] Seventhly, this application provides a chip system including a processor for supporting an execution device in implementing the functions involved in the foregoing aspects, such as transmitting or processing data involved in the foregoing methods; or, information. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the execution device or training device. This chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description

[0052] Figure 1 A structural diagram illustrating the main framework of artificial intelligence;

[0053] Figure 2 This is a schematic diagram of the computing system for performing model training in the embodiments of this application;

[0054] Figure 3 This is a schematic diagram of a system architecture provided in an embodiment of this application;

[0055] Figure 4 A schematic diagram of the architecture of a model training method provided in an embodiment of this application;

[0056] Figure 5 A flowchart illustrating a model training method provided in an embodiment of this application;

[0057] Figures 6 to 9 This application provides an example of a model training method.

[0058] Figure 10 A schematic diagram of a model training device provided in an embodiment of this application;

[0059] Figure 11 A schematic diagram of the structure of the execution device provided in the embodiments of this application;

[0060] Figure 12 This is a schematic diagram of a training device provided in an embodiment of this application;

[0061] Figure 13 This is a schematic diagram of a chip structure provided in an embodiment of this application. Detailed Implementation

[0062] The embodiments of the present invention will now be described with reference to the accompanying drawings. The terminology used in the embodiments section is for illustrative purposes only and is not intended to limit the scope of the invention.

[0063] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0064] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.

[0065] First, the overall workflow of the artificial intelligence system is described; please refer to [link / reference]. Figure 1 , Figure 1 The diagram illustrates a structural framework for artificial intelligence (AI). The framework is further elaborated below along two dimensions: the "Intelligent Information Chain" (horizontal axis) and the "IT Value Chain" (vertical axis). The "Intelligent Information Chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT Value Chain" reflects the value that AI brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed through technological means) to the industrial ecosystem of the system.

[0066] (1) Infrastructure

[0067] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips (hardware acceleration chips such as CPUs, NPUs, GPUs, ASICs, and FPGAs); and the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, and this data is provided to intelligent chips in the distributed computing system provided by the basic platform for computation.

[0068] (2) Data

[0069] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.

[0070] (3) Model Training

[0071] Model training typically includes data training, machine learning, deep learning, search, inference, and decision-making.

[0072] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training of data by symbolizing and formalizing it.

[0073] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.

[0074] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.

[0075] (4) General ability

[0076] After training the data using the model mentioned above, further general capabilities can be formed based on the training results. These capabilities could be algorithms or general systems, such as translation, text analysis, computer vision processing, speech recognition, image recognition, and so on.

[0077] (5) Smart Products and Industry Applications

[0078] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, and safe cities.

[0079] Figure 2 This is a schematic diagram of a computing system for performing model training in an embodiment of this application. The computing system includes a terminal device 102 (hereinafter referred to as the first device and the second device) and a server 130 (also referred to as the central node) coupled via a network communication. The terminal device 102 can be any type of computing device, such as, for example, a personal computing device (e.g., a laptop computer or desktop computer), a mobile computing device (e.g., a smartphone or tablet computer), a game console or controller, a wearable computing device, an embedded computing device, or any other type of computing device.

[0080] Terminal device 102 may include processor 112 and memory 114. Processor 112 may be any suitable processing device (e.g., processor core, microprocessor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), controller, microcontroller, etc.). Memory 114 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or compact disc read-only memory (CD-ROM). Memory 114 may store data 116 and instructions 118 executed by processor 112 to cause terminal device 102 to perform operations.

[0081] In some implementations, memory 114 may store one or more models 120. For example, model 120 may be or may additionally include various machine learning models, such as neural networks (e.g., deep neural networks) or other types of machine learning models, including nonlinear and / or linear models. Neural networks may include feedforward neural networks, recurrent neural networks (e.g., long short-term memory recurrent neural networks), convolutional neural networks, or other forms of neural networks.

[0082] In some implementations, one or more models 120 may be received from server 130 via network 180, stored in memory 114, and then used or otherwise implemented by one or more processors 112.

[0083] Terminal device 102 may also include one or more user input components 122 for receiving user input. For example, user input component 122 may be a touch-sensitive component (e.g., a touch-sensitive display or touchpad) that is sensitive to the touch of a user input object (e.g., a finger or stylus). Touch-sensitive components can be used to implement a virtual keyboard. Other example user input components include a microphone, a traditional keyboard, or other devices from which the user can provide input.

[0084] The terminal device 102 may also include a communication interface 123. The terminal device 102 can communicate with the server 130 through the communication interface 123. The server 130 may include a communication interface 133. The terminal device 102 can communicate with the server 130 through the communication interface 123 and the communication interface 133 of the server 130, thereby realizing data interaction between the terminal device 102 and the server 130.

[0085] Server 130 may include processor 132 and memory 134. Processor 132 may be any suitable processing device (e.g., processor core, microprocessor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), controller, microcontroller, etc.). Memory 134 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or compact disc read-only memory (CD-ROM). Memory 134 may store data 136 and instructions 138 executed by processor 132 to cause server 130 to perform operations.

[0086] As described above, memory 134 can store one or more machine learning models 140. For example, model 140 can be, or may additionally include, various machine learning models. Example machine learning models include neural networks or other multi-layer nonlinear models. Example neural networks include feedforward neural networks, deep neural networks, recurrent neural networks, and convolutional neural networks.

[0087] Figure 3 This is a schematic diagram of a system 100 architecture provided in an embodiment of this application. Figure 3In the process, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with external devices. Users can input data to the I / O interface 112 through the client device 140. The input data in this embodiment may include various tasks to be scheduled, callable resources, and other parameters.

[0088] During the preprocessing of input data by the execution device 110, or during the calculation module 111 of the execution device 110 performing calculations and other related processing (such as implementing the neural network function in this application), the execution device 110 may call data, code, etc. in the data storage system 150 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 150.

[0089] Finally, I / O interface 112 returns the processing result to client device 140, thereby providing it to the user.

[0090] It is worth noting that the training device 120 can generate corresponding target models / rules based on different training data for different objectives or tasks. These corresponding target models / rules can be used to achieve the above objectives or complete the above tasks, thereby providing the user with the required results.

[0091] exist Figure 3 In the scenario shown, the user can manually provide input data, which can be done through the interface provided by I / O interface 112. Alternatively, the client device 140 can automatically send input data to I / O interface 112. If user authorization is required for the client device 140 to automatically send input data, the user can set the corresponding permissions in the client device 140. The user can view the output results of the execution device 110 on the client device 140, which can be presented in various forms such as display, sound, or animation. The client device 140 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 112 as new sample data and storing them in the database 130. Alternatively, data can be collected directly from the I / O interface 112 without going through the client device 140, using the input data and output results of the input I / O interface 112 as new sample data and storing them in the database 130.

[0092] It is worth noting that, Figure 3 This is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the diagram do not constitute any limitation. For example, in Figure 3In this context, the data storage system 150 is an external memory relative to the execution device 110. However, in other cases, the data storage system 150 can also be placed within the execution device 110. For example... Figure 3 As shown, a neural network can be trained using training device 120.

[0093] This application also provides a chip including a neural network processor (NPU). This chip can be configured as follows: Figure 3 The execution device 110 shown is used to perform the calculations of the calculation module 111. This chip can also be located in, for example... Figure 3 The training device 120 shown is used to complete the training work of the training device 120 and output the target model / rules.

[0094] The Neural Processing Unit (NPU) is a coprocessor mounted on the main central processing unit (CPU) (host CPU), where tasks are assigned by the CPU. The core of the NPU is the computation circuitry, which is controlled by a controller to retrieve data from memory (weight memory or input memory) and perform calculations.

[0095] In some implementations, the arithmetic circuitry includes multiple process engines (PEs). In some implementations, the arithmetic circuitry is a two-dimensional pulsating array. The arithmetic circuitry can also be a one-dimensional pulsating array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuitry is a general-purpose matrix processor.

[0096] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from input memory 1 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is ​​stored in the accumulator.

[0097] Vector computation units can further process the output of computational circuits, such as vector multiplication, vector addition, exponentiation, logarithmic operations, size comparisons, etc. For example, vector computation units can be used for computation in non-convolutional / non-FC layers of neural networks, such as pooling, batch normalization, and local response normalization.

[0098] In some implementations, the vector computation unit can store the processed output vector into a unified buffer. For example, the vector computation unit can apply a nonlinear function to the output of the arithmetic circuit, such as a vector of accumulated values, to generate activation values. In some implementations, the vector computation unit generates normalized values, merged values, or both. In some implementations, the processed output vector can be used as activation input to the arithmetic circuit, for example, for use in subsequent layers of a neural network.

[0099] The unified memory is used to store input data and output data.

[0100] The weight data is directly transferred from the external memory to the input memory 1 and / or the unified memory through the direct memory access controller (DMAC), the weight data in the external memory is stored in the weight memory, and the data in the unified memory is stored in the external memory.

[0101] The bus interface unit (BIU) is used to enable interaction between the main CPU, DMAC, and instruction fetch memory via a bus.

[0102] The instruction fetch buffer, connected to the controller, is used to store the instructions used by the controller.

[0103] The controller is used to invoke instructions cached in the memory to control the operation of the computing accelerator.

[0104] Generally, the unified memory, input memory 1, weight memory, and instruction fetch memory are all on-chip memories, while the external memory is memory outside the NPU. This external memory can be double data rate synchronous dynamic random access memory (DDRSDRAM), high bandwidth memory (HBM), or other readable and writable memory.

[0105] Since the embodiments of this application involve a large number of neural network applications, for ease of understanding, the relevant terms and concepts such as neural networks involved in the embodiments of this application will be introduced below.

[0106] (1) Neural Network

[0107] A neural network can be composed of neural units, which can be operational units that take xs and an intercept of 1 as inputs, and whose output can be:

[0108]

[0109] Where s = 1, 2, ..., n, where n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of this activation function can be used as the input of the next convolutional layer. The activation function can be the sigmoid function. A neural network is a network formed by connecting many of the above-mentioned individual neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, which can be a region composed of several neural units.

[0110] The function of each layer in a neural network can be expressed mathematically. To describe it: From a physical perspective, the work of each layer in a neural network can be understood as transforming the input space (the set of input vectors) to the output space (i.e., from the row space to the column space of a matrix) through five operations on the input space. These five operations include: 1. Dimensionality increase / decrease; 2. Magnification / scaling; 3. Rotation; 4. Translation; 5. "Bending". Operations 1, 2, and 3 are... The operation 4 is completed using +b, and the operation 5 is implemented using a(). The term "space" is used here because the objects being classified are not individual things, but a class of things; space refers to the set of all individuals within this class of things. Here, W is the weight vector, where each value represents the weight of a neuron in that layer of the neural network. This vector W determines the spatial transformation from the input space to the output space, as described above; that is, the weights W of each layer control how the space is transformed. The purpose of training the neural network is to ultimately obtain the weight matrix of all layers of the trained neural network (a weight matrix formed by the vectors W from many layers). Therefore, the training process of a neural network is essentially learning how to control the spatial transformation, more specifically, learning the weight matrix.

[0111] Because we want the output of the neural network to be as close as possible to the actual predicted value, we can compare the current network's prediction with the desired target value, and then update the weight vector of each layer of the neural network based on the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring the parameters of each layer in the neural network). For example, if the network's prediction is too high, the weight vector is adjusted to make it predict lower, and this adjustment is continued until the neural network can predict the actual target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value," which is the loss function or objective function. These are important equations used to measure the difference between the predicted value and the target value. Taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so training the neural network becomes the process of minimizing this loss as much as possible.

[0112] (2) Backpropagation algorithm

[0113] Neural networks can employ backpropagation (BP) to correct the parameters of the initial neural network model during training, thereby reducing the reconstruction error loss. Specifically, forward propagation of the input signal to the output generates error loss; this error loss information is then propagated back to update the parameters of the initial neural network model, leading to convergence of the error loss. The backpropagation algorithm is an error-loss-driven backpropagation process aimed at obtaining the optimal parameters of the neural network model, such as the weight matrix.

[0114] (3) Federated Learning

[0115] A privacy-preserving distributed machine learning modeling method is proposed. Compared with traditional centralized modeling, in federated learning, each component does not directly share data, but instead performs distributed training by sharing the model.

[0116] (4) Federated Learning under Parameter Server Framework

[0117] The most common federated learning model currently consists of several edge nodes and a central node. Edge nodes receive models distributed by the central node, train them using local data, and then send the models back to the central node. The central node collects the models from each edge node, aggregates them into a global model, and distributes it to the edge nodes to start a new round of training iterations.

[0118] (5) Non-independent and identically distributed

[0119] In the context of federated learning, this refers to the different data distributions on different user endpoints. "Independent and identically distributed" means that the data distributions on each endpoint are independent of each other and consistent.

[0120] See Figure 4 , Figure 4 This application provides an example of a model training method architecture, such as... Figure 4 As shown, the architecture provided in this application embodiment includes: a cloud-side central node, such as a cloud-side server. A1, A2, ... are distributed nodes of type A (which may be referred to as terminals in this application), such as a mobile phone product held by a user. B1, B2, ... are distributed nodes of type B, such as a personal computer held by a user. After obtaining the consent of the administrator of the distributed nodes (such as the user of the mobile phone or computer), the administrator of the distributed nodes voluntarily shares the data generated during their daily use of the device, under the premise of privacy protection, and adds it to the model training plan. The device becomes a distributed node in the architecture. The system in this embodiment may also include more types of distributed nodes, such as smartwatches, etc. To protect data privacy, the distributed nodes do not upload data to the central node, but only store data locally. The distributed nodes are connected to the cloud server through a communication network. The cloud-side central node can run large models, while each distributed node can only run small models due to hardware limitations, and A and B can have different model training capabilities.

[0121] At the start of training, the server sends an initial model to each client. Subsequently, each client iterates the model using local data and feeds back the changes in the model (i.e., the gradients corresponding to the parameters) to the server. The server performs a weighted average of the fed-back gradients, updates the initial model with the resulting average gradient, and distributes the updated model to each client user, restarting the next iteration.

[0122] The problem with existing federated training frameworks is that when user data is not independently and identically distributed, the significant differences in gradient directions among user nodes after iterations prevent the server from obtaining an effective model gradient update direction. This leads to slow convergence of the server model and necessitates extensive back-and-forth gradient propagation between users and the server, consuming substantial communication bandwidth. Furthermore, in the current network environment, the growth rate of overall network bandwidth is far slower than the growth rate of neural network model size. Therefore, effectively reducing communication overhead is a critical issue that needs to be addressed in federated learning.

[0123] See Figure 5 , Figure 5 This is a flowchart illustrating a model training method provided in an embodiment of this application, as shown below. Figure 5 As shown, the model training method provided in this application includes:

[0124] 501. The server obtains multiple first gradients and multiple second gradients; the multiple first gradients are the gradients corresponding to multiple first parameters in the target model; the multiple second gradients are the gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning, and the multiple second parameters were not updated in the previous iteration of federated learning.

[0125] In one possible implementation, the target model can be the model training object of federated learning. The target model can include neural networks or other multi-layer nonlinear models. For example, neural networks can include feedforward neural networks, deep neural networks, recurrent neural networks, and convolutional neural networks.

[0126] In this embodiment of the application, after receiving the initial model of the target model sent by the server, multiple devices can train the target model using local data and obtain gradients during the training process. The gradients can then be uploaded to the server. Optionally, to protect the information privacy during the transmission process, the devices can upload encrypted gradients to the server.

[0127] In one possible implementation, the server can receive gradients sent by some of the multiple devices and select some gradients from the gradients (as well as the gradient error from the previous iteration, i.e., the gradients that were not used for model updates) to update the model.

[0128] For example, the target model may include parameters A, B, C, D, and E. The server can receive gradients sent by the terminal and aggregate them (aggregation can be a weighted average) to obtain the gradients corresponding to parameters A, B, and C. Parameters C and D are parameters that were updated in the previous server iteration, while parameters A, B, and E are parameters that were not updated in the previous server iteration. The server can fuse the gradients corresponding to parameters A and B from the previous server iteration with the gradients of parameters A and B obtained from the aggregation of gradients sent by the terminal in the current iteration (e.g., by addition) to obtain the gradients of parameters A and B in the current iteration. The server can use the gradient of parameter C obtained from the aggregation of gradients sent by the terminal as the gradient of parameter C in the current iteration. The server can also use the gradient of parameter E from the previous server iteration as the gradient of parameter E in the current iteration. The server can select gradients corresponding to some parameters from A, B, C, and E to update the model.

[0129] In one possible implementation, this application embodiment is illustrated by taking the example that the plurality of first parameters were updated in the previous iteration of federated learning, while the plurality of second parameters were not updated in the previous iteration of federated learning.

[0130] In one possible implementation, multiple second devices (which can be a subset of the multiple devices) can obtain the gradients of multiple parameters in the target model during a single iteration. For example, they can obtain the gradients corresponding to multiple first parameters (i.e., multiple third gradients) and the gradients corresponding to multiple second parameters (i.e., multiple fourth gradients). The multiple second devices can then transmit these multiple third and fourth gradients to the server.

[0131] In one possible implementation, the server can obtain multiple first gradients by aggregating multiple third gradient passes sent from multiple second devices in the current iteration round; the server can obtain multiple gradients by aggregating multiple fourth gradient passes sent from multiple second devices in the current iteration round, and fuse the multiple gradients with the gradients corresponding to the multiple second parameters determined in the previous iteration round to obtain multiple second gradients.

[0132] Optionally, the Momentum gradient update method can be used during aggregation: That is, the local gradient formed by the current merging is no longer simply the sum of the edge gradients, but a weighted sum of the current gradient and the gradient of the previous round.

[0133] In one possible implementation, the multiple second devices among the multiple terminals are specifically used to determine multiple gradients corresponding to the target model in the previous iteration of federated learning; and to randomly select the multiple third gradients and multiple fourth gradients from the multiple gradients.

[0134] In other words, after receiving the model parameters from the server, the client can update the model using local data, calculate the update gradient after the local iteration round, and use the rand-k method to randomly select k gradients from the update gradients and upload them to the server.

[0135] By using the above method, an unbiased compression scheme is implemented on the client side, avoiding the risk that client-side users do not participate in federated training in every iteration round.

[0136] In one possible implementation, the plurality of second devices among the plurality of terminals are specifically used to perform lossless compression or linear unbiased compression on the information indicating the plurality of third gradients and the plurality of fourth gradients, and send the compression result to the server.

[0137] Reference Figure 6 , Figure 6 This is a schematic diagram of an interaction between a server and a terminal.

[0138] The following describes an example of using a linear unbiased compression scheme to further compress uplink traffic. The interaction flow is as follows: Figure 7 As shown, the difference from Embodiment 1 is that after rand-k compression is performed on the end side, a linear unbiased compression scheme is used to compress the traffic (e.g., using the sketch compression method).

[0139] The above method allows the linear unbiased compression scheme to be hard-coded into network devices, thereby fully utilizing the processing power of these devices to reduce network transmission pressure and further reducing the amount of communication uploaded from the endpoint to the server. Simultaneously, the proposed linear unbiased compression scheme can be hard-coded into network devices, thus fully utilizing their performance to reduce network communication pressure.

[0140] 502. Select a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of the federated learning.

[0141] In one possible implementation, the partial gradient is the largest of the plurality of first gradients and the plurality of second gradients.

[0142] In one possible implementation, let the residual gradient error from the previous round be err_{t-1}. Then, in this round, the top-k gradient values ​​in (g_t+err_{t-1}) are taken as update values ​​to update the current public model as w_{t+1}. Let (g_t+err_{t-1})-top-k(g_t+err_{t-1}) be err_t. This error can participate in the next round of iteration.

[0143] 503. The updated target model information is transmitted to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

[0144] In one possible implementation, the updated target model can be w_{t+1}, and the information of the updated target model can be sent to the terminals that need to participate in the next round of iteration (that is, the multiple first devices in the embodiments of this application).

[0145] Since the target model only selects and updates the values ​​of some parameters each time, the amount of gradient transmission from the server to the terminal can be effectively reduced.

[0146] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

[0147] In other words, the server can send w_{t+1}-w_0 to the client as the compressed gradient value, where w_0 is the initial model of the target model.

[0148] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is a model obtained by the first target device updating the target model in the iterations prior to the current iteration; the server can transmit the parameter update amount of the updated target model relative to the third model to the first target device.

[0149] In one possible implementation, the iteration round preceding the current iteration round specifically refers to the iteration round in which the first target device last updated the target model before the current iteration round.

[0150] In one possible implementation, the server can maintain a list of existing target models for users on the client side. When issuing updates, the server can perform a difference operation with the corresponding public model parameters on the client side, thereby improving the communication compression rate of gradient distribution. A specific solution is as follows: Figure 9 As shown in the diagram, the server maintains the latest model parameter list for the end-user using the above method, thereby reducing the number of gradient differences between the latest target model and the end-user model when gradients are sent down, thus maximizing the downlink traffic compression effect.

[0151] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the first model, the first model being the model obtained by updating the target model in the iterations prior to the current iteration; before obtaining the multiple first gradients and multiple second gradients, the parameter values ​​of the updated first model can be broadcast to the multiple terminals.

[0152] In one possible implementation, the server can broadcast (e.g., periodically broadcast) the parameters of the latest target model to reduce the number of model gradient changes sent from the cloud. If the model gradient sent from the cloud is w_{t+1}-w_0, the downlink model compression effect will significantly decrease as t becomes larger. In this case, a scheme where the server periodically broadcasts the latest public model parameters (or the difference between the latest and second-newest target models) to all federated end-users participating in training can be used to reduce the number of model gradient changes sent from the cloud. Figure 8 As shown, w_anchor represents the latest public model parameters periodically broadcast by the cloud server. This method reduces the gradient difference between the latest target model and the end-user model, thus ensuring that downlink traffic compression performance is not degraded.

[0153] This application provides a model training method applied to a server, which communicates with multiple terminals. The method includes: acquiring multiple first gradients and multiple second gradients; the multiple first gradients are gradients corresponding to multiple first parameters in the target model; the multiple second gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning, and the multiple second parameters were not updated in the previous iteration of federated learning; selecting a portion of gradients from the multiple first gradients and the multiple second gradients, the portion of gradients being used to update the target model in the current iteration of federated learning; and transmitting the updated target model information to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

[0154] Since the target model only selects and updates the values ​​of some parameters each time, the amount of gradient transmission from the server to the terminal can be effectively reduced.

[0155] Furthermore, this application provides a system comprising a server and multiple terminals, wherein the server communicates with the multiple terminals, wherein...

[0156] The server is used to obtain multiple first gradients and multiple second gradients; the multiple first gradients are gradients corresponding to multiple first parameters in the target model; the multiple second gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters are updated in the previous iteration of federated learning, and the multiple second parameters are not updated in the previous iteration of federated learning.

[0157] Selecting a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of the federated learning;

[0158] The updated target model information is transmitted to multiple first devices; wherein the multiple first devices and the multiple second devices belong to the multiple terminals.

[0159] In one possible implementation, the partial gradient is the largest of the plurality of first gradients and the plurality of second gradients.

[0160] In one possible implementation, multiple second devices among the multiple terminals are used to send multiple third gradients and multiple fourth gradients to the server; the multiple third gradients are gradients corresponding to multiple first parameters in the target model; the multiple fourth gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning; the multiple second parameters were not updated in the previous iteration of federated learning.

[0161] The server is specifically used to aggregate the multiple third gradients to obtain multiple first gradients;

[0162] The multiple fourth gradients are aggregated and fused with the gradients corresponding to the multiple second parameters determined in the previous iteration to obtain multiple second gradients.

[0163] In one possible implementation, the multiple second devices among the multiple terminals are specifically used to determine multiple gradients corresponding to the target model in the previous iteration of federated learning; and to randomly select the multiple third gradients and multiple fourth gradients from the multiple gradients.

[0164] In one possible implementation, the plurality of second devices among the plurality of terminals are specifically used to perform lossless compression or linear unbiased compression on the information indicating the plurality of third gradients and the plurality of fourth gradients, and send the compression result to the server.

[0165] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is a model obtained by updating the target model in the iterations prior to the current iteration;

[0166] The server is also configured to broadcast the updated parameter values ​​of the first model to the multiple terminals before acquiring the multiple first gradients and multiple second gradients.

[0167] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

[0168] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is a model obtained by the first target device updating the target model in the iterations prior to the current iteration;

[0169] The server is specifically used to transmit the updated parameter update amount of the target model relative to the third model to the first target device.

[0170] In one possible implementation, the iteration round preceding the current iteration round specifically refers to the iteration round in which the first target device last updated the target model before the current iteration round.

[0171] The model training apparatus provided in the embodiments of this application will now be described from the perspective of the apparatus itself, referring to... Figure 10 , Figure 10 This is a schematic diagram of a model training device provided in an embodiment of this application, such as... Figure 10 As shown in the figure, the model training apparatus 1000 provided in this application embodiment includes:

[0172] The acquisition module 1001 is used to acquire multiple first gradients and multiple second gradients; the multiple first gradients are the gradients corresponding to multiple first parameters in the target model; the multiple second gradients are the gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning, and the multiple second parameters were not updated in the previous iteration of federated learning.

[0173] For a detailed description of the acquisition module 1001, please refer to the description of step 501 in the above embodiment, which will not be repeated here.

[0174] The gradient selection module 1002 is used to select a portion of gradients from the plurality of first gradients and the plurality of second gradients, the portion of gradients being used to update the target model in the current iteration of federated learning;

[0175] For a detailed description of the gradient selection module 1002, please refer to the description of step 502 in the above embodiment, which will not be repeated here.

[0176] The sending module 1003 is used to transmit the updated target model information to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

[0177] For a detailed description of the sending module 1003, please refer to the description of step 503 in the above embodiment, which will not be repeated here.

[0178] In one possible implementation, the partial gradient is the largest of the plurality of first gradients and the plurality of second gradients.

[0179] In one possible implementation, the plurality of first gradients are obtained by aggregating a plurality of third gradients sent by a plurality of second devices in the current iteration round; the plurality of second gradients are obtained based on the gradients corresponding to the plurality of second parameters determined in the previous iteration round and the plurality of fourth gradients sent by the plurality of second devices in the current iteration round; the plurality of second devices belong to the plurality of terminals.

[0180] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is a model obtained by updating the target model in the iterations prior to the current iteration;

[0181] The sending module is further configured to: broadcast the updated parameter values ​​of the first model to the multiple terminals before acquiring the multiple first gradients and multiple second gradients.

[0182] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

[0183] In one possible implementation, the information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is a model obtained by the first target device updating the target model in the iterations prior to the current iteration;

[0184] The sending module is specifically used to: transmit the updated parameter update amount of the target model relative to the third model to the first target device.

[0185] In one possible implementation, the iteration round preceding the current iteration round specifically refers to the iteration round in which the first target device last updated the target model before the current iteration round.

[0186] The following describes an execution device provided in an embodiment of this application. Please refer to [link / reference]. Figure 11 , Figure 11 This is a schematic diagram of an execution device provided in an embodiment of this application. The execution device 1100 can specifically be a mobile phone, tablet, laptop, smart wearable device, server, etc., and is not limited thereto. The execution device 1100 may be equipped with... Figure 11 The model training apparatus described in the corresponding embodiment is used to implement Figure 11 This corresponds to the model training function in the embodiment. Specifically, the execution device 1100 includes: a receiver 1101, a transmitter 1102, a processor 1103, and a memory 1104 (wherein the execution device 1100 may have one or more processors 1103). Figure 11 (Taking a processor as an example), processor 1103 may include application processor 11031 and communication processor 11032. In some embodiments of this application, receiver 1101, transmitter 1102, processor 1103 and memory 1104 may be connected via bus or other means.

[0187] Memory 1104 may include read-only memory and random access memory, and provides instructions and data to processor 1103. A portion of memory 1104 may also include non-volatile random access memory (NVRAM). Memory 1104 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.

[0188] Processor 1103 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses are referred to as the bus system in the diagram.

[0189] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 1103. The processor 1103 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1103 or by instructions in software form. The processor 1103 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1103 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1104. Processor 1103 reads the information in memory 1104 and, in conjunction with its hardware, completes the steps of the above method.

[0190] Receiver 1101 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 1102 can be used to output digital or character information through the first interface; transmitter 1102 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 1102 may also include a display device such as a display screen.

[0191] In one embodiment of this application, the processor 1103 is configured to execute... Figure 5 The method executed by the server in the corresponding embodiment.

[0192] This application also provides a training device; please refer to [link / reference]. Figure 12 , Figure 12 This is a schematic diagram of a training device provided in an embodiment of this application. The training device 1200 can be equipped with... Figure 10 The neural network training device described in the corresponding embodiment is used to implement Figure 10 In accordance with the functionality of the neural network training device in the corresponding embodiment, specifically, the training device 1200 is implemented by one or more servers. The training device 1200 can vary significantly due to differences in configuration or performance, and may include one or more central processing units (CPUs) 1212 (e.g., one or more processors) and memory 1232, and one or more storage media 1230 (e.g., one or more mass storage devices) for storing application programs 1242 or data 1244. The memory 1232 and storage media 1230 can be temporary or persistent storage. The program stored in the storage media 1230 may include one or more modules (not shown in the figure), each module may include a series of instruction operations on the training device. Furthermore, the CPU 1212 may be configured to communicate with the storage media 1230 and execute the series of instruction operations in the storage media 1230 on the training device 1200.

[0193] The training device 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input / output interfaces 1258; or, one or more operating systems 1241, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0194] In this embodiment, the central processing unit 1212 is used to execute the steps related to the training method in the above embodiments.

[0195] This application also provides a computer program product that, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.

[0196] This application also provides a computer-readable storage medium storing a program for signal processing, which, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.

[0197] The execution device, training device, or terminal device provided in this application embodiment can specifically be a chip. The chip includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the execution device to execute the model training method described in the above embodiments, or to cause the chip within the training device to execute the model training method described in the above embodiments. Optionally, the storage unit is a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).

[0198] For details, please refer to Figure 13 , Figure 13 This is a schematic diagram of a chip provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 1300. The NPU 1300 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1303, which is controlled by the controller 1304 to extract matrix data from the memory and perform multiplication operations.

[0199] In some implementations, the arithmetic circuit 1303 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 1303 is a two-dimensional pulsating array. The arithmetic circuit 1303 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1303 is a general-purpose matrix processor.

[0200] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1302 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1301 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is ​​stored in the accumulator 1308.

[0201] Unified memory 1306 is used to store input and output data. Weight data is directly transferred to weight memory 1302 via Direct Memory Access Controller (DMAC) 1305. Input data is also transferred to unified memory 1306 via DMAC.

[0202] BIU stands for Bus Interface Unit, which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1309.

[0203] The Bus Interface Unit (BIU) 1310 is used by the instruction fetch memory 1309 to fetch instructions from external memory, and also by the memory access controller 1305 to fetch the original data of the input matrix A or the weight matrix B from external memory.

[0204] The DMAC is mainly used to move input data from external memory DDR to unified memory 1306, or to weight data to weight memory 1302, or to input data to input memory 1301.

[0205] The vector computation unit 1307 includes multiple processing units that further process the output of the computation circuit 1303 when needed, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as Batch Normalization, pixel-level summation, and upsampling of feature planes.

[0206] In some implementations, the vector computation unit 1307 can store the processed output vector in the unified memory 1306. For example, the vector computation unit 1307 can apply a linear function, or a nonlinear function, to the output of the computation circuit 1303, such as performing linear interpolation on the feature planes extracted by the convolutional layer, or, for example, accumulating a vector of values ​​to generate activation values. In some implementations, the vector computation unit 1307 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit 1303, for example, for use in subsequent layers of the neural network.

[0207] The instruction fetch buffer 1309 connected to the controller 1304 is used to store the instructions used by the controller 1304;

[0208] Unified memory 1306, input memory 1301, weighted memory 1302, and instruction fetch memory 1309 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.

[0209] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above program.

[0210] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0211] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0212] In the above embodiments, the implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, in the form of a computer program product.

[0213] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A model training method, characterized in that, Applied to a server that communicates with multiple terminals, the method includes: Obtain multiple first gradients and multiple second gradients; the multiple first gradients are the gradients corresponding to multiple first parameters in the target model; the multiple second gradients are the gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning, and the multiple second parameters were not updated in the previous iteration of federated learning. Selecting a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of the federated learning; The updated target model information is transmitted to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

2. The method according to claim 1, characterized in that, The partial gradient is the largest gradient among the plurality of first gradients and the plurality of second gradients.

3. The method according to claim 1 or 2, characterized in that, The plurality of first gradients are obtained by aggregating the plurality of third gradients sent by the plurality of second devices in the current iteration round; the plurality of second gradients are obtained based on the gradients corresponding to the plurality of second parameters determined in the previous iteration round and the plurality of fourth gradients sent by the plurality of second devices in the current iteration round. The plurality of second devices belong to the plurality of terminals.

4. The method according to claim 1 or 2, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is the model obtained by updating the target model in the iterations prior to the current iteration; Before obtaining the multiple first gradients and multiple second gradients, the method further includes: The updated parameter values ​​of the first model are broadcast to the multiple terminals.

5. The method according to claim 1 or 2, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

6. The method according to claim 1 or 2, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is the model obtained by the first target device updating the target model in the iterations prior to the current iteration; The step of transmitting the updated target model information to multiple first devices includes: The updated parameter update amount of the target model relative to the third model is transmitted to the first target device.

7. The method according to claim 6, characterized in that, The iteration rounds preceding the current iteration are specifically: the iteration round in which the first target device last updated the target model before the current iteration.

8. A system, characterized in that, The system includes a server and multiple terminals, wherein the server communicates with the multiple terminals. The server is used to obtain multiple first gradients and multiple second gradients; the multiple first gradients are gradients corresponding to multiple first parameters in the target model; the multiple second gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters are updated in the previous iteration of federated learning, and the multiple second parameters are not updated in the previous iteration of federated learning. Selecting a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of the federated learning; The updated target model information is transmitted to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

9. The system according to claim 8, characterized in that, The partial gradient is the largest gradient among the plurality of first gradients and the plurality of second gradients.

10. The system according to claim 8 or 9, characterized in that, The multiple second devices among the multiple terminals are used to send multiple third gradients and multiple fourth gradients to the server; the multiple third gradients are gradients corresponding to multiple first parameters in the target model; the multiple fourth gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning; the multiple second parameters were not updated in the previous iteration of federated learning. The server is specifically used to aggregate the multiple third gradients to obtain multiple first gradients; The multiple fourth gradients are aggregated and fused with the gradients corresponding to the multiple second parameters determined in the previous iteration to obtain multiple second gradients.

11. The system according to claim 10, characterized in that, The multiple second devices among the multiple terminals are specifically used to determine multiple gradients corresponding to the target model in the previous iteration of federated learning; and to randomly select multiple third gradients and multiple fourth gradients from the multiple gradients.

12. The system according to claim 11, characterized in that, The multiple second devices among the multiple terminals are specifically used to perform lossless compression or linear unbiased compression on the information indicating the multiple third gradients and the multiple fourth gradients, and send the compression results to the server.

13. The system according to claim 8 or 9, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is the model obtained by updating the target model in the iterations prior to the current iteration; The server is also configured to broadcast the updated parameter values ​​of the first model to the multiple terminals before acquiring the multiple first gradients and multiple second gradients.

14. The system according to claim 8 or 9, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

15. The system according to claim 8 or 9, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is the model obtained by the first target device updating the target model in the iterations prior to the current iteration; The server is specifically used to transmit the updated parameter update amount of the target model relative to the third model to the first target device.

16. The system according to claim 15, characterized in that, The iteration rounds preceding the current iteration are specifically: the iteration round in which the first target device last updated the target model before the current iteration.

17. A model training device, characterized in that, Applied to a server that communicates with multiple terminals, the device includes: An acquisition module is used to acquire multiple first gradients and multiple second gradients; the multiple first gradients are gradients corresponding to multiple first parameters in the target model; the multiple second gradients are gradients corresponding to multiple second parameters in the target model; the multiple first parameters were updated in the previous iteration of federated learning, and the multiple second parameters were not updated in the previous iteration of federated learning. A gradient selection module is used to select a subset of gradients from the plurality of first gradients and the plurality of second gradients, the subset of gradients being used to update the target model in the current iteration of federated learning; A sending module is used to transmit the updated target model information to multiple first devices; wherein the multiple first devices belong to the multiple terminals.

18. The apparatus according to claim 17, characterized in that, The partial gradient is the largest gradient among the plurality of first gradients and the plurality of second gradients.

19. The apparatus according to claim 17 or 18, characterized in that, The plurality of first gradients are obtained by aggregating the plurality of third gradients sent by the plurality of second devices in the current iteration round; the plurality of second gradients are obtained based on the gradients corresponding to the plurality of second parameters determined in the previous iteration round and the plurality of fourth gradients sent by the plurality of second devices in the current iteration round. The plurality of second devices belong to the plurality of terminals.

20. The apparatus according to claim 17 or 18, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the first model, where the first model is the model obtained by updating the target model in the iterations prior to the current iteration; The sending module is further configured to: broadcast the updated parameter values ​​of the first model to the multiple terminals before acquiring the multiple first gradients and multiple second gradients.

21. The apparatus according to claim 17 or 18, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the second model, where the second model is the initial model of the target model.

22. The apparatus according to claim 17 or 18, characterized in that, The information of the target model includes: the parameter update amount of the updated target model relative to the third model; the plurality of first devices includes a first target device; the third model is the model obtained by the first target device updating the target model in the iterations prior to the current iteration; The sending module is specifically used to: transmit the updated parameter update amount of the target model relative to the third model to the first target device.

23. The apparatus according to claim 22, characterized in that, The iteration rounds preceding the current iteration are specifically: the iteration round in which the first target device last updated the target model before the current iteration.

24. A model training device, characterized in that, The device includes a memory and a processor; the memory stores code, and the processor is configured to execute the code and implement the method as claimed in any one of claims 1 to 7.

25. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions that, when executed by one or more computers, cause the one or more computers to perform the method of any one of claims 1 to 7.

26. A computer program product, comprising code, characterized in that, When the code is executed, it is used to implement the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Federal learning method and device thereof, computing equipment and storage medium

    CN113177645A

  • Federated-learning-based user data classification method and apparatus, and device and medium

    WO2021179720A1