Large model implementation method and device based on multi-layer task processing and electronic equipment
By distributing tasks to computing chips with different performance parameters according to the computing needs of different layers in the large model, the problem of waste of computing resources and low efficiency caused by each layer of tasks in the large model being processed by the same processing performance chip is solved. Efficient utilization of resources and improvement of inference speed.
Patent Information
- Application Number
- CN202411104797.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-10-25
AI Technical Summary
The tasks of each layer in the large model are processed by computing chips with the same processing performance, resulting in a waste of computing resources and reduced computing efficiency.
According to the computing needs of different layers in the large model, tasks are distributed to computing chips with different performance parameters for processing. The target computing chip is determined through the preset sparsity-performance parameter and quantification parameter mapping relationship, and the performance parameter proportion relationship is updated when necessary. to match task requirements.
It reduces resource waste, lowers costs, and speeds up model inference.
Smart Images

Figure CN118838718A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a large model implementation method, device and electronic equipment based on multi-layer task processing. Background Art
[0002] In the field of artificial intelligence technology, large models are usually models with millions or even billions of parameters. Large models can process a variety of tasks and achieve good results because of their advantages in capturing and learning complex patterns and relationships in data. However, since each layer in the multi-layer structure of large models contains different amounts of information, each layer has different requirements for computing power, bandwidth, and memory during the task processing stage. Therefore, it is particularly important to reduce computing overhead and increase reasoning speed while ensuring the model processing effect.
[0003] In the related technology, for a large model in which each layer mainly includes an attention mechanism and a feedforward neural network (FFN), different amounts of information carried by different layers are sparsed to different degrees, and then computing chips are used to process the tasks entering each layer after the information is sparse.
[0004] However, since there are differences in the amount of information in different layers of a large model after multiple layers of sparse processing, and the tasks entering each sparse layer are processed by computing chips of the same performance, it will cause a waste of computing resources and reduce computing efficiency. Summary of the invention
[0005] The present invention provides a large model implementation method, device and electronic device based on multi-layer task processing, which are used to solve the defects of waste of computing resources and reduced computing efficiency caused by the fact that tasks of each layer in the existing large model are processed by computing chips with the same processing performance. Combined with the implementation concept of the PP method, according to the different computing requirements or task processing requirements of different layers in the large model, the target tasks entering different layers in the large model are distributed to target computing chips with different performance parameters for processing, thereby achieving the purpose of realizing the large model based on multi-layer task processing, which can not only reduce resource waste and reduce costs, but also speed up the model reasoning speed.
[0006] The present invention provides a large model implementation method based on multi-layer task processing, comprising the following steps.
[0007] Based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters, determine the target computing chip for processing the target task in the current layer; distribute the target task in the current layer to the target computing chip for corresponding processing.
[0008] According to a large model implementation method based on multi-layer task processing provided by the present invention, the target computing chip for processing the target task in the current layer is determined based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters, including: when the task processing requirements include the target sparsity of the current layer, based on the mapping relationship between the sparsity-performance parameters set in advance for all layers in the large model and the target sparsity, the target computing chip for processing the target task in the current layer is determined from the computing chips with different performance parameters.
[0009] According to a large model implementation method based on multi-layer task processing provided by the present invention, the target computing chip for processing the target task in the current layer is determined based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters. It also includes: when the task processing requirements include the target quantization parameters of the current layer, based on the mapping relationship between the quantization parameters and performance parameters set in advance for all layers in the large model and the target quantization parameters, the target computing chip for processing the target task in the current layer is determined from the computing chips with different performance parameters.
[0010] According to a large model implementation method based on multi-layer task processing provided by the present invention, the target computing chip for processing the target task in the current layer is determined based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters. The method also includes: when there is no target performance parameter matching the target sparsity of the current layer or the target quantization parameter of the current layer among the multiple different performance parameters, based on the target performance parameters, updating the performance parameter proportional relationship used to build a heterogeneous framework for computing chips; based on the updated performance parameter proportional relationship, updating the multiple computing chips with different performance parameters, and determining the target computing chip for processing the target task in the current layer based on the update result.
[0011] According to a large model implementation method based on multi-layer task processing provided by the present invention, the process of determining the multiple computing chips with different performance parameters includes: determining the proportional relationship of performance parameters used to build a heterogeneous framework of computing chips; and determining all computing chips that satisfy the performance parameter proportional relationship as the computing chips with the multiple different performance parameters.
[0012] According to a large model implementation method based on multi-layer task processing provided by the present invention, the determination of the performance parameter proportional relationship used to build a computing chip heterogeneous framework includes: based on the sparsity proportional relationship between different layers of the large model after multi-layer sparseness, determining the performance parameter proportional relationship that matches the sparsity proportional relationship; or, based on the quantization parameter proportional relationship between different layers of the large model after multi-layer quantization, determining the performance parameter proportional relationship that matches the quantization parameter proportional relationship.
[0013] According to a large model implementation method based on multi-layer task processing provided by the present invention, the method also includes: passing the task processing result output by the current layer to the next layer of the current layer, and redetermining the task processing requirements based on the new task received by the current layer, and taking the new task as a new target task, returning to execute the computing chip based on the task processing requirements of the current layer in the large model and multiple different performance parameters, and determining the target computing chip for processing the target task in the current layer; until the task processing stop condition is met; wherein the task processing time of the current layer and the next layer is the same, the task processing time is the time for the target computing chip to fully utilize its own computing power and bandwidth to process the corresponding target task, and the new task is the task processing result corresponding to the previous layer of the current layer or the task to be processed that initially enters the large model.
[0014] The present invention also provides a large model implementation device based on multi-layer task processing, including the following chip determination unit and model implementation unit.
[0015] The chip determination unit is used to determine the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters.
[0016] The model implementation unit is used to distribute the target task in the current layer to the target computing chip for corresponding processing.
[0017] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the large model implementation method based on multi-layer task processing as described above is implemented.
[0018] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described large model implementation methods based on multi-layer task processing.
[0019] The present invention provides a large model implementation method, device and electronic device based on multi-layer task processing, wherein the large model implementation method based on multi-layer task processing, for the target task entering the current layer in the large model, first determines the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters, and then distributes the target task in the current layer to the target computing chip for corresponding processing. In this way, combined with the implementation concept of the PP method, according to the different computing requirements or task processing requirements of different layers in the large model, the target tasks entering different layers in the large model are distributed to target computing chips with different performance parameters for processing, thereby achieving the purpose of implementing a large model based on multi-layer task processing, which can not only reduce resource waste and reduce costs, but also speed up model reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 It is a schematic diagram of deleting KV information at different layers in a large model in the related art.
[0022] Figure 2 It is a flow chart of the large model implementation method based on multi-layer task processing provided by the present invention.
[0023] Figure 3 It is one of the task processing flow charts provided by the present invention.
[0024] Figure 4 This is the second task processing flow chart provided by the present invention.
[0025] Figure 5 It is a structural schematic diagram of a large model implementation device based on multi-layer task processing provided by the present invention.
[0026] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] In the embodiments of the present invention, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B may be singular or plural. In the textual description of the present invention, the character " / " generally indicates that the previous and next associated objects are in an "or" relationship. In addition, it should be noted that the serial numbers themselves, such as "first", "second", etc., used to distinguish the objects described in the present invention are only used to distinguish the objects described, and do not have any order or technical meaning.
[0029] In the field of artificial intelligence technology, large models are usually models with millions or even billions of parameters. Large models can handle a variety of tasks and achieve good results because they have the advantages of capturing and learning complex patterns and relationships in data. Large models can handle a variety of tasks and achieve good results, such as transformer models. However, since each layer in the multi-layer structure of large models contains different amounts of information, each layer has different requirements for computing power, bandwidth, and memory during the task processing stage. Therefore, it is particularly important to reduce computing overhead and increase reasoning speed while ensuring the model processing effect.
[0030] In the related technology, for a large model in which each layer mainly includes an attention mechanism and a feedforward neural network (FFN), different amounts of information carried by different layers are sparsed to different degrees, and then computing chips are used to process the tasks entering each layer after the information is sparse.
[0031] For example, for large models of Transformer architecture such as the Bidirectional Encoder Representations from Transformers (BERT) model, the third-generation Transformer (GPT-3) model of the Generative Pre-trained Transformer series, and the Large Language Model Meta AI (Llama), the BERT model, the GPT-3 model, and the Llama model are not only models based on the Transformers architecture, but also can perform well on multiple tasks, such as language translation, image recognition, natural language understanding, natural language generation, and other tasks.
[0032] For large models of the Transformer architecture, the attention mechanism and FFN are the main computing modules of each layer in the large model. In order to achieve better task processing effects, large models often require a larger scale, which also means that more resources are needed for calculation. In order to improve the efficiency of model reasoning and reduce reasoning time, a common method is to sparse the attention calculation and FFN calculation, that is, only select some parameters in each layer of the large model for calculation. In addition, considering that the amount of information contained in each layer in the multi-layer structure of the large model is different, different layers can be sparse to different degrees. In this way, resource waste can be reduced and the reasoning speed can be accelerated while ensuring the model reasoning effect.
[0033] In addition, when the scale of the model and the amount of computation required to process the task are both large, the reasoning speed can be accelerated through parallel methods, such as tensor parallelism (TP), data parallelism (DP), pipeline parallelism (PP) and other parallel methods; by using parallel methods to let each graphics processing unit (GPU) process part of the task separately, resources can be fully utilized and the acceleration purpose can be achieved.
[0034] The following describes the multi-layer attention sparse method and multi-layer FFN sparse method involved in the sparseness of attention calculations and FFN calculations in large models.
[0035] Multi-layer attention sparse method: Attention calculation mainly includes three parts: query, key, and value. First, the input sequence (the input sequence is obtained by encoding the token, and each token is encoded to obtain a sequence vector) is converted into a query vector, a key vector, and a value vector through a linear transformation (usually the input matrix is multiplied by the weight matrix WQ, WK, and WV); further, the large model calculates the dot product of the query vector and all key vectors, normalizes the dot product result through a normalized exponential function (softmax function), and then performs a weighted sum with the value vector to obtain the output. Each time the large model is inferred, the input query vector needs to be calculated with all the past key-value (Key-Value, KV) information in the key-value cache (KVcache). When the inference length is long, the KVcache stores longer KV information. At this time, the attention calculation will become slower and the inference speed will be lower.
[0036] In order to speed up reasoning, the large model implementation method in related technologies is to sparse the attention calculation, that is, only select part of the KV information from the KVcache to participate in the calculation, without participating in the calculation with all the KV information; in addition, related research points out that the amount of information carried by different layers containing the attention mechanism in the large model is different. The front layers of the large model carry more and more important information, and the back layers of the large model carry relatively less and redundant information. Therefore, different layers can be sparse to different degrees, such as Figure 1 The schematic diagram of deleting KV information at different layers in a large model in the related art shown, Figure 1 In the figure, Drop the keys and value from current KV cache means deleting KV information from the current KVcache. The dotted box is the KV information to be deleted at the corresponding layer, and the solid box is the KV information to be retained at the corresponding layer. Figure 1 It can be seen that the initial layers (such as the Nth layer LayerN) use more KV information for calculation, and the later layers (such as the N+2th layer LayerN+2) use less KV information for calculation.
[0037] Multi-layer FFN sparse method: Similar to the multi-layer attention sparse method, different layers containing FFN in the large model are also sparse to different degrees. The front layers are not sparse or are sparse to a small extent, and the back layers can be sparse to a greater extent. This can reduce the computational overhead and accelerate reasoning while ensuring the model effect.
[0038] However, considering that the inference cost of large models is relatively high, the above-mentioned existing large model implementation methods do not take into account that different layers have different computing characteristics after multiple layers of sparseness. For example, the calculation stage of the front layer has higher requirements for computing power, bandwidth and memory, while the calculation stage of the back layer has lower requirements for computing power, bandwidth and memory. If they are performed on computing chips with the same performance, it will cause waste of computing resources and high computing costs. Since the existing large model implementation methods all use the same computing chip, it will cause waste of resources and low computing efficiency.
[0039] In addition, the related technology uses the PP method in large models as follows: different layers in the large model are processed by different GPUs, and one GPU can process one or more layers in the large model. After the GPUs corresponding to each layer complete their respective tasks, they will pass the task processing results to the GPU corresponding to the next layer. Each GPU only processes tasks in the corresponding layer, and after each layer passes the task processing results to the next layer, it can receive new tasks for processing, thereby realizing PP parallelism. However, since the multiple GPUs used in the entire use process have the same performance, it is easy for a high-performance GPU to process tasks with less computational workload and data reading volume, which also leads to technical problems such as waste of computing resources and high computing costs.
[0040] In order to solve the above technical problems, the present invention provides a large model implementation method, device and electronic device based on multi-layer task processing. Combined with the implementation concept of the PP method, according to the different computing requirements or task processing requirements of different layers in the large model, the target tasks entering different layers in the large model are distributed to target computing chips with different performance parameters for processing, thereby achieving the purpose of realizing the large model based on multi-layer task processing, which can not only reduce resource waste and reduce costs, but also speed up the model reasoning speed.
[0041] Combine the following Figure 2-Figure 6The present invention describes a large model implementation method, device and electronic device based on multi-layer task processing, wherein the execution subject of the large model implementation method based on multi-layer task processing can be an electronic device or a server, the electronic device has at least multiple computing chip configuration functions and large model reasoning functions, and the server also has at least multiple computing chip graphics cards and large model reasoning functions. The computing chip can specifically be a chip that carries computing tasks in large model reasoning, such as CPU (Central Processing Unit), GPU (Graphics Processing Unit) and TPU (Tensor Processing Unit); the electronic device can be a personal computer (Personal Computer, PC), portable device, laptop, smart phone, tablet computer and portable wearable device and other devices; the server can refer to a server, or a server cluster composed of multiple servers, cloud server, etc.; the present invention does not specifically limit the specific form of the electronic device or server. Furthermore, the execution subject of the large model implementation method based on multi-layer task processing can also be applied to a large model implementation device based on multi-layer task processing set in an electronic device or server, and the large model implementation device based on multi-layer task processing can be implemented by software, hardware or a combination of both. The following describes the large model implementation method based on multi-layer task processing by taking an electronic device with at least multiple computing chip configuration functions and large model reasoning functions as an example.
[0042] Reference Figure 2 , which is a flow chart of a large model implementation method based on multi-layer task processing provided by the present invention, such as Figure 2 As shown, the large model implementation method based on multi-layer task processing includes the following steps 210 and 230.
[0043] Step 210: Determine the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and computing chips with multiple different performance parameters.
[0044] Step 220: Distribute the target tasks in the current layer to the target computing chip for corresponding processing.
[0045] Among them, the large model has a multi-layer structure and each layer is mainly an attention and / or FFN structure. For example, when each layer in the large model mainly includes an attention layer and a FFN layer, each layer can specifically include a nonlinear layer, an attention layer, a nonlinear layer and a FFN layer.
[0046] The current layer can be any layer in the multi-layer structure contained in the large model. When the current layer is different, the corresponding target task is also different.
[0047] For example, if the current layer is the first layer of the large model, the target task is the task that has not been processed by the large model, that is, the task to be processed that initially enters the large model; if the current layer is any layer from the second layer to the last layer of the large model, the target task is the task processing result corresponding to the previous layer of the current layer in the large model.
[0048] The number of target tasks can be one or more; when the number of target tasks is multiple, the multiple target tasks can be tasks of the same type, and each target task can include but is not limited to language translation, image recognition, natural language understanding and natural language generation, etc.
[0049] The task processing requirements of the current layer can be the computing requirements for processing at least one target task in the current layer, such as the required computing amount and the data reading amount for memory access readings, and at least one target task entering the current layer. For example, the task computing amount and the data reading amount for memory access readings required to process at least one target task in the current layer can be determined as the task processing requirements of the current layer.
[0050] Each performance parameter is used to reflect the processing performance of the corresponding computing chip. For example, the larger the performance parameter, the higher the processing performance of the corresponding computing chip, and the smaller the performance parameter, the lower the processing performance of the corresponding computing chip. Therefore, multiple computing chips with different performance parameters can be specifically understood as multiple computing chips, and each computing chip has different processing performance.
[0051] It should be noted that the electronic device is pre-configured with multiple computing chips with different processing performances and a large model containing a multi-layer structure (each layer is mainly an attention and / or FFN structure); or, a communication protocol is established between the electronic device and multiple computing chips with different processing performances configured in other devices. In this way, when at least one target task enters the current layer of the large model, firstly based on the task processing requirements of at least one target task, the target computing chip with the highest matching degree with the task processing requirements is determined from multiple computing chips with different processing performances; the highest matching degree here can be understood as the highest processing performance of using the target computing chip to process at least one target task in the current layer under the premise of the lowest resource waste and the highest computing efficiency.
[0052] Exemplarily, if the amount of computing and data reading required to process at least one target task in the current layer of the large model is large, a target computing chip with high processing performance can be matched to process the at least one target task; if the amount of computing and data reading required to process at least one target task in the current layer of the large model is small, a target computing chip with low processing performance can be matched to process at least one target task; in this way, at least one target task in the current layer of the large model is distributed to the target computing chip, so that the target computing chip performs corresponding processing on at least one target task, and when the number of target tasks is multiple, the target computing chip can calculate multiple target tasks at the same time; this can reduce resource waste, reduce costs, and at the same time speed up the process.
[0053] The large model implementation method based on multi-layer task processing provided by the present invention, for the target task entering the current layer in the large model, first determines the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters, and then distributes the target task in the current layer to the target computing chip for corresponding processing. In this way, combined with the implementation concept of the PP method, according to the different computing requirements or task processing requirements of different layers in the large model, the target tasks entering different layers in the large model are distributed to target computing chips with different performance parameters for processing, thereby achieving the purpose of implementing the large model based on multi-layer task processing, which can not only reduce resource waste and reduce costs, but also speed up the model reasoning speed.
[0054] Based on the above Figure 2 In the large model implementation method based on multi-layer task processing shown, in an exemplary embodiment, step 210 can be specifically implemented through the following steps.
[0055] When the task processing requirements include the target sparsity of the current layer, the target computing chip for processing the target task in the current layer is determined from multiple computing chips with different performance parameters based on the mapping relationship between the sparsity-performance parameters set in advance for all layers in the large model and the target sparsity.
[0056] Specifically, since the sparsity of each layer in the large model is determined when the scale of the large model is determined, the sparsity of each layer can be implemented and determined using the sparsity strategy of the corresponding layer. For example, when the large model has 4 layers, the sparsity of the first layer is 0, the sparsity of the second layer is 10%, the sparsity of the third layer is 25%, and the sparsity of the fourth layer is 50%; therefore, the mapping relationship between sparsity and performance parameters can be constructed and stored based on the sparsity of each layer in the large model with a determined scale and multiple different performance parameters. In this way, the target performance parameter corresponding to the target sparsity can be determined based on the target sparsity of the current layer in the large model and the above mapping relationship, and then the computing chip with the target performance parameter can be searched from the computing chips with multiple different performance parameters, and the found computing chip is determined as the target computing chip for processing the target task in the current layer.
[0057] It should be noted that when using the large model implementation method based on multi-layer task processing provided by the present invention to perform large model calculations, the calculation stages of different layers have different calculation characteristics after multi-layer sparseness, especially after adopting multi-card parallel implementation, it can support longer reasoning lengths and more batch tasks, and the difference in computing power and bandwidth requirements is more obvious. Taking the generative pre-trained Transformer (GPT) model reasoning as an example, after adopting multi-layer attention sparseness and multi-layer FFN sparseness, the first layer still needs complete parameters and calculations, and all KVcache needs to be saved, and the requirements for memory, bandwidth and computing power are relatively high. After the last layer is highly sparse, the parameters, calculations and KVcache are greatly reduced compared to the first layer, and the requirements for memory, bandwidth and computing power are relatively low.
[0058] Furthermore, considering the different computing characteristics of different layers of the sparse large model, when combined with PP multi-card parallel implementation, the tasks of different layers are distributed to different types of computing chips. For example, when PP multi-card parallel, the front layers can be implemented with computing chips with better performance, and the back layers can be implemented with some lower-cost and lower-performance computing chips. This can avoid waste of resources, reduce costs, and achieve better inference speed.
[0059] In addition, considering that different layers have different computing requirements after being sparse to different degrees, when combined with the PP method for parallel implementation, it can be implemented with computing chips with different performance parameters. Compared with the existing large model implementation method, it will not reduce the reasoning speed, but can be implemented with a heterogeneous system composed of lower-cost computing chips, which reduces the model reasoning cost and improves resource utilization.
[0060] Based on the above Figure 2In the large model implementation method based on multi-layer task processing shown, in an exemplary embodiment, step 210 can also be specifically implemented through the following steps.
[0061] When the task processing requirements include the target quantization parameters of the current layer, based on the mapping relationship between the quantization parameters and performance parameters set in advance for all layers in the large model and the target quantization parameters, the target computing chip for processing the target task in the current layer is determined from multiple computing chips with different performance parameters.
[0062] Specifically, considering that different layers in a large model can be implemented in a sparse manner using different sparse strategies, different quantization strategies can also be used. For example, the first layer in the large model is not quantized, the last layer is quantized with very low bits, and the middle layer is quantized with higher bits; in this way, the quantization parameters that characterize the degree of quantization of each layer can be determined, and a mapping relationship between quantization parameters and performance parameters can be constructed and stored based on the quantization parameters of each layer in the large model and multiple different performance parameters. In this way, the target performance parameter corresponding to the target quantization parameter can be determined based on the target quantization parameter of the current layer in the large model and the above mapping relationship, and then the computing chip with the target performance parameter can be searched from computing chips with multiple different performance parameters, and the found computing chip can be determined as the target computing chip for processing the target task in the current layer.
[0063] Based on the above Figure 2 In the large model implementation method based on multi-layer task processing shown, in an exemplary embodiment, step 210 can also be specifically implemented through the following steps.
[0064] First, when there is no target performance parameter that matches the target sparsity of the current layer or the target quantization parameter of the current layer among multiple different performance parameters, the performance parameter proportional relationship used to build a computing chip heterogeneous framework is updated based on the target performance parameter; then, based on the updated performance parameter proportional relationship, multiple computing chips with different performance parameters are updated, and the target computing chip for processing the target task in the current layer is determined based on the update result.
[0065] Specifically, if there is no target performance parameter among multiple different performance parameters that matches the target sparsity of the current layer or the target quantization parameter of the current layer, it can be understood that there is no target computing chip among the multiple computing chips configured in the electronic device that can process at least one target task in the current layer to achieve the highest resource utilization and the lowest model inference cost. At this time, it can be guided to update the hardware architecture, that is, based on the target performance parameters, the proportional relationship of performance parameters used to build a heterogeneous framework of computing chips is updated, and the updated performance parameter proportional relationship is used to update multiple computing chips with different performance parameters, so that the updated multiple computing chips contain the target computing chip that processes at least one target task in the current layer, and the target computing chip is selected from the updated multiple computing chips.
[0066] It should be noted that, in an exemplary embodiment, the process of determining a plurality of computing chips with different performance parameters includes the following steps.
[0067] Determine a proportional relationship of performance parameters for building a heterogeneous framework of computing chips; and determine all computing chips that satisfy the proportional relationship of performance parameters as computing chips with multiple different performance parameters.
[0068] Specifically, to determine the proportional relationship of performance parameters for building a heterogeneous framework for computing chips, the performance parameter proportional relationship that matches the sparsity proportional relationship can be determined based on the sparsity proportional relationship between different layers of the large model after multiple layers of sparseness; or, the performance parameter proportional relationship that matches the quantization parameter proportional relationship can be determined based on the quantization parameter proportional relationship between different layers of the large model after multiple layers of quantization.
[0069] It should be noted that when each layer in the large model is sparsely distributed by the corresponding sparse strategy or quantized by the corresponding quantization strategy, the sparsity or quantization degree of each layer is also determined, so that the sparsity ratio relationship can be determined based on the sparsity of each layer, or the quantization parameter ratio relationship can be determined based on the quantization degree of each layer, and then the sparsity ratio relationship or quantization parameter ratio relationship can be determined as the performance parameter ratio relationship. For example, when the sparsity ratio relationship or the quantization parameter ratio relationship is 1:2:3, the performance parameter ratio relationship for building a computing chip heterogeneous framework is also determined to be 1:2:3; when the sparsity ratio relationship or the quantization parameter ratio relationship is 1:5:10, the performance parameter ratio relationship for building a computing chip heterogeneous framework is also determined to be 1:5:10.
[0070] At this time, all computing chips that meet the performance parameter ratio relationship can be determined as computing chips with multiple different performance parameters, so as to build a computing chip heterogeneous framework based on computing chips with multiple different performance parameters, and then determine the target computing chip for processing the target task in the current layer from the computing chip heterogeneous framework.
[0071] Based on the above Figure 2 The large model implementation method based on multi-layer task processing shown in an exemplary embodiment may also include the following steps.
[0072] The task processing result output by the current layer is passed to the next layer of the current layer, and the task processing requirements are redetermined based on the new tasks received by the current layer, and the new tasks are used as new target tasks. The steps of determining the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters are returned; until the task processing stop conditions are met.
[0073] Among them, the task processing time of the current layer and the next layer is consistent, and the task processing time is the time for the target computing chip to fully utilize its own computing power and bandwidth to process the corresponding target task; the new task is the task processing result corresponding to the previous layer of the current layer or the pending task that initially enters the large model.
[0074] Specifically, the present invention takes into account the characteristics of different layers when calculating after the large model is sparse or quantized, and respectively assigns different computing chips to complete the task processing of the corresponding layers.
[0075] For example, the large model has 4 layers, each of which is mainly an attention+FFN structure. There are 4 computing chips in total for parallel implementation. Each computing chip processes the tasks in one layer. The first layer is not sparse, and the complete parameters and KVcache are retained; the second layer is 10% sparse, the third layer is 25% sparse, and the fourth layer is 50% sparse. If the four computing chips use the same processing performance, the following will be obtained: Figure 3 One of the task processing flow diagrams shown in Figure 3 In the example, task 0 is a batch task 0 containing at least one task, task 1 is a batch task 1 containing at least one task, task 2 is a batch task 2 containing at least one task, Layer0 is the first layer after the large model is sparse, Layer1 is the second layer after the large model is sparse, Layer2 is the third layer after the large model is sparse, and Layer3 is the fourth layer after the large model is sparse; due to the later layers (such as Figure 3 Layer3 in the sparse post-processing speed is faster, so the computing chip corresponding to Layer1 cannot start the calculation of Task 1 immediately after finishing the calculation of Task 0. It needs to wait until the computing chip corresponding to Layer0 finishes the calculation of Task 1 before it can start. This will cause bubbles in the middle. The bubbles mean that the computing chip does not work during the waiting period, wasting computing chip resources.
[0076] In order to solve the problem of computing chip resource waste, the present invention sets the time for each layer of the large model to process the batch tasks after the corresponding sparseness or quantization to be consistent, that is, the cumulative time for each layer in the large model to process the batch tasks after the sparseness or quantization is the same, so as to make full use of the corresponding computing chip resources, ensure that each computing chip is working in each time period, and when the parameter amount and calculation amount of the later layer in the large model are smaller, the computing power and bandwidth of the computing chip that processes the batch tasks entering the layer are less than the computing power and bandwidth of the computing chip that processes the batch tasks entering the front layer.
[0077] For example, Figure 4 The second task processing flow diagram shown in Figure 4 In the figure, the target computing chip for processing batch tasks in Layer0 is GPU0, the target computing chip for processing batch tasks in Layer1 is GPU1, the target computing chip for processing batch tasks in Layer2 is GPU2, and the target computing chip for processing batch tasks in Layer3 is GPU3, and the processing performance of GPU0~GPU3 is different; for example, the number of parameters and the amount of calculation of Layer3 are smaller, and Layer3 is 50% sparser than Layer0, so the computing power and bandwidth of GPU3 required are only half of that of GPU0, thereby eliminating the vacancy time in the waiting period during the batch task processing, and the overall inference time does not increase, and by using a lower-cost computing chip corresponding to each layer, the resource utilization of the computing chip is improved.
[0078] Based on this, for the large model after sparse or quantization, when the task processing time of each target computing chip to process at least one target task entering the corresponding layer is the same, it can be determined that each target computing chip has completed the calculation of at least one target task entering the corresponding layer and has not stopped working during the entire time period of the same task processing time. At this time, the task processing result corresponding to the current layer can be passed to the next layer as the target task of the next layer of the current layer, and the current layer can receive the task processing result passed by the previous layer or the task to be processed that initially enters the large model, and use the received task processing result or the task to be processed as the new target task of the current layer, and re-determine the task processing requirements based on the new target task, and then repeat steps 210 and 220. Until the task processing stop condition is met; the task processing stop condition here can be preset, such as the first layer of the large model does not receive a task within a certain period of time after passing the task processing result to the next layer, it can be considered that the task processing stop condition is met; or, the non-first layer of the large model does not pass the task processing result within a certain period of time after the task processing is completed; or, the task processing result output by the last layer carries a preset end symbol; the present invention does not make specific restrictions on this.
[0079] It should be noted that, for the processing process of the target task of the next layer, reference may be made to the processing process of the target task of the current layer in the aforementioned steps 210 and 220, which will not be repeated here.
[0080] The following describes the large model implementation device based on multi-layer task processing provided by the present invention. The large model implementation device based on multi-layer task processing described below and the large model implementation method based on multi-layer task processing described above can be referenced to each other.
[0081] Reference Figure 5 , which is a schematic diagram of the structure of the large model implementation device based on multi-layer task processing provided by the present invention, such as Figure 5 As shown, the large model implementation device 500 based on multi-layer task processing includes: a chip determination unit 510 and a model implementation unit 520.
[0082] The chip determination unit 510 is used to determine the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters.
[0083] The model implementation unit 520 is used to distribute the target tasks in the current layer to the target computing chip for corresponding processing.
[0084] Optionally, the chip determination unit 510 is specifically used to determine the target computing chip for processing the target task in the current layer from a plurality of computing chips with different performance parameters based on the mapping relationship between the sparsity-performance parameters pre-set for all layers in the large model and the target sparsity, when the task processing requirements include the target sparsity of the current layer.
[0085] Optionally, the chip determination unit 510 is specifically used to determine the target computing chip for processing the target task in the current layer from a plurality of computing chips with different performance parameters based on the mapping relationship between the quantization parameters and performance parameters pre-set for all layers in the large model and the target quantization parameters when the task processing requirements include the target quantization parameters of the current layer.
[0086] Optionally, the chip determination unit 510 is specifically used to update the performance parameter proportional relationship used to build a computing chip heterogeneous framework based on the target performance parameters when there is no target performance parameter matching the target sparsity of the current layer or the target quantization parameter of the current layer among multiple different performance parameters; update multiple computing chips with different performance parameters based on the updated performance parameter proportional relationship, and determine the target computing chip for processing the target task in the current layer based on the update result.
[0087] Optionally, the chip determination unit 510 is specifically used to determine a performance parameter ratio relationship for building a computing chip heterogeneous framework; and determine all computing chips that satisfy the performance parameter ratio relationship as computing chips with multiple different performance parameters.
[0088] Optionally, the chip determination unit 510 is specifically used to determine a performance parameter proportional relationship that matches the sparsity proportional relationship based on the sparsity proportional relationship between different layers of the large model after multiple layers of sparseness; or to determine a performance parameter proportional relationship that matches the quantization parameter proportional relationship based on the quantization parameter proportional relationship between different layers of the large model after multiple layers of quantization.
[0089] Optionally, the model implementation unit 520 is specifically used to pass the task processing result output by the current layer to the next layer of the current layer, and redetermine the task processing requirement based on the new task received by the current layer, and use the new task as a new target task, and return to the step of executing the computing chip based on the task processing requirement of the current layer in the large model and multiple different performance parameters to determine the target computing chip for processing the target task in the current layer; until the task processing stop condition is met; wherein, the task processing time of the current layer and the next layer is the same, the task processing time is the time for the target computing chip to fully utilize its own computing power and bandwidth to process the corresponding target task, and the new task is the task processing result corresponding to the previous layer of the current layer or the pending task that initially enters the large model.
[0090] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute a large model implementation method based on multi-layer task processing, the method comprising: determining a target computing chip for processing a target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters; and distributing the target task in the current layer to the target computing chip for corresponding processing.
[0091] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0092] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the large model implementation method based on multi-layer task processing provided by the above methods. The method includes: determining the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters; distributing the target task in the current layer to the target computing chip for corresponding processing.
[0093] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the large model implementation method based on multi-layer task processing provided by the above-mentioned methods. The method includes: determining the target computing chip for processing the target task in the current layer based on the task processing requirements of the current layer in the large model and multiple computing chips with different performance parameters; distributing the target task in the current layer to the target computing chip for corresponding processing.
[0094] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0095] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0096] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A large model implementation method based on multi-layer task processing, characterized in that: include: Determine a target computing chip for processing a target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters; Distribute the target task in the current layer to the target computing chip for corresponding processing.
2. The large model implementation method based on multi-layer task processing according to claim 1 is characterized in that: The step of determining a target computing chip for processing a target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters includes: In a case where the task processing requirement includes the target sparsity of the current layer, the target computing chip for processing the target task in the current layer is determined from the computing chips with different performance parameters based on the mapping relationship between the sparsity-performance parameters pre-set for all layers in the large model and the target sparsity.
3. The large model implementation method based on multi-layer task processing according to claim 1 is characterized in that: The step of determining a target computing chip for processing a target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters further includes: In the case where the task processing requirement includes the target quantization parameter of the current layer, based on the mapping relationship between the quantization parameter-performance parameter set in advance for all layers in the large model and the target quantization parameter, the target computing chip for processing the target task in the current layer is determined from the computing chips with different performance parameters.
4. The large model implementation method based on multi-layer task processing according to claim 1 is characterized in that: The step of determining a target computing chip for processing a target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters further includes: When there is no target performance parameter matching the target sparsity of the current layer or the target quantization parameter of the current layer among the multiple different performance parameters, updating the performance parameter proportional relationship for building a computing chip heterogeneous framework based on the target performance parameter; The computing chips with the multiple different performance parameters are updated based on the updated performance parameter ratio relationship, and the target computing chip for processing the target task in the current layer is determined based on the update result.
5. The large model implementation method based on multi-layer task processing according to any one of claims 1 to 4, characterized in that: The process of determining the plurality of computing chips with different performance parameters includes: Determine a performance parameter ratio relationship for building a computing chip heterogeneous framework; and determine all computing chips that satisfy the performance parameter ratio relationship as computing chips with the multiple different performance parameters.
6. The large model implementation method based on multi-layer task processing according to claim 5 is characterized in that: The determining of the performance parameter ratio relationship for building a computing chip heterogeneous framework includes: Based on the sparsity ratio relationship between different layers of the large model after multi-layer sparseness, determine the performance parameter ratio relationship that matches the sparsity ratio relationship; or, Based on the quantization parameter proportional relationship between different layers after the large model is quantized through multiple layers, the performance parameter proportional relationship that matches the quantization parameter proportional relationship is determined.
7. The large model implementation method based on multi-layer task processing according to any one of claims 1 to 4 is characterized in that: The method further comprises: The task processing result output by the current layer is passed to the next layer of the current layer, and the task processing requirement is re-determined based on the new task received by the current layer, and the new task is used as a new target task, and the computing chip that executes the task processing requirement of the current layer in the large model and multiple different performance parameters is returned to determine the target computing chip that processes the target task in the current layer; until the task processing stop condition is met; Among them, the task processing time of the current layer and the next layer is consistent, the task processing time is the time for the target computing chip to fully utilize its own computing power and bandwidth to process the corresponding target task, and the new task is the task processing result corresponding to the previous layer of the current layer or the pending task that initially enters the large model.
8. A large model implementation device based on multi-layer task processing, characterized in that: include: A chip determination unit, configured to determine a target computing chip for processing a target task in the current layer based on the task processing requirements of the current layer in the large model and a plurality of computing chips with different performance parameters; The model implementation unit is used to distribute the target task in the current layer to the target computing chip for corresponding processing.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, it implements the large model implementation method based on multi-layer task processing as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the large model implementation method based on multi-layer task processing as described in any one of claims 1 to 7 is implemented.
