Model training method, device and system and computing equipment
By selecting the training scheme with the lowest performance overhead in the low-rank fine-tuning algorithm and utilizing parallel training technology with an accelerator card, the problem of efficiency impacted by manual parameter tuning in the low-rank fine-tuning algorithm is solved, and efficient model fine-tuning is achieved.
Patent Information
- Application Number
- CN202411120228.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2026-03-03
AI Technical Summary
In existing technologies, low-rank fine-tuning algorithms require manual parameter tuning during the fine-tuning of large language models, which affects the efficiency of model fine-tuning.
The fine-tuning model to be trained is determined based on the pre-trained model and the fine-tuning module. A target training scheme is adopted to control the parallel training of multiple accelerator cards, and the training scheme with the least performance overhead is selected to reduce communication overhead and waste of computing resources.
It improves the efficiency of model fine-tuning without the need for manual parameter tuning, and enhances the versatility and efficiency of model training.
Smart Images

Figure CN121599082A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence (AI) technology, and in particular to a model training method, apparatus, system and computing device. Background Technology
[0002] Model fine-tuning refers to further training a pre-trained model using a specific dataset to adapt it to a particular domain or task. Currently, low-rank adaptation (LoRA) algorithms are widely used in the fine-tuning of large language models (LLMs). The core idea of the LoRA algorithm is to decompose the weights of the pre-trained model into two low-rank matrices. By freezing the weights of the pre-trained model and updating only the low-rank matrices, efficient fine-tuning of the model can be achieved.
[0003] In related technologies, the LoRA algorithm is optimized in the following ways: for example, the pre-trained model is quantized using the NF4 (normal float 4) data format, and then the quantized model is fine-tuned in low rank, thereby reducing the GPU memory occupied when fine-tuning large models.
[0004] However, in the above method, quantizing the pre-trained model will cause the optimized LoRA algorithm to be inequivalent to the original LoRA algorithm. Therefore, manual parameter tuning is required, which will affect the efficiency of model fine-tuning. Summary of the Invention
[0005] This application provides a model training method, apparatus, system, and computing device that can improve the efficiency of model fine-tuning.
[0006] Firstly, this application provides a model training method applicable to scenarios involving fine-tuning a pre-trained model. This application does not limit the type or structure of the pre-trained model; illustratively, the method includes:
[0007] Based on the pre-trained model and the fine-tuning module, the fine-tuning model to be trained is determined. The fine-tuning module includes multiple fine-tuning matrices, which are used to update the pre-trained weight matrix of the pre-trained model while keeping it unchanged.
[0008] The target training scheme is based on the fine-tuning model. The fine-tuning model is trained, and the target training scheme is determined based on the configuration information of the fine-tuning model. The target training scheme indicates the order and number of operators to be executed during the training of the fine-tuning model.
[0009] In the above method, after obtaining the fine-tuned model to be trained based on the pre-trained model and the fine-tuning module, the fine-tuned model is trained according to the target training scheme. The target training scheme is a scheme determined based on the configuration information of the fine-tuned model. Since the configuration information is usually used to set relevant parameters and rules for the model's operation, which in turn affects the model's understanding of data and the accuracy of output results, the order and number of operators to be executed during the fine-tuned model training process can be set in a targeted manner according to the configuration information of the fine-tuned model. This can result in a training scheme that better meets the training requirements of the fine-tuned model. Therefore, after training the fine-tuned model according to this training scheme, no manual parameter tuning is required, which improves the model fine-tuning efficiency while ensuring the model training requirements.
[0010] Optionally, based on the target training scheme for the fine-tuning model, the fine-tuning model is trained, including:
[0011] Based on the target training scheme, multiple accelerator cards are controlled to train and fine-tune the model in parallel. The accelerator cards are used to execute communication operators and computation operators in parallel.
[0012] This application does not limit the parallel strategy used for training and fine-tuning the model on multiple accelerator cards. It can employ column partitioning, where the weight matrix of the fine-tuned model is divided by columns and placed on each accelerator card, or row partitioning, where the weight matrix is divided by rows and placed on each accelerator card. In practical applications, a suitable parallel strategy can be selected based on the model architecture and accelerator card performance. This approach utilizes both the computational and communication resources of the accelerator cards, allowing them to execute computational operators simultaneously with communication operators, thereby reducing communication overhead.
[0013] Optionally, based on the target training scheme, multiple accelerator cards are controlled to train and fine-tune the model in parallel, including:
[0014] Based on the target training scheme, the first accelerator card among multiple accelerator cards is controlled to execute the first communication operator and the first computation operator in parallel;
[0015] There is no dependency between the first communication operator and the first computation operator, and both the first communication operator and the first computation operator are located before the second operator. There is a dependency between the second operator and the first communication operator, or there is a dependency between the second operator and the first computation operator.
[0016] Since the target training scheme can indicate the order and number of operators to be executed during the training and fine-tuning of the model, it is possible to control which communication and computation operators can be executed in parallel by the accelerator card, thereby reducing communication overhead.
[0017] Optionally, the method further includes: determining a target training scheme from multiple training schemes based on configuration information, wherein the target training scheme is the training scheme with the lowest performance overhead among the multiple training schemes, and the training results of different training schemes are equivalent.
[0018] By using the above method, the training scheme with the lowest performance overhead is selected from multiple training schemes with equivalent training results, thus saving computational resources while ensuring that the model training results are error-free.
[0019] Optionally, different training schemes may indicate different orders and numbers of operators to be executed.
[0020] It should be understood that different training schemes indicate different operator execution orders and numbers, and different operator execution orders and numbers occupy different computational resources. Therefore, different training schemes correspond to different performance overheads.
[0021] Optionally, based on configuration information, a target training scheme that meets the criteria is determined from multiple training schemes, including any of the following:
[0022] Based on the size of the input data indicated by the configuration information, the target training scheme is determined from multiple training schemes; or,
[0023] Based on the model accuracy indicated by the configuration information, the target training scheme is determined from multiple training schemes.
[0024] Although different training schemes may yield equivalent training results, the size of the matrix may differ. Furthermore, in actual numerical computation, the limited precision of computers and the differences in numerical computation methods result in different computational resources being consumed by different operator execution orders. Therefore, the target training scheme can be determined based on the size of the input data or the model precision indicated by the configuration information, making the determined target training scheme more suitable for the current fine-tuning model.
[0025] Optionally, based on the size of the input data indicated by the configuration information, a target training scheme is determined from multiple training schemes, including any of the following:
[0026] If the input data size indicates that the length of the input data is greater than its width, the first training scheme among multiple training schemes is determined as the target training scheme. The first training scheme indicates that the input data is processed based on the combined result of the pre-trained weight matrix and the fine-tuning module; or,
[0027] If the size of the input data indicates that the length of the input data is less than or equal to the width, the second training scheme among multiple training schemes is determined as the target training scheme. The second training scheme indicates that the input data is processed based on the pre-trained weight matrix and the fine-tuning module, respectively.
[0028] By using the above method, the target training scheme is determined based on the size of the input data indicated by the configuration information, making the determined target training scheme more suitable for the current fine-tuning model. Taking the LLM model as an example, as the length of the LLM input data increases, the order of magnitude of s increases, while h usually remains within a limited range. Therefore, determining the training scheme based on the size of the input data can effectively reduce the amount of operator computation and improve training efficiency.
[0029] Optionally, based on the model accuracy indicated by the configuration information, a target training scheme is determined from multiple training schemes, including:
[0030] Based on the prediction model accuracy corresponding to each training scheme, the training scheme that meets the model accuracy among multiple training schemes is determined as the target training scheme.
[0031] Since the execution order of different types of operators changes, the rounding error accumulation in the intermediate calculation process will be different. Therefore, it may ultimately affect the model accuracy and performance overhead. In this way, the target training scheme is determined according to the model accuracy indicated by the configuration information, so that the determined target training scheme reduces the performance overhead while meeting the model accuracy of the current fine-tuned model.
[0032] Optionally, the multiple training schemes include a first training scheme, which instructs that after executing a first addition operator, a first multiplication operator be executed. The first addition operator refers to calculating the sum of the pre-trained weight matrix and the result of the second multiplication operator, the second multiplication operator refers to calculating the product of multiple fine-tuning matrices, and the first multiplication operator refers to calculating the product of the result of the first addition operator and the input data; or...
[0033] Multiple training schemes include a second training scheme, which instructs the execution of a second addition operator after the execution of the third and fourth multiplication operators. The third multiplication operator refers to calculating the product of the input data and the pre-trained weight matrix. The fourth multiplication operator refers to calculating the product of the input data and the execution result of the fifth multiplication operator. The fifth multiplication operator refers to calculating the product of multiple fine-tuning matrices. The second addition operator refers to calculating the sum of the execution results of the third and fourth multiplication operators.
[0034] The above approach provides several training schemes with equivalent training results. Since the execution order and number of operators indicated by different training schemes are different, but their execution results are equivalent, the training scheme with the lowest performance overhead can be selected to reduce the number of operators and the amount of operator computation, thereby saving computing resources while ensuring that the model training results are error-free.
[0035] Secondly, this application provides a model training apparatus, which includes at least one functional unit for implementing the model training method provided by the first aspect or any possible implementation of the first aspect.
[0036] Thirdly, this application provides a model training system, which includes a host computer and an accelerator card. The host computer is used to control the accelerator card and to implement the model training method provided by the first aspect or any possible implementation of the first aspect.
[0037] Fourthly, this application provides a computing device including a processor and a memory, wherein the processor is configured to execute at least one piece of program code stored in the memory to enable the computing device to implement the model training method provided by the first aspect or any possible implementation thereof.
[0038] Fifthly, this application provides a computer-readable storage medium for storing at least one piece of program code, which, when executed by a computing device, causes the computing device to implement the model training method provided by the first aspect or any possible implementation thereof. This storage medium includes, but is not limited to, volatile memory, such as random access memory, and non-volatile memory, such as flash memory, hard disk drive (HDD), and solid-state drive (SSD).
[0039] Sixthly, this application provides a computer program product that, when run on a computing device, enables the computing device to implement the model training method provided by the first aspect or any possible implementation thereof. The computer program product can be a software installation package; when the aforementioned method needs to be implemented, the computer program product can be downloaded and executed on the computing device. Attached Figure Description
[0040] Figure 1 This is a schematic diagram illustrating the principle of a low-rank fine-tuning algorithm;
[0041] Figure 2 This is a schematic diagram of an implementation environment provided in an embodiment of this application;
[0042] Figure 3 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0043] Figure 4 This is a schematic diagram of the architecture of a model training method provided in an embodiment of this application;
[0044] Figure 5 This is a schematic diagram illustrating the principle of determining an execution scheme based on a training scheme, as provided in an embodiment of this application.
[0045] Figure 6 This is a flowchart of a model training method provided in an embodiment of this application;
[0046] Figure 7 This is a schematic diagram of a scheme determination stage provided in an embodiment of this application;
[0047] Figure 8 This is a schematic diagram of the parallel training process of a column segmentation strategy provided in an embodiment of this application;
[0048] Figure 9 This is a schematic diagram of the parallel training process of another column segmentation strategy provided in this application embodiment;
[0049] Figure 10 This is a schematic diagram of the parallel training process of a row segmentation strategy provided in an embodiment of this application;
[0050] Figure 11 This is a schematic diagram of the parallel training process of another row segmentation strategy provided in the embodiments of this application;
[0051] Figure 12 This is a schematic diagram of the structure of a model training device provided in an embodiment of this application. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be further described in detail below with reference to the accompanying drawings. It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application are authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the pre-trained models and fine-tuning modules involved in this application were obtained under fully authorized conditions.
[0053] To facilitate understanding, the key terms and concepts involved in this application will be explained below.
[0054] Artificial intelligence (AI) models are a class of mathematical algorithm models that use machine learning concepts to solve practical problems. Typically, AI models include a large number of parameters and calculation formulas (or calculation rules).
[0055] An operator (OP) is a computational unit or function that runs on a computing device. In the field of deep learning, neural network layers and even the entire model are composed of operators, which correspond to the computational logic within the neural network layers. For example, a convolutional layer is an operator; the weight summation process in a fully-connected layer (FClayer) is also an operator.
[0056] Acceleration cards, also known as acceleration devices, accelerators, or acceleration chips, are a type of specialized hardware accelerator or computer system designed to accelerate AI applications, especially neural networks, machine vision, and machine learning. For example, they provide computational power to perform calculations on matrices and vectors, thereby accelerating the computation of AI models. Illustratively, acceleration devices include, for example, graphics processing units (GPUs), neural network processing units (XPUs), intelligent processing units (IPUs), tensor processing units (TPUs), domain-specific architecture (DSA) chips, etc., and this application is not limited to these.
[0057] Model fine-tuning refers to further training and optimizing certain parameters of a pre-trained model for a specific task and dataset. It's important to understand that pre-trained models are typically trained on large-scale, general-purpose data, learning common features and knowledge. Fine-tuning, on the other hand, uses a smaller, labeled dataset relevant to a specific task to adaptively adjust the model, enabling it to better handle that task. During fine-tuning, the parameters of some layers in the pre-trained model are usually frozen (e.g., the lower layers that have learned general features), and only the parameters of specific layers or modules are adjusted. This avoids overfitting to small datasets while fully utilizing the useful information already learned by the pre-trained model.
[0058] Collective communication, also known as aggregation communication, refers to the global data migration and global control operations among a group of processors in a multi-computer system. It is widely used in distributed computing, enabling many-to-all data transmission between different processes. Common collective communication tasks include broadcast, barrier synchronization, reduce, scatter, gather, all gather, all scatter, and all reduce.
[0059] Parallel strategies in model training refer to breaking down computational tasks into multiple subtasks and distributing them across multiple nodes (such as accelerator cards) for execution. This fully utilizes parallel computing resources, significantly shortening training time and accelerating model convergence. Related technologies include model parallelism (or tensor parallelism), sequence parallelism (SP), and mixture of experts (MoE) parallelism, among others. The core idea behind these parallel strategies is to divide the model weights or activation values among multiple accelerator cards, allowing each accelerator card to handle a portion of the model's computation. This approach not only overcomes the memory capacity limitations of a single accelerator card but also supports the training of larger models.
[0060] In model parallelism, weight matrix partitioning can be used as an example. For matrix multiplication Y = X × W, X is an input matrix of dimension M × K, W is a weight matrix of dimension K × N, and Y is a result matrix of dimension M × N. If the size of the weight matrix W is large, even exceeding the memory capacity of a single accelerator card, it can be partitioned across multiple accelerator cards. The results can then be aggregated using aggregated communication, ensuring that the final result is mathematically equivalent to the result obtained by computing on a single accelerator card. Illustratively, the weight matrix W can be partitioned in the following two ways:
[0061] Method 1: Column Splitting. The parameter matrix W is split into columns W = [W1|W2], and W1 and W2 are placed on two accelerator cards respectively. The two accelerator cards calculate Y1 = X × W1 and Y2 = X × W2 respectively. After calculation, for any one accelerator card, the AllGather communication operator is executed to obtain the calculation result from the other accelerator card. The accelerator card's own calculation result and the obtained calculation result are then concatenated to obtain the final result matrix Y. It can be seen that by splitting the weight matrix W, which cannot be accommodated by the memory of a single accelerator card, and placing it on two accelerator cards, and then executing the AllGather communication operator, the final result can be obtained. This result is mathematically equivalent to the result obtained by calculating on a single accelerator card.
[0062] Method 2: Row Segmentation. To satisfy the matrix multiplication rules, the input matrix X is segmented by columns into X = [X1|X2], and the weight matrix W is segmented by rows into W = [W1|W2]. The segmented matrices are placed on two accelerator cards, and each accelerator card calculates Y1 = X1 × W1 and Y2 = X2 × W2 respectively. After the calculation is completed, for any accelerator card, the AllReduce communication operator is executed to obtain the calculation result from the other accelerator card. The final result matrix Y is obtained by adding the accelerator card's own calculation result to the obtained calculation result. It can be seen that by splitting the matrices W and X, which cannot be contained in the memory of a single accelerator card, and placing them on two accelerator cards, and then executing the AllReduce communication operator, the final result can be obtained. This result is mathematically equivalent to the result obtained by calculating on a single accelerator card.
[0063] Performance profiling results refer to detailed information and data obtained after performing performance analysis or profiling on a system, program, or process, regarding its operating status, resource usage, time consumption, etc. These results can help identify system performance bottlenecks and optimization directions. Typically, performance profiling results may include the following information: execution time, i.e., the time spent by each operation, function, module, or stage; CPU utilization, i.e., the CPU resource usage of different parts; memory usage, i.e., changes in memory usage, peak values, etc.; data transfer volume, i.e., the amount of data transferred between networks or different components; computational load, such as the number of floating-point operations; detailed statistics of specific operations or modules, such as the specific performance of a certain layer, etc., which are not limited in this application.
[0064] The application scenarios and implementation environment of this application are described below.
[0065] This application can be applied to scenarios involving fine-tuning pre-trained models. The application does not limit the type or structure of the pre-trained model. For example, the pre-trained model can be an open-source pre-trained large language model (LLM), such as CodeLlama, Llama, Llama2, StarCoder, ChatGLM2, CodeGeeX2, Qwen, etc., or it can be a U-Net model. This application does not limit the type or structure of the pre-trained model. Illustratively, the application uses the low-rank fine-tuning LoRA algorithm to fine-tune the pre-trained model as an example. The following references... Figure 1 This section introduces the principles of the LoRA algorithm.
[0066] Figure 1 This is a schematic diagram illustrating the principle of a low-rank fine-tuning algorithm. (For example...) Figure 1 As shown, trainable fine-tuning modules are added to certain layers of the pre-trained model (such as the Transformer layer of an LLM). These fine-tuning modules are obtained by performing a low-rank decomposition on the pre-trained weights of that layer. Specifically, after performing a low-rank decomposition on the pre-trained weight matrix of that layer, two fine-tuning matrices A and B with relatively small parameter counts are obtained. These two fine-tuning matrices are then added to that layer as fine-tuning modules. The pre-trained weight matrix is represented as follows: The fine-tuning matrix A is represented as The fine-tuning matrix B is represented as d represents the dimension of the input and output data of this layer, and r represents the rank of the fine-tuning module. The rank r is usually much smaller than d. It should be noted that low-rank decomposition can be achieved using singular value decomposition or random projection, etc., and there are no restrictions on which method is used.
[0067] For example, given input After adding the fine-tuning module, the output of this layer... Furthermore, h(W0+ΔW)x = W0x + BAx, ΔW = BA, and ΔW is the incremental parameter matrix obtained after fine-tuning, i.e., the fine-tuning module. During training, the pre-trained weight matrix W0 is frozen (i.e., W0 remains unchanged), and only the weights of the fine-tuning module are updated, that is, only the fine-tuning matrix A and fine-tuning matrix B are updated. It can be seen that although the pre-trained weight matrix W0 participates in the forward and backward calculations, its parameters are not updated. However, for the fine-tuning matrix A and fine-tuning matrix B, the gradient of ΔW is calculated, and its parameters are updated. Since the number of parameters of ΔW is relatively small, the computational load can be effectively reduced, and the model fine-tuning efficiency can be improved.
[0068] In related technologies, there are various optimization LoRA algorithms, but these optimization algorithms often require manual parameter tuning, which affects the efficiency of model fine-tuning. Based on this, this application provides a model training method that selects a training scheme that meets the conditions to train the fine-tuned model by performing equivalent transformations on various low-rank fine-tuning methods. This method ensures performance without the need for manual parameter tuning and improves the versatility of the method.
[0069] Please refer to the following first. Figure 2 This paper introduces the implementation environment involved in this application. Figure 2 This is a schematic diagram of an implementation environment provided in an embodiment of this application. For example... Figure 2 As shown, the implementation environment includes a model training system 200, which includes a host 201 and an accelerator card 202, and the host 201 and the accelerator card 202 are connected by communication.
[0070] The host 201 is used to provide model training services. In this embodiment, the host 201 can control the accelerator card 202 to execute the computational tasks involved in the model training process. For example, in response to a training request for a fine-tuned model, the host 201 controls the accelerator card 202 to execute the various forward and backward computation operators of the fine-tuned model. This process can also be understood as loading the computational tasks involved in the model training process into the accelerator card 202 for execution. Furthermore, the number of hosts 201 can be one or more, and this application does not limit this.
[0071] Accelerator card 202 is used to provide computing power for the model training process, thereby accelerating the training process. For example, accelerator card 202 can be a GPU, XPU, IPU, TPU, DSA chip, etc., and this application is not limited to these. Furthermore, the number of accelerator cards 202 can be one or more, and this application does not limit this. When there are multiple accelerator cards 202, the model training system 200 has distributed computing capabilities and can execute fine-tuning model training requests in a pipelined parallel manner. Pipeline parallelism includes, but is not limited to, naive pipeline parallelism, virtual pipeline parallelism, micro-batch pipeline parallelism, etc.
[0072] The aforementioned host 201 and accelerator card 202 can be integrated into a single server or configured separately; this application does not impose any limitations on this. Illustratively, taking the integration of host 201 and accelerator card 202 into a single server as an example, host 201 and accelerator card 202 are connected via a peripheral component interconnect express (PCIe) link, and data exchange between host 201 and accelerator card 202 occurs through the PCIe link. The aforementioned server can be an independent physical server, a server cluster composed of multiple physical servers, a distributed file system, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Taking a computing device as an example of a cloud server, the computing device can also be referred to as a cloud platform (i.e., short for cloud computing platform), which refers to services based on hardware and software resources, providing computing, network, and storage capabilities. Cloud computing platforms leverage the internet to remotely process and analyze massive amounts of data before returning it to users. This approach offers advantages such as large scale, distributed computing, virtualization, high availability, scalability, on-demand service, and security. Cloud platforms can rapidly deploy and distribute configurable computing resources with minimal management overhead and low interaction complexity between users and service providers.
[0073] Furthermore, the networks mentioned above include, but are not limited to, data center networks, storage area networks (SANs), local area networks (LANs), metropolitan area networks (MANs), wide area networks (WANs), mobile, wired or wireless networks, private networks, or virtual private networks (VPNs). In some implementations, technologies and / or formats, including Hypertext Markup Language (HTML) and Extensible Markup Language (XML), are used to represent data exchanged over the network. Additionally, conventional encryption technologies such as Secure Sockets Layer (SSL), Transport Layer Security (TLS), Virtual Private Networks (VPNs), and Internet Protocol Security (IPsec) can be used to encrypt all or part of the links. In other embodiments, custom and / or dedicated data communication technologies can be used to replace or supplement the aforementioned data communication technologies.
[0074] The hardware structure of host 201 in the above model training system is described below.
[0075] This application provides a computing device that can be configured as the aforementioned host 201, see reference. Figure 3 , Figure 3 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Figure 3 As shown, the computing device 300 includes a memory 301, a processor 302, a communication interface 303, and a bus 304. The memory 301, processor 302, and communication interface 303 are interconnected via the bus 304.
[0076] Memory 301 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Illustratively, memory 301 is used to store at least one piece of program code. When the program code stored in memory 301 is executed by processor 302, processor 302 performs the steps performed by the host in the following method embodiments.
[0077] The processor 302 may be a network processor (NP), a central processing unit (CPU), a graphics processing unit (GPU), an application-specific integrated circuit (ASIC), or an integrated circuit used to control the execution of the program of the present application. The processor 302 may be a single-core processor or a multi-core processor. The number of processors 302 may be one or more.
[0078] The communication interface 303 uses a transceiver module, such as a transceiver, to enable communication between the computing device 300 and other devices or communication networks. For example, data can be acquired through the communication interface 303.
[0079] The memory 301 and the processor 302 can be set separately or integrated together.
[0080] Bus 304 may include a pathway for transmitting information between various components of computing device 300 (e.g., memory 301, processor 302, communication interface 303).
[0081] Based on the above introduction to the application scenarios and implementation environment of this application, the model training method provided in this application will be introduced below.
[0082] For ease of understanding, please refer to the following: Figure 4 This paper introduces the overall architecture of the model training method provided in this application. Figure 4 This is a schematic diagram of the architecture of a model training method provided in an embodiment of this application. It should be understood that... Figure 4 This is merely an illustrative structural diagram illustrating the architecture of a model training method; this application does not limit the way the stages involved in this method are divided. Indicatively, the method is configured as described above. Figure 2 The model training system shown includes the following stages: pre-trained model input stage, pre-trained weight decomposition stage, scheme determination stage, forward computation stage, backward computation stage, and optimizer update stage.
[0083] The pre-trained model input stage refers to obtaining a pre-trained model, such as a pre-trained model uploaded by the user or a pre-trained model provided by the system. This application does not limit the type or structure of the pre-trained model.
[0084] The pre-training weight decomposition stage refers to performing low-rank decomposition on the pre-trained weight matrix in the pre-trained model to obtain multiple fine-tuning matrices. These fine-tuning matrices are then added to the pre-trained model as fine-tuning modules to obtain the fine-tuned model to be trained. Illustratively, the pre-trained model typically includes multiple layers. This application can add fine-tuning modules to each layer, or, depending on the model structure, add fine-tuning modules to specific layers; there is no limitation in this regard. For example, if the pre-trained model is an LLM, adding fine-tuning modules to the Transformer layer of the LLM forms the fine-tuned model to be trained.
[0085] The scheme determination stage refers to determining the target training scheme for the fine-tuning model. The target training scheme indicates the order and number of operators to be executed during the training of the fine-tuning model. For example, in related technologies, when using a low-rank fine-tuning algorithm to train a fine-tuning model, the training scheme corresponding to the following formula (1) is usually used for the layer where the fine-tuning module is located:
[0086] Y=Wx+λ(BAx) (1)
[0087] Where Y is the output of the layer containing the fine-tuning module in the fine-tuning model, W is the pre-training weight of the layer containing the fine-tuning module in the pre-trained model, x is the model input, λ is the weight coefficient of the fine-tuning module, λ=α / r, α is the hyperparameter, r is the rank of the fine-tuning matrix in the fine-tuning module, and B and A are the fine-tuning matrices of the fine-tuning module, respectively.
[0088] By performing an equivalent transformation on formula (1), we can obtain the training schemes corresponding to formulas (2) and (3) as follows:
[0089] Y=(W+λBA)x (2)
[0090] Y=Wx+(λBA)x (3)
[0091] Thus, the training scheme for training the fine-tuned model using the low-rank fine-tuning algorithm can include the three training schemes corresponding to the three formulas shown above. Since the execution order and number of operators indicated by different training schemes are different, but their execution results are equivalent, the target training scheme with the lowest performance overhead can be selected to reduce the number of operators and the amount of operator computation, thereby saving computational resources while ensuring that the model training results are error-free. The implementation method of this process will be described in detail in subsequent method embodiments, and will not be repeated here.
[0092] In some embodiments, the scheme determination stage further includes determining an execution scheme for fine-tuning the model based on the training scheme. The execution scheme indicates the operators to be executed on each accelerator card in the system. For example, when the model training system includes multiple accelerator cards, the multiple accelerator cards can perform parallel training. Typically, accelerator cards can execute communication operators and computation operators in parallel, that is, they can utilize the computational and communication resources of the accelerator cards simultaneously. Based on this, the execution scheme for parallel training and fine-tuning of the model by multiple accelerator cards can be optimized and arranged according to the training scheme, thereby effectively improving training efficiency.
[0093] Indicatively, for reference Figure 5 , Figure 5 This is a schematic diagram illustrating the principle of determining an execution scheme based on a training scheme, as provided in an embodiment of this application. Figure 5 As shown, taking the training scheme based on formula (1) Y=Wx+λ(BAx) as an example, for any fine-tuning module in the layer, when the pre-trained weight matrix W of the pre-trained model is divided into W1 and W2 by columns, W1 and W2 are placed on accelerator card 1 and accelerator card 2 respectively. In the figure, f represents Allgather communication and g represents X (identity) identity mapping. The forward propagation stage of this training scheme includes three parts:
[0094] The first part includes the Allgather communication operator (used to collect input data x from each accelerator card). i This process obtains the input data X (where i is an integer) required for subsequent operators. The Matmul matrix multiplication operator (used to calculate Y1 = W1X and Y2 = W2X respectively) is also used. Since the pre-trained weight matrix W has fixed parameters, this part can also be understood as the pre-trained fixed parameter communication and calculation process.
[0095] The second part includes the Matmul matrix multiplier (used to calculate Ax). i Allgather communication operator (used to collect Ax data from each accelerator card) i This yields the input data AX required for subsequent operators. The Matmul matrix multiplication operator (used to calculate ΔY1=λB1(AX) and ΔY2=λB2(AX) respectively) is used. Since matrices A and B are fine-tuning matrices, combined with the aforementioned... Figure 1 As can be seen from the principle shown, the fine-tuning matrix is an incremental parameter matrix, so this part can also be understood as the incremental communication and calculation process.
[0096] The third part includes the addition operator (used to calculate Y = Y + ΔY), which yields the output result.
[0097] Analysis of the above process reveals that if the accelerator card executes serially, then each communication operator and computation operator must be executed sequentially. Specifically, during pre-training fixed-parameter communication and computation, the Allgather communication operator corresponds to communication 1, the Matmul matrix multiplication operator Y = WX corresponds to computation 1, and the identity mapping g corresponds to communication 2; during incremental communication and computation, the Matmul matrix multiplication operator Ax... i Corresponding to computation 2, the Allgather communication operator corresponds to communication 3, the Matmul matrix multiplication operator ΔY=λB(AX) corresponds to computation 3, and the identity mapping g corresponds to communication 4; the addition operator Y=Y+ΔY corresponds to computation 4. Since accelerator cards typically have the ability to execute communication and computation operators in parallel, the serial execution scheme can be optimized into two pipelines based on the dependencies between them. That is, some communication operators and some computation operators can be executed in parallel, for example, parallel execution of communication 1 and computation 2, parallel execution of computation 1 and communication 3, etc. This reduces communication overhead and improves training efficiency. Furthermore, since each computation operator and each communication operator executes sequentially, when computation and communication operators are executed in parallel, communication 3 must wait for communication 1 to execute before it can execute, hence the gap between computation 2 and communication 3. Similarly, the gap between communication 3 and computation 3 is because computation 3 must wait for computation 1 to execute before it can execute. It should be noted that the diagram is for illustrating the principle of parallel execution. The dimensions of the boxes shown in the diagram are for illustrative purposes only and do not constitute a limitation on the execution time of each operator.
[0098] The forward propagation phase refers to the operators involved in controlling the accelerator card to execute the forward propagation process. This phase involves pre-trained communication and computation operators with fixed parameters (i.e., communication and computation processes related to the pre-trained weight matrix), as well as incremental communication and computation operators (i.e., communication and computation processes related to the fine-tuning matrix).
[0099] The backpropagation phase refers to the operators involved in controlling the accelerator card to execute the backpropagation process. Similar to the forward propagation phase, this phase also involves communication and computation operators with pre-trained fixed parameters (i.e., communication and computation processes related to the pre-trained weight matrix), as well as incremental communication and computation operators (i.e., communication and computation processes related to the fine-tuning matrix).
[0100] The optimizer update phase refers to updating the relevant parameters of the fine-tuning module based on the results generated in the backpropagation phase, such as the parameters of the fine-tuning matrix, the scaling factor that controls the degree of influence of the fine-tuning matrix, the bias terms of the model, etc. This application does not limit this.
[0101] Through the aforementioned stages, the fine-tuned model is trained. This approach, by performing equivalent transformations on various low-rank fine-tuning methods, facilitates the selection of the training scheme with the lowest performance overhead. The fine-tuned model is then trained based on this selected scheme, ensuring performance without requiring manual parameter tuning and improving the method's versatility. Furthermore, the execution scheme for fine-tuning the model can be determined based on the training scheme, reducing communication overhead and improving training efficiency.
[0102] It should be noted that the above Figure 4 and Figure 5 The illustrations shown are for informational purposes only and do not constitute a limitation of this application. For example, in the pre-training weight decomposition stage, it can be done according to... Figure 1 The low-rank fine-tuning algorithm shown performs low-rank decomposition of the weight matrix. It can also be combined with weight-decomposed low-rank adaptation (DoRA) to decompose the weight matrix into an amplitude vector m and a direction matrix. The direction matrix is then processed as described above. Figure 5 Based on the training scheme shown, an additional step of multiplying with the magnitude vector is added. For example, the formula (1) Y = Wx + λ(mBAx) is transformed into Y = Wx + λ(mBAx), where matrix B and matrix A are obtained by performing low-rank decomposition on the direction matrix. Other training schemes are similar and will not be elaborated further.
[0103] The model training method provided in this application will be introduced below through several method implementation examples.
[0104] Figure 6 This is a flowchart of a model training method provided in an embodiment of this application. Figure 6 As shown, the method is applied to a host in a model training system as an example. Schematic, the method includes the following steps 601 to 605.
[0105] 601. In response to a training request for a pre-trained model, obtain the pre-trained model and fine-tuning module.
[0106] In this embodiment, the model training system includes a host and an accelerator card. The host can access a wired or wireless network to provide model training services to users. The accelerator card is controlled by the host and provides computing power and storage space for the model training process. Indicatively, in response to a training request for a pre-trained model, the host obtains the pre-trained model and a fine-tuning module. The pre-trained model refers to a pre-trained model, such as a user-uploaded pre-trained model or a pre-trained model provided by the system. This application does not limit the type or structure of the pre-trained model. The training request instructs the fine-tuned pre-trained model to be trained; that is, the fine-tuning module is added to the pre-training module to obtain the fine-tuned model (hereinafter referred to as the fine-tuned model), and the fine-tuned model is trained.
[0107] The fine-tuning module includes multiple fine-tuning matrices, which are used to update the pre-trained weight matrix of the pre-trained model while keeping it unchanged. Indicatively, the multiple fine-tuning matrices are obtained by performing a low-rank decomposition on the pre-trained weight matrix of the pre-trained model. The low-rank decomposition can be implemented using singular value decomposition or random projection, etc., and this application does not limit the specific implementation.
[0108] In some embodiments, the fine-tuning module is a user-uploaded fine-tuning module. That is, the user performs low-rank decomposition on the pre-trained weight matrix of the pre-trained model to obtain multiple fine-tuning matrices, and sends these multiple fine-tuning matrices to the host, for example, by including the fine-tuning module in the training request. In other embodiments, the fine-tuning module is obtained by the host performing low-rank decomposition on the pre-trained weight matrix of the pre-trained model. For example, the training request also instructs the pre-trained model to be processed to obtain the fine-tuning module. This application does not limit the method by which the host obtains the fine-tuning module. Furthermore, this application does not limit the number of fine-tuning matrices in the fine-tuning module, as described above. Figure 1 Taking the low-rank fine-tuning algorithm shown as an example, for any fine-tuning module, the fine-tuning module includes a fine-tuning matrix A (denoted as...). ) and fine-tuning matrix B (represented as ), where d is the dimension of the input and output data of the layer where the fine-tuning module is located, and r is the rank of the fine-tuning module, which is usually much smaller than d. For example, taking the DoRA algorithm, the fine-tuning module includes an amplitude vector m (which can be understood as a fine-tuning matrix of size 1×d) and fine-tuning matrices A and B obtained by low-rank decomposition of the direction matrix (similar to the aforementioned fine-tuning matrices A and B, and will not be repeated).
[0109] Furthermore, pre-trained models typically consist of multiple layers. The host can obtain the fine-tuning modules corresponding to each layer, or it can obtain the fine-tuning modules corresponding to a specific layer based on the model structure. This application does not impose any limitations on this. For example, if the pre-trained model is an LLM, the fine-tuning modules corresponding to each Transformer layer of the LLM can be obtained.
[0110] 602. Based on the pre-trained model and the fine-tuning module, determine the fine-tuning model to be trained.
[0111] In this embodiment, the host computer adds the fine-tuning module to the corresponding layer of the pre-trained model according to the layer corresponding to the fine-tuning module, so as to obtain the fine-tuned model to be trained.
[0112] Steps 601 to 602 above are described using the example of the host obtaining the pre-trained model and the fine-tuned model and generating the fine-tuned model. In some scenarios, the fine-tuned model to be trained can also be uploaded by the user. For example, the host obtains the fine-tuned model uploaded by the user and receives the training request for the fine-tuned model. This application does not limit this.
[0113] 603. Based on the configuration information of the fine-tuned model, determine the target training scheme from multiple training schemes.
[0114] In this application's embodiments, the configuration information of the fine-tuning model is used to describe the model's purpose, computational framework, accuracy, input data size, inference code dependencies, and external API interfaces, etc., but this application is not limited to these. For any training scheme, the training scheme indicates the order and number of operators to be executed during the training of the fine-tuning model. In this application, the training results of different training schemes are equivalent, but the order and number of operators to be executed indicated by different training schemes are different. The target training scheme refers to the training scheme determined from multiple training schemes for training the fine-tuning model. The target training scheme is the training scheme with the lowest performance overhead among multiple training schemes. The performance overhead is reflected, for example, through the computational load of the accelerator card, communication latency, etc., which is not limited in this application. It should be understood that since configuration information is usually used to set relevant parameters and rules for the operation of the model, which in turn affects the model's understanding of data and the accuracy of output results, setting the order and number of operators to be executed during the fine-tuning model training process in a targeted manner based on the configuration information of the fine-tuning model can yield a training scheme that better meets the training needs of the fine-tuning model. Thus, after training the fine-tuning model according to this training scheme, no manual parameter tuning is required, thereby improving the efficiency of model fine-tuning while ensuring the model training requirements are met.
[0115] The following section introduces several training schemes. Illustratively, we take Y as the output of the layer containing the fine-tuning module in the fine-tuning model, W as the pre-training weight matrix of the pre-trained model, x as the input data of the model, λ as the weight coefficients of the fine-tuning module, λ = α / r, where α is a hyperparameter, r is the rank of the fine-tuning matrix in the fine-tuning module, and B and A as the fine-tuning matrices of the fine-tuning module, respectively. The multiple training schemes provided in this application include the following:
[0116] The first type, the first training scheme, is represented as Y = (W + λBA)x.
[0117] The first training scheme specifies that after executing the first addition operator, the first multiplication operator is executed. The first addition operator calculates the sum of the results of the pre-trained weight matrix and the second multiplication operator. The second multiplication operator calculates the product of multiple fine-tuning matrices. The first multiplication operator calculates the product of the result of the first addition operator and the input data. Combining the expression of the first training scheme, we know that the first addition operator is W + λBA, the first multiplication operator is (W + λBA)x, and the second multiplication operator is λBA. Therefore, the first training scheme refers to processing the input data based on the merged result after merging the pre-trained weight matrix and the fine-tuning module. In other words, the first training scheme indicates processing the input data based on the merged result of the pre-trained weight matrix and the fine-tuning module.
[0118] The second type, the second training scheme, is represented as Y = Wx + (λBA)x.
[0119] The second training scheme instructs that after executing the third and fourth multiplication operators, the second addition operator is executed. The third multiplication operator calculates the product of the input data and the pre-trained weight matrix; the fourth multiplication operator calculates the product of the input data and the result of the fifth multiplication operator; the fifth multiplication operator calculates the product of multiple fine-tuning matrices; and the second addition operator calculates the sum of the results of the third and fourth multiplication operators. Combining the expressions of the second training scheme, we know that the third multiplication operator is Wx, the fourth multiplication operator is (λBA)x, the second addition operator is Wx+(λBA)x, and the fifth multiplication operator is λBA=λB×A. Therefore, the second training scheme means that after processing the input data based on the pre-trained weight matrix and the fine-tuning module respectively, the two execution results are merged. Specifically, when processing the input data based on the fine-tuning module, the product of multiple fine-tuning matrices is first calculated based on the weight coefficients of the fine-tuning module before processing the input data. In other words, the second training scheme instructs that the input data be processed based on the pre-trained weight matrix and the fine-tuning module respectively.
[0120] The third type, the third training scheme, is represented as Y = Wx + λ(BAx).
[0121] The third training scheme specifies that after executing the sixth and seventh multiplication operators, a third addition operator is executed. The sixth multiplication operator calculates the product of the input data and the pre-trained weight matrix; the seventh multiplication operator calculates the product of the input data and the result of the eighth multiplication operator; the eighth multiplication operator calculates the product of multiple fine-tuning matrices; and the third addition operator calculates the sum of the results of the sixth and seventh multiplication operators. Combining the expressions of the third training scheme, we know that the sixth multiplication operator is Wx, the seventh multiplication operator is λ(BAx), the eighth multiplication operator is Ax, and the third addition operator is Wx + λ(BAx). Therefore, the third training scheme involves processing the input data based on the pre-trained weight matrix and the fine-tuning module separately, and then merging the two results. Specifically, when processing the input data based on the fine-tuning module, the input data is first processed based on the product of multiple fine-tuning matrices, and then multiplied by the weight coefficients of the fine-tuning module.
[0122] It should be understood that although different training schemes may have equivalent training results, the matrix sizes may differ. Furthermore, in actual numerical calculations, due to the limited precision of computers and the differences in numerical calculation methods, the computational resources occupied by different operator execution orders may vary. Therefore, the training scheme with the lowest performance overhead can be selected to reduce the number of operators and the amount of operator operations, thereby saving computational resources while ensuring that the model training results are error-free.
[0123] Based on this, this application provides an implementation method for selecting a target training scheme from multiple training schemes according to the configuration information of the fine-tuning model. This makes the selected target training scheme more suitable for the current fine-tuning model, effectively reducing the amount of operator computation and improving training efficiency. The optional implementation methods of this process are described below, illustratively including the following methods:
[0124] Method 1: Determine the target training scheme from multiple training schemes based on the size of the input data indicated by the configuration information.
[0125] Taking the aforementioned three training schemes as examples, if the size of the input data indicates that the length of the input data is greater than the width, the first training scheme is determined as the target training scheme; or, if the size of the input data indicates that the length of the input data is less than or equal to the width, the second training scheme is determined as the target training scheme; or, if the size of the first calculation result obtained based on the size of the input data is less than the size of the second calculation result, the third training scheme is determined as the target training scheme. Here, the first calculation result refers to the calculation result of BAx, that is, the product of the input data and the fine-tuning module, and the second calculation result refers to the calculation result of BA, that is, the product of each fine-tuning matrix in the fine-tuning module.
[0126] It should be understood that when the length of the input data is greater than its width, the computational cost of calculating W+λBA first and then (W+λBA)x is less than that of calculating Wx and (λBA)x first and then Wx+(λBA)x, and also less than that of Wx+λ(BAx). For example, if the size of the input data x is 100×10, the size of the pre-trained weight matrix is 10×10, the size of the fine-tuning matrix B is 10×1, the size of the fine-tuning matrix A is 1×10, and λ is 0.5, then obviously, if (W+λBA)x is used, the 100×10 matrix (input data x) only participates in one matrix multiplication. If Wx+(λBA)x or Wx+λ(BAx) is used, the 100×10 matrix (input data x) needs to participate in two matrix multiplications. Therefore, when the length of the input data is greater than its width, choosing the first training scheme can effectively reduce the computational cost and save computational resources.
[0127] Conversely, when the length of the input data is less than or equal to the width, the computational cost of calculating Wx and (λBA)x first, then Wx + (λBA)x, is less than the computational cost of calculating W + λBA first, then (W + λBA)x, and also less than the computational cost of Wx + λ(BAx). For example, if the size of the input data x is 10×10, the size of the pre-trained weight matrix is 10×10, the size of the fine-tuning matrix B is 10×1, the size of the fine-tuning matrix A is 1×10, and λ is 0.5, it is obvious that... Since the size of the input data x is relatively small, the computational cost of matrix addition and matrix multiplication is less when using Wx+(λBA)x than when using (W+λBA)x and Wx+λ(BAx). Moreover, if Wx+(λBA)x is used, λ only needs to be multiplied by a 10×1 matrix (fine-tuning matrix B), while if Wx+λ(BAx) is used, λ needs to be multiplied by a 10×10 matrix (the result of BAx). Therefore, choosing the second training scheme can effectively reduce the computational cost and save computational resources.
[0128] By using the above method, the target training scheme is determined based on the size of the input data indicated by the configuration information. This results in a target training scheme that is more suitable for the current fine-tuning model and has lower performance overhead. Taking an LLM model as an example, as the length of the input data in an LLM increases, the order of magnitude of 's' becomes increasingly larger, while 'h' usually remains within a limited range. Therefore, determining the training scheme based on the size of the input data can effectively reduce the amount of operator computation, reduce performance overhead, and improve training efficiency.
[0129] Method 2: Determine the target training scheme from multiple training schemes based on the model accuracy indicated by the configuration information.
[0130] Taking the aforementioned three training schemes as examples, based on the prediction model accuracy corresponding to each training scheme, the training scheme that meets the model accuracy indicated by the configuration information is determined as the target training scheme. The prediction model accuracy corresponding to each training scheme can be manually estimated or determined through performance analysis results of different training schemes. For example, a batch of training samples can be selected, trained using different training schemes, and the training process can be performed performance analysis. The target training scheme can then be selected based on the model accuracy indicated by the performance analysis results. Since changes in the execution order of different types of operators can lead to different accumulation methods of rounding errors in the intermediate calculation process, this may ultimately affect model accuracy and performance overhead. In this way, the target training scheme is determined based on the model accuracy indicated by the configuration information, ensuring that the determined target training scheme meets the model accuracy of the current fine-tuned model while reducing performance overhead.
[0131] 604. Based on the target training scheme, determine the execution scheme for parallel training and fine-tuning the model on multiple accelerator cards.
[0132] In the embodiments of this application, the execution scheme indicates the operators to be executed on each accelerator card. In some embodiments, the operators to be executed on the accelerator card include communication operators and computation operators to be executed in parallel. That is, both the computational and communication resources of the accelerator card are utilized, allowing the accelerator card to execute communication operators while simultaneously executing computation operators, thereby reducing communication overhead.
[0133] As can be seen from step 603 above, the target training scheme can indicate the order and number of operators to be executed during the training and fine-tuning of the model. Therefore, it is possible to determine which communication operators and which computation operators can be executed in parallel by the accelerator card based on the target training scheme.
[0134] Schematic, the host determines the execution scheme based on the dependency relationship between the communication operator and the computation operator indicated by the target training scheme. The dependency relationship indicates that the communication operator depends on the execution result of the computation operator, that is, the input data of the communication operator includes the execution result of the computation operator, or the computation operator depends on the execution result of the communication operator, that is, the input data of the computation operator includes the execution result of the communication operator.
[0135] Taking any communication operator and any computation operator to be executed on the accelerator card as an example, hereinafter referred to as the first communication operator and the first computation operator, respectively, if there is no dependency between the first communication operator and the first computation operator, and both the first communication operator and the first computation operator are located before the second operator, then the first communication operator and the first computation operator are determined to be communication operators and computation operators to be executed in parallel. There is a dependency between the second operator and the first communication operator, or a dependency between the second operator and the first computation operator. In other words, if there is no dependency between the first communication operator and the first computation operator, and both operators are executed before a certain operator, then these two operators can be considered as operators to be executed in parallel. For example, refer to the aforementioned... Figure 5 The low-rank fine-tuning algorithm, Allgather communication operator, and Ax shown are described. i There are no dependencies between the matrix multiplication operators, and both of these operators precede the λ(BAx) matrix multiplication operator. Therefore, the accelerator card can execute the Ax operator while executing the Allgather communication operator. i Matrix multiplication operators thus effectively reduce communication overhead.
[0136] In some embodiments, in this step, the host can select at least one sample according to the target training scheme, train the fine-tuned model according to the first execution scheme and the second execution scheme respectively, and then determine the execution scheme for multiple accelerator cards to train the fine-tuned model in parallel from the first execution scheme and the second execution scheme. The first execution scheme refers to executing each communication operator and computation operator serially, and the second execution scheme refers to executing the communication operator and computation operator in parallel. Of course, the host can also determine the execution scheme according to pre-set parameters for the fine-tuned model; this application does not limit this.
[0137] Furthermore, this application does not limit the parallel strategy used for training and fine-tuning the model in parallel on multiple accelerator cards. It can adopt column partitioning, which divides the weight matrix of the fine-tuning model into columns and places it on each accelerator card, or it can adopt row partitioning, which divides the weight matrix of the fine-tuning model into rows and places it on each accelerator card. In practical applications, an appropriate parallel strategy can be selected according to the model architecture and the performance of the accelerator cards.
[0138] Following steps 603 and 604 above, the host first determines the target training scheme based on the model configuration information. Then, based on the training scheme, it determines an execution scheme that reduces communication overhead. Combined with the aforementioned... Figure 4 This process is essentially the solution-determination stage. (Illustratively, refer to...) Figure 7 , Figure 7 This is a schematic diagram illustrating a solution determination stage provided in an embodiment of this application. For example... Figure 7As shown, the host selects the target training scheme with the lowest performance overhead from multiple training schemes based on the model configuration information. For example, taking the input data size as s×h (s represents length, h represents width), if s > h, the target training scheme is Y = (W + λBA)x; if s ≤ h, the target training scheme is Y = Wx + (λBA)x; or, if the size of BAx is smaller than the size of BA, the target training scheme is Y = Wx + λ(BAx). Next, based on the target training scheme, the execution scheme for parallel training and fine-tuning of the model using multiple accelerator cards is determined. This can also be understood as an optimization path for the communication and computation process. Taking the LLM model as an example, as the length of the LLM input data increases, the order of magnitude of s increases, while h usually remains within a limited range. Therefore, compared to the aforementioned third training scheme, selecting the aforementioned first or second training scheme can effectively reduce the amount of operator computation and improve training efficiency.
[0139] 605. In accordance with the execution plan, control multiple accelerator cards to train and fine-tune the model in parallel.
[0140] In this embodiment, the host controls each accelerator card to execute corresponding operators according to the execution plan, thereby achieving parallel training and fine-tuning of the model. During training, the pre-trained weight matrix remains unchanged, while multiple fine-tuning matrices are updated. Schematic, taking an execution plan indicating that the operators to be executed on the accelerator card include communication and computation operators to be executed in parallel as an example, for any one of the multiple accelerator cards (hereinafter referred to as the first accelerator card), the host controls the first accelerator card to execute the first communication operator and the first computation operator in parallel. There is no dependency between the first communication operator and the first computation operator, and both the first communication operator and the first computation operator are located before the second operator. There is a dependency between the second operator and the first communication operator, or a dependency between the second operator and the first computation operator. It should be understood that the first communication operator and the first computation operator are described in step 604 above and will not be repeated here.
[0141] In steps 604 and 605 above, the host computer, after determining the execution plan, controls multiple accelerator cards to train and fine-tune the model in parallel according to the execution plan. In some embodiments, the target training plan is a preset training plan determined based on configuration information, such as one set by the user or a default training plan provided by the model training system. Based on this, after executing steps 601 and 602, the host computer trains and fine-tunes the model based on the target training plan. In other embodiments, the execution plan corresponding to the target training plan is a preset execution plan, such as one set by the user or a default execution plan provided by the model training system. Based on this, after determining the target training plan, the host computer controls multiple accelerator cards to train and fine-tune the model in parallel according to the execution plan corresponding to the target training plan. The accelerator cards are used to execute communication operators and computation operators in parallel.
[0142] The following is for reference. Figures 8 to 11 Taking the aforementioned first and second training schemes as examples, this paper illustrates the process of implementing parallel training and fine-tuning of models using different parallel strategies.
[0143] Figure 8 This is a schematic diagram illustrating the parallel training process of a column segmentation strategy provided in an embodiment of this application. For example... Figure 8 As shown, the pre-trained weight matrix W of the pre-trained model is placed on accelerator card 1 (corresponding to W1) and accelerator card 2 (corresponding to W2) using column partitioning. The training scheme is the first training scheme, i.e., Y = (W + λBA)x. As mentioned earlier, the size of the fine-tuning matrix B is d × r, and the size of the fine-tuning matrix A is r × d. d represents the dimension of the input and output data of the layer where the fine-tuning module is located, and r is the rank of the fine-tuning module. The rank r is usually much smaller than d. Therefore, the fine-tuning matrix B is placed on accelerator card 1 and accelerator card 2 using column partitioning. Since the fine-tuning matrix A has a smaller r, it does not need to be partitioned.
[0144] During the forward propagation process (f represents Allgather communication, g represents the identity mapping of X (identity):
[0145] (1) Each accelerator card executes the Allgather communication operator (collecting the input data x that each accelerator card is responsible for). i This process obtains the input data X (where i is an integer) required for subsequent operators. Based on this, the addition operator W+λBA is executed in parallel, where accelerator card 1 executes W1+λB1A, accelerator card 2 executes W2+λB2A, and each accelerator card is responsible for its own input data x. i Calculate Ax i This refers to intermediate activation values (used for gradient calculation during subsequent backpropagation).
[0146] (2) Execute the Matmul matrix multiplication operator on each accelerator card. Based on this, execute the Allgather communication operator in parallel (collecting the Ax data from each accelerator card). i The input data AX required for subsequent operators is obtained. Accelerator card 1 executes the (W1+λB1A)X multiplication operator, which yields Y1+ΔY1, and accelerator card 2 executes the (W2+λB2A)X multiplication operator, which yields Y2+ΔY2. Based on this, the forward propagation execution result Y+ΔY is obtained. It should be understood that Y+ΔY includes Y1+ΔY1 and Y2+ΔY2.
[0147] As can be seen, during the forward propagation process, the weight merging of incremental decomposition and the calculation of intermediate activation values are performed simultaneously with the communication of input data. Furthermore, the entire forward propagation is completed simultaneously with the communication of incremental decomposition results. In this way, some communication operators and some computation operators can be executed in parallel, reducing communication overhead and improving training efficiency.
[0148] During backpropagation (f represents Reduce-scatter communication, g represents the identity mapping of X (identity):
[0149] (1) Each accelerator card executes the Reduce-scatter communication operator (distributing the intermediate activation value Ax it is responsible for to each accelerator card). i Based on this, intermediate gradient calculations are performed in parallel.
[0150] (2) Each accelerator card performs gradient calculation of the fine-tuning matrix. Based on this, the Reduce-scatter communication operator is executed in parallel (distributing the intermediate calculation results of the gradient to each accelerator card). It should be understood that although the pre-trained weight matrix remains unchanged during training, its gradient still needs to be calculated.
[0151] As can be seen, during backpropagation, intermediate gradient calculations are performed simultaneously with communication of intermediate activation values. Furthermore, the incremental weight gradient is output simultaneously with communication of intermediate gradient calculation results. This allows some communication operators and some computation operators to be executed in parallel, reducing communication overhead and improving training efficiency. Additionally, each accelerator card updates the parameters of the fine-tuning matrix based on the calculated gradients.
[0152] Figure 9 This is a schematic diagram illustrating the parallel training process of another column segmentation strategy provided in an embodiment of this application. For example... Figure 9As shown, the pre-trained weight matrix W of the pre-trained model is placed on accelerator card 1 (corresponding to W1) and accelerator card 2 (corresponding to W2) using column partitioning. The training scheme is the second training scheme, i.e., Y = Wx + (λBA)x. As mentioned earlier, the size of the fine-tuning matrix B is d × r, and the size of the fine-tuning matrix A is r × d. d represents the dimension of the input and output data of the layer where the fine-tuning module is located, and r is the rank of the fine-tuning module. The rank r is usually much smaller than d. Therefore, the fine-tuning matrix B is placed on accelerator card 1 and accelerator card 2 using column partitioning. Since the fine-tuning matrix A has a smaller r, it does not need to be partitioned.
[0153] During the forward propagation process (f represents Allgather communication, g represents the identity mapping of X (identity):
[0154] (1) Each accelerator card executes the Allgather communication operator (collecting the input data x that each accelerator card is responsible for). i This process obtains the input data X (where i is an integer) required for subsequent operators. Based on this, the multiplication operator λB is executed in parallel, with accelerator card 1 executing λB1, accelerator card 2 executing λB2, and each accelerator card performing the multiplication based on its assigned input data x. i Calculate Ax i This refers to intermediate activation values (used for gradient calculation during subsequent backpropagation).
[0155] (2) Each accelerator card executes the Matmul matrix multiplication operator, and on this basis, executes the Allgather communication operator in parallel (collecting the Ax data from each accelerator card). i The input data AX required for subsequent operators is obtained. Accelerator card 1 executes the W1X multiplication operator and the λB1AX multiplication operator to obtain Y1+ΔY1, and accelerator card 2 executes the W2X multiplication operator and the λB2AX multiplication operator to obtain Y2+ΔY2. Based on this, the forward propagation execution result Y+ΔY is obtained. It should be understood that Y+ΔY includes Y1+ΔY1 and Y2+ΔY2.
[0156] As can be seen, during the forward propagation process, matrix multiplication between the weights and weight coefficients of the incremental decomposition and the calculation of intermediate activation values are performed simultaneously with the communication of input data. Furthermore, the entire forward propagation is completed simultaneously with the communication of the incremental decomposition results. In this way, some communication operators and computation operators can be executed in parallel, reducing communication overhead and improving training efficiency.
[0157] During backpropagation (f represents Reduce-scatter communication, g represents the identity mapping of X (identity):
[0158] (1) Each accelerator card executes the Reduce-scatter communication operator (distributing the intermediate activation value Ax it is responsible for to each accelerator card). i Based on this, intermediate gradient calculations are performed in parallel.
[0159] (2) Each accelerator card performs gradient calculation of the fine-tuning matrix. Based on this, the Reduce-scatter communication operator is executed in parallel (distributing the intermediate calculation results of the gradient to each accelerator card). It should be understood that although the pre-trained weight matrix remains unchanged during training, its gradient still needs to be calculated.
[0160] As can be seen, during backpropagation, intermediate gradient calculations are performed simultaneously with communication of intermediate activation values. Furthermore, the incremental weight gradient is output simultaneously with communication of intermediate gradient calculation results. This allows some communication and computation operators to be executed in parallel, reducing communication overhead and improving training efficiency. Additionally, each accelerator card updates the parameters of the fine-tuning matrix based on the calculated gradients.
[0161] Figure 10 This is a schematic diagram illustrating the parallel training process of a row segmentation strategy provided in an embodiment of this application. For example... Figure 10 As shown, the pre-trained weight matrix W of the pre-trained model is placed on accelerator card 1 (corresponding to W1) and accelerator card 2 (corresponding to W2) using row partitioning. The training scheme is the first training scheme, i.e., Y = (W + λBA)x. As mentioned earlier, the size of the fine-tuning matrix B is d × r, and the size of the fine-tuning matrix A is r × d, where d is the dimension of the input and output data of the layer containing the fine-tuning module, and r is the rank of the fine-tuning module. The rank r is usually much smaller than d. Therefore, the fine-tuning matrix A is placed on accelerator card 1 and accelerator card 2 using row partitioning. Since the fine-tuning matrix B has a smaller r, it does not need to be partitioned. It should be understood that... Figure 10 The training process shown is the same as described above. Figure 8 Similarly, the difference lies in the type of communication operator, which will not be elaborated here. That is, in the forward propagation process, f represents the identity mapping of X (identity), and g represents Reduce-scatter communication; in the backward propagation process, f represents the identity mapping of X (identity), and g represents Allgather communication.
[0162] Figure 11 This is a schematic diagram illustrating the parallel training process of another row segmentation strategy provided in this application embodiment. For example... Figure 11As shown, the pre-trained weight matrix W of the pre-trained model is placed on accelerator card 1 (corresponding to W1) and accelerator card 2 (corresponding to W2) using row partitioning. The training scheme is the second training scheme, i.e., Y = Wx + (λBA)x. As mentioned earlier, the size of the fine-tuning matrix B is d × r, and the size of the fine-tuning matrix A is r × d, where d is the dimension of the input and output data of the layer where the fine-tuning module is located, and r is the rank of the fine-tuning module. The rank r is usually much smaller than d. Therefore, the fine-tuning matrix A is placed on accelerator card 1 and accelerator card 2 using row partitioning. Since the fine-tuning matrix B has a smaller r, it does not need to be partitioned. It should be understood that... Figure 11 The training process shown is the same as described above. Figure 9 Similarly, the difference lies in the type of communication operator, which will not be elaborated here. That is, in the forward propagation process, f represents the identity mapping of X (identity), and g represents Reduce-scatter communication; in the backward propagation process, f represents the identity mapping of X (identity), and g represents Allgather communication.
[0163] In summary, in the model training process provided in this application embodiment, after obtaining the fine-tuned model to be trained based on the pre-trained model and the fine-tuning module, the fine-tuned model is trained according to the target training scheme. The target training scheme is a scheme determined based on the configuration information of the fine-tuned model. Since the configuration information is typically used to set relevant parameters and rules for model operation, thus affecting the model's understanding of data and the accuracy of output results, setting the order and number of operators to be executed during the fine-tuned model training process in a targeted manner based on the configuration information of the fine-tuned model can yield a training scheme that better meets the training requirements of the fine-tuned model. Therefore, after training the fine-tuned model according to this training scheme, no manual parameter tuning is required, improving the model fine-tuning efficiency while ensuring the model training requirements are met. Furthermore, the execution scheme of the fine-tuned model can be determined based on the training scheme to reduce communication overhead and improve training efficiency.
[0164] Based on the aforementioned model training method, this application also provides a model training device that can be configured in the host of a model training system. This device can implement some or all of the host's functions through software, hardware, or a combination of both. (Illustratively,) Figure 12 This is a schematic diagram of the structure of a model training device provided in an embodiment of this application. (Reference) Figure 12 The device includes a model determination unit 1201 and a model training unit 1202.
[0165] The model determination unit 1201 is used to determine the fine-tuning model to be trained based on the pre-trained model and the fine-tuning module. The fine-tuning module includes multiple fine-tuning matrices, which are used to update the pre-trained weight matrix of the pre-trained model while keeping it unchanged.
[0166] The model training unit 1202 is used to train the fine-tuned model based on the target training scheme of the fine-tuned model. The target training scheme is determined based on the configuration information of the fine-tuned model and indicates the order and number of operators to be executed during the training of the fine-tuned model.
[0167] In some embodiments, the model training unit 1202 is used for:
[0168] Based on the target training scheme, multiple accelerator cards are controlled to train and fine-tune the model in parallel. The accelerator cards are used to execute communication operators and computation operators in parallel.
[0169] In some embodiments, the model training unit 1202 is used for:
[0170] Based on the target training scheme, the first accelerator card among multiple accelerator cards is controlled to execute the first communication operator and the first computation operator in parallel;
[0171] There is no dependency between the first communication operator and the first computation operator, and both the first communication operator and the first computation operator are located before the second operator. There is a dependency between the second operator and the first communication operator, or there is a dependency between the second operator and the first computation operator.
[0172] In some embodiments, the apparatus further includes a training scheme determination unit, configured to:
[0173] Based on the configuration information, a target training scheme is determined from multiple training schemes. The target training scheme is the training scheme with the lowest performance overhead among multiple training schemes, and the training results of different training schemes are equivalent.
[0174] In some embodiments, different training schemes indicate different orders and numbers of operators to be executed.
[0175] In some embodiments, the training scheme determination unit is used for any of the following:
[0176] Based on the size of the input data indicated by the configuration information, the target training scheme is determined from multiple training schemes; or,
[0177] Based on the model accuracy indicated by the configuration information, the target training scheme is determined from multiple training schemes.
[0178] In some embodiments, the training scheme determination unit is used for any of the following:
[0179] If the input data size indicates that the length of the input data is greater than its width, the first training scheme among multiple training schemes is determined as the target training scheme. The first training scheme indicates that the input data is processed based on the combined result of the pre-trained weight matrix and the fine-tuning module; or,
[0180] If the size of the input data indicates that the length of the input data is less than or equal to the width, the second training scheme among multiple training schemes is determined as the target training scheme. The second training scheme indicates that the input data is processed based on the pre-trained weight matrix and the fine-tuning module, respectively.
[0181] In some embodiments, the training scheme determination unit is configured to:
[0182] Based on the prediction model accuracy corresponding to each training scheme, the training scheme that meets the model accuracy among multiple training schemes is determined as the target training scheme.
[0183] In some embodiments, multiple training schemes include a first training scheme; the first training scheme instructs that after executing a first addition operator, a first multiplication operator be executed, wherein the first addition operator refers to calculating the sum of the pre-trained weight matrix and the execution result of a second multiplication operator, the second multiplication operator refers to calculating the product of multiple fine-tuning matrices, and the first multiplication operator refers to calculating the product of the execution result of the first addition operator and the input data; or,
[0184] Multiple training schemes include a second training scheme, which instructs the execution of a second addition operator after the execution of the third and fourth multiplication operators. The third multiplication operator refers to calculating the product of the input data and the pre-trained weight matrix. The fourth multiplication operator refers to calculating the product of the input data and the execution result of the fifth multiplication operator. The fifth multiplication operator refers to calculating the product of multiple fine-tuning matrices. The second addition operator refers to calculating the sum of the execution results of the third and fourth multiplication operators.
[0185] Using the aforementioned device, after obtaining the fine-tuned model to be trained based on the pre-trained model and the fine-tuning module, the fine-tuned model is trained according to the target training scheme. The target training scheme is a scheme determined based on the configuration information of the fine-tuned model. Since the configuration information is usually used to set relevant parameters and rules for the model's operation, which in turn affects the model's understanding of data and the accuracy of the output results, the order and number of operators to be executed during the fine-tuned model training process can be set in a targeted manner based on the configuration information of the fine-tuned model. This can result in a training scheme that better meets the training requirements of the fine-tuned model. Therefore, after training the fine-tuned model according to this training scheme, no manual parameter tuning is required, which improves the model fine-tuning efficiency while ensuring the model training requirements.
[0186] Of course, the device can also include other functional units to implement the functions involved in the host in the above method embodiments. In practical applications, the above functions can be assigned to different functional units as needed, that is, the internal structure of the device can be divided into different functional units to complete all or part of the functions described above. In addition, the model training device and the model training method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0187] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with substantially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another. For example, without departing from the various examples described, a first operator can be referred to as a second operator, and similarly, a second operator can be referred to as a first operator. Both the first and second operators can be operators, and in some cases, they can be separate and distinct operators.
[0188] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple operators means two or more operators.
[0189] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0190] In the above embodiments, 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 program structure information. This program structure information includes one or more program instructions. When these program instructions are loaded and executed on a computing device, the processes or functions according to the embodiments of this application are generated, in whole or in part.
[0191] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0192] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A model training method, characterized in that, The method includes: Based on the pre-trained model and the fine-tuning module, a fine-tuning model to be trained is determined. The fine-tuning module includes multiple fine-tuning matrices, which are used to update the pre-trained weight matrix of the pre-trained model while keeping it unchanged. The fine-tuning model is trained based on the target training scheme of the fine-tuning model. The target training scheme is determined based on the configuration information of the fine-tuning model and indicates the order and number of operators to be executed during the training of the fine-tuning model.
2. The method according to claim 1, characterized in that, The target training scheme based on the fine-tuned model, training the fine-tuned model, includes: Based on the target training scheme, multiple accelerator cards are controlled to train the fine-tuned model in parallel, wherein the accelerator cards are used to execute communication operators and computation operators in parallel.
3. The method according to claim 2, characterized in that, The step of controlling multiple accelerator cards to train the fine-tuned model in parallel based on the target training scheme includes: Based on the target training scheme, the first accelerator card among the multiple accelerator cards is controlled to execute the first communication operator and the first computation operator in parallel; Wherein, there is no dependency between the first communication operator and the first computation operator, and both the first communication operator and the first computation operator are located before the second operator, and there is a dependency between the second operator and the first communication operator, or there is a dependency between the second operator and the first computation operator.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Based on the configuration information, the target training scheme is determined from multiple training schemes. The target training scheme refers to the training scheme with the lowest performance overhead among the multiple training schemes, and the training results of different training schemes are equivalent.
5. The method according to claim 4, characterized in that, Different training schemes indicate different orders and numbers of operators to be executed.
6. The method according to claim 4 or 5, characterized in that, The step of determining the target training scheme from multiple training schemes based on the configuration information includes any one of the following: Based on the size of the input data indicated by the configuration information, the target training scheme is determined from the plurality of training schemes; or, Based on the model accuracy indicated by the configuration information, the target training scheme is determined from the plurality of training schemes.
7. The method according to claim 6, characterized in that, The determination of the target training scheme from the plurality of training schemes based on the size of the input data indicated by the configuration information includes any one of the following: If the size of the input data indicates that the length of the input data is greater than the width, the first training scheme among the plurality of training schemes is determined as the target training scheme. The first training scheme indicates that the input data is processed based on the merging result of the pre-trained weight matrix and the fine-tuning module. or, If the size of the input data indicates that the length of the input data is less than or equal to the width, the second training scheme among the plurality of training schemes is determined as the target training scheme, and the second training scheme indicates that the input data is processed based on the pre-trained weight matrix and the fine-tuning module respectively.
8. The method according to claim 6, characterized in that, The step of determining the target training scheme from the plurality of training schemes based on the model accuracy indicated by the configuration information includes: Based on the prediction model accuracy corresponding to each training scheme, the training scheme that meets the model accuracy among the multiple training schemes is determined as the target training scheme.
9. The method according to any one of claims 4 to 8, characterized in that, The plurality of training schemes includes a first training scheme, which instructs that after executing a first addition operator, a first multiplication operator be executed. The first addition operator refers to calculating the sum of the pre-trained weight matrix and the execution result of a second multiplication operator, the second multiplication operator refers to calculating the product of the plurality of fine-tuning matrices, and the first multiplication operator refers to calculating the product of the execution result of the first addition operator and the input data; or... The plurality of training schemes includes a second training scheme, which instructs that after executing the third and fourth multiplication operators, a second addition operator be executed. The third multiplication operator refers to calculating the product of the input data and the pre-trained weight matrix. The fourth multiplication operator refers to calculating the product of the input data and the execution result of the fifth multiplication operator. The fifth multiplication operator refers to calculating the product of the plurality of fine-tuning matrices. The second addition operator refers to calculating the sum of the execution results of the third and fourth multiplication operators.
10. A model training device, characterized in that, The device includes: The model determination unit is used to determine the fine-tuning model to be trained based on the pre-trained model and the fine-tuning module. The fine-tuning module includes multiple fine-tuning matrices, which are used to update the pre-trained weight matrix of the pre-trained model while keeping it unchanged. The model training unit is used to train the fine-tuned model based on the target training scheme of the fine-tuned model. The target training scheme is determined based on the configuration information of the fine-tuned model and indicates the order and number of operators to be executed during the training of the fine-tuned model.
11. The apparatus according to claim 10, characterized in that, The model training unit is used for: Based on the target training scheme, multiple accelerator cards are controlled to train the fine-tuned model in parallel, wherein the accelerator cards are used to execute communication operators and computation operators in parallel.
12. The apparatus according to claim 11, characterized in that, The model training unit is used for: Based on the target training scheme, the first accelerator card among the multiple accelerator cards is controlled to execute the first communication operator and the first computation operator in parallel; Wherein, there is no dependency between the first communication operator and the first computation operator, and both the first communication operator and the first computation operator are located before the second operator, and there is a dependency between the second operator and the first communication operator, or there is a dependency between the second operator and the first computation operator.
13. The apparatus according to any one of claims 10 to 12, characterized in that, The device further includes a training scheme determination unit, used for: Based on the configuration information, the target training scheme is determined from multiple training schemes. The target training scheme refers to the training scheme with the lowest performance overhead among the multiple training schemes, and the training results of different training schemes are equivalent.
14. The apparatus according to claim 13, characterized in that, Different training schemes indicate different orders and numbers of operators to be executed.
15. The apparatus according to claim 13 or 14, characterized in that, The training scheme determination unit is used for any of the following: Based on the size of the input data indicated by the configuration information, the target training scheme is determined from the plurality of training schemes; or, Based on the model accuracy indicated by the configuration information, the target training scheme is determined from the plurality of training schemes.
16. The apparatus according to claim 15, characterized in that, The training scheme determination unit is used for any of the following: If the size of the input data indicates that the length of the input data is greater than the width, the first training scheme among the plurality of training schemes is determined as the target training scheme. The first training scheme indicates that the input data is processed based on the merging result of the pre-trained weight matrix and the fine-tuning module. or, If the size of the input data indicates that the length of the input data is less than or equal to the width, the second training scheme among the plurality of training schemes is determined as the target training scheme, and the second training scheme indicates that the input data is processed based on the pre-trained weight matrix and the fine-tuning module respectively.
17. The apparatus according to claim 15, characterized in that, The training scheme determination unit is used for: Based on the prediction model accuracy corresponding to each training scheme, the training scheme that meets the model accuracy among the multiple training schemes is determined as the target training scheme.
18. The apparatus according to any one of claims 13 to 17, characterized in that, The plurality of training schemes includes a first training scheme, which instructs that after executing a first addition operator, a first multiplication operator be executed. The first addition operator refers to calculating the sum of the pre-trained weight matrix and the execution result of a second multiplication operator, the second multiplication operator refers to calculating the product of the plurality of fine-tuning matrices, and the first multiplication operator refers to calculating the product of the execution result of the first addition operator and the input data; or... The plurality of training schemes includes a second training scheme, which instructs that after executing the third and fourth multiplication operators, a second addition operator be executed. The third multiplication operator refers to calculating the product of the input data and the pre-trained weight matrix. The fourth multiplication operator refers to calculating the product of the input data and the execution result of the fifth multiplication operator. The fifth multiplication operator refers to calculating the product of the plurality of fine-tuning matrices. The second addition operator refers to calculating the sum of the execution results of the third and fourth multiplication operators.
19. A model training system, characterized in that, The system includes a host and an accelerator card, the host being used to control the accelerator card, and the host being used to implement the model training method as described in any one of claims 1 to 9.
20. A computing device, characterized in that, The computing device includes a processor and a memory, the processor being configured to execute at least one piece of program code stored in the memory to enable the computing device to implement the model training method as described in any one of claims 1 to 9.
21. A computer program product, characterized in that, When the computer program product is run on a computing device, the computing device enables the model training method as described in any one of claims 1 to 9.
22. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store at least one piece of program code, which is used to implement the model training method as described in any one of claims 1 to 9.