A fault-tolerant computing method, device, equipment, medium and computer program product
By using a fault-tolerant calculation method in the artificial intelligence model, and through block and redundant matrix check value processing, the error problem caused by hardware failure during the artificial intelligence model calculation process is solved, and the accuracy and accuracy of the model calculation are achieved. .
Patent Information
- Application Number
- CN202410683294.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-05-29
AI Technical Summary
During the calculation process of the artificial intelligence model, the area of the computing unit increases due to hardware failure, and the model generation results are incorrect. For example, when the large language model is calculated, the response information is incomplete or far away from the question information.
Using a fault-tolerant calculation method, the weight matrix is divided into multiple data blocks by rows, a redundant matrix is generated, and a general matrix multiplication calculation is performed with the input word vector to generate a check value. If the data calculation result passes the check, it goes to the next step. layer calculation, otherwise error correction processing is performed to ensure the accuracy of model calculation.
The accuracy and precision of the artificial intelligence model calculation results are achieved. Through verification and error correction processing, erroneous results caused by hardware failures are avoided, and the accuracy during model training and inference is improved.
Smart Images

Figure CN118246438B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a fault-tolerant computing method, device, equipment, medium and computer program product. Background Art
[0002] With the development of artificial intelligence (AI) technology, the scale of AI models used is getting larger and larger, which leads to increasingly complex model calculation processes and increasing areas of processing elements (PEs), which increases the failure rate of single hardware and ultimately leads to errors in model generation results. For example, errors in the model calculation process of large language models (LLMs) may result in incomplete and discontinuous response information, or even a far cry from the answer required by the question information, resulting in irrelevant answers.
[0003] How to improve the accuracy of artificial intelligence model calculations is a technical problem that technical personnel in this field need to solve. Summary of the invention
[0004] The purpose of the present invention is to provide a fault-tolerant computing method, device, equipment, medium and computer program product for improving the accuracy of artificial intelligence model calculations.
[0005] In order to solve the above technical problems, the present invention provides a fault-tolerant computing method, which is applied to artificial intelligence question answering, comprising:
[0006] receiving input question information, wherein the question information includes prompt words;
[0007] Convert the prompt word into a word vector, and input the word vector into a target language model for iterative calculation;
[0008] In the propagation calculation of the current iterative calculation of the target language model, after generating a redundant matrix according to the weight matrix of the current layer, general matrix multiplication is performed on the weight matrix, the redundant matrix and the input word vector of the current layer respectively, and the data calculation result of the propagation calculation of the current layer and the first verification value are obtained correspondingly, and a second verification value is generated from the data calculation result, and the data calculation result of the current layer is verified according to the consistency comparison result of the second verification value and the corresponding first verification value. If the data calculation results of the current layer pass the verification, the propagation calculation of the next layer is entered, otherwise, the data calculation results of the current layer are corrected;
[0009] After completing the propagation calculation of each layer of the target language model, obtaining a generation result corresponding to the current iterative calculation and the question information;
[0010] Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0011] On the one hand, the weight matrix is divided into a plurality of data blocks by row, and a plurality of different redundant vectors are generated according to the data blocks, and the redundant vectors are combined into the redundant matrix, including:
[0012] The weight matrix is evenly divided into rows said data blocks;
[0013] Calculate and obtain the column elements of the same column elements in a single data block and obtain the redundancy value of the corresponding column to sequentially obtain the redundancy vector corresponding to the single data block, then calculate the column elements of the same column elements and obtain the redundancy value of the corresponding column of the data blocks without repetition to sequentially obtain the corresponding redundancy vector, and so on until the elements of the same column of all the data blocks and the corresponding redundancy vectors are obtained;
[0014] in, p is the blocking factor and p Is a positive integer.
[0015] On the other hand, the construction process of the redundant matrix includes constructing OK d Redundancy matrix of columns :
[0016] right j =1,2,……, d ,
[0017] when When is an odd number, ,in, =2 k -1, ;
[0018] when When is an even number, ,in, , l satisfy ;
[0019] in, , ;
[0020] The weight matrix includes n OK d List; k is the sequence number of the data block, , No. k The data blocks correspond to the weight matrix Go to kh Row, if the row number of the last row of the last data block n Less than kh Then to the n Behavior stops; h is the number of rows of one of the data blocks; is the number of Line j The elements of the column, is the number of Line j The elements of the column, is the number of Line j The elements of the column, is the weight matrix i Line j The elements of the column, l is the exponential parameter, express Completely divisible , p is the blocking factor, This is a round-up operation.
[0021] On the other hand, general matrix multiplication is performed on the weight matrix, the redundancy matrix, and the input word vector of the current layer respectively, and the data calculation result and the first check value of the propagation calculation of the current layer are obtained correspondingly, including:
[0022] The redundant matrix is concatenated below the weight matrix to obtain a check matrix;
[0023] The check matrix is multiplied by the input word vector to obtain a check vector. n The components are the data calculation results corresponding to each row of the weight matrix, and the back of the check vector The components are the first check values corresponding to each row of the redundant matrix.
[0024] On the other hand, the data calculation results fail to pass the verification, including:
[0025] The second verification value calculated according to the data calculation result is inconsistent with the corresponding first verification value;
[0026] The second check value is inconsistent with the corresponding first check value, which is expressed by the following formula:
[0027] , , m satisfy ;
[0028] in, is the first Quantity, is the first i Quantity, h is the number of rows of the data block, n is the number of rows of the weight matrix, m is the exponential parameter, express Completely divisible , p is the blocking factor.
[0029] On the other hand, generating the second check value from the data calculation result includes recursively calculating the second check value corresponding to the data block using the following formula:
[0030] when When is an odd number, ,in, =2 k -1, ;
[0031] when When is an even number, ,in, , l satisfy ;
[0032] in, is the first the second check value obtained by calculating the data calculation result corresponding to the first check value, is the first the second check value obtained by calculating the data calculation result corresponding to the first check value, is the first the second check value obtained by calculating the data calculation result corresponding to the first check value, h is the number of rows of the data block, n is the number of rows of the weight matrix, l is the exponential parameter, express Completely divisible ,p is the blocking factor.
[0033] On the other hand, generating the second check value from the data calculation result includes:
[0034] The second check values corresponding to the first check values are obtained by parallel calculation according to the redundancy value calculation method.
[0035] On the other hand, verifying the data calculation result of the current layer according to the consistency comparison result between the second verification value and the corresponding first verification value includes:
[0036] If the second check value corresponding to all the data blocks is consistent with the corresponding first check value, it is determined that the first check value corresponding to all the data blocks passes the check, and further it is determined that the data calculation results of the current layer all pass the check;
[0037] If the second check value corresponding to all the data blocks is inconsistent with the corresponding first check value, performing level-by-level check according to the first check value;
[0038] In the step-by-step verification process, if the current first verification value passes the verification, the branch indicator of the first verification value is not verified; if the current first verification value does not pass the verification, and the first verification value has the branch indicator, the branch indicator of the first verification value is verified; if the current first verification value does not pass the verification, and the first verification value does not have the branch indicator, it is determined that the data block corresponding to the first verification value is an erroneous block; wherein, if the current first verification value does not pass the verification but all the branch indicators of the first verification value pass the verification, the current first verification value is set to pass the verification;
[0039] Determine that the data calculation result corresponding to the error block is an error result, and determine that the data calculation result corresponding to the first verification value that passes verification is a correct result;
[0040] The branch index is the first check value in the order The sorting order the first verification value and the first verification value, is the sequence number of the current first check value, l is the exponential parameter, l satisfy , express Completely divisible .
[0041] On the other hand, the blocking factor is determined based on the computing resources of the computing device that performs the propagation calculation of the current layer and the number of rows of the weight matrix, so that the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix is less than or equal to the maximum computing resources provided by the computing device for the propagation calculation of the current layer.
[0042] On the other hand, error correction processing is performed on the data calculation result of the current layer, including:
[0043] When determining that the second check value is inconsistent with the corresponding first check value, the corresponding data block is an error block;
[0044] Generate a recalculation matrix from each of the error blocks;
[0045] Performing a general matrix multiplication calculation on the recalculation matrix and the input word vector of the current layer to obtain a recalculation result;
[0046] The data calculation result of the propagation calculation of the current layer is subjected to error correction processing according to the recalculation result.
[0047] On the other hand, dividing each of the error blocks into the recalculation matrix comprises:
[0048] Copying each of the erroneous blocks into multiple copies and then splicing them together to obtain the recalculated matrix;
[0049] The performing error correction processing on the data calculation result of the propagation calculation of the current layer according to the recalculation result includes:
[0050] The result that appears most frequently in the recalculated results corresponding to the erroneous block is taken as the final calculation result corresponding to the erroneous block, and the data calculation result corresponding to the erroneous block is replaced by the final calculation result.
[0051] On the other hand, each of the erroneous blocks is copied into multiple copies and then spliced to obtain the recalculated matrix, including:
[0052] Get the recalculated redundant modulus;
[0053] The error blocks are copied multiple times according to the recalculated redundant modulus and then spliced into the recalculated matrix, so that the number of each error block in the recalculated matrix is the recalculated redundant modulus.
[0054] On the other hand, before performing a general matrix multiplication calculation on the recalculation matrix and the input word vector of the current layer to obtain a recalculation result, the method further includes:
[0055] Determining whether the number of rows of the recalculation matrix exceeds the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix;
[0056] If yes, return to the step of generating a redundant matrix according to the weight matrix of the current layer;
[0057] If not, the step of performing general matrix multiplication calculation on the recalculated matrix and the input word vector of the current layer is entered.
[0058] On the other hand, it also includes:
[0059] If the number of times the step of generating a redundant matrix according to the weight matrix of the current layer is returned exceeds a recalculation threshold, the iterative calculation of the target language model is stopped and an error message indicating a computing device failure is output.
[0060] On the other hand, the recalculated redundant modulus is obtained by the following formula:
[0061] ;
[0062] in, t for said recalculated redundancy modulus, n is the number of rows of the weight matrix, is the number of rows of the redundant matrix, s is the number of the erroneous blocks, h is the number of rows of the data block, p is the blocking factor, This is a floor operation.
[0063] On the other hand, performing general matrix multiplication calculation on the weight matrix, the redundancy matrix and the input word vector of the current layer respectively to obtain the data calculation result and the first check value of the propagation calculation of the current layer, including:
[0064] A general matrix multiplication calculation of the weight matrix and the input word vector of the current layer and a general matrix multiplication calculation of the redundant matrix and the input word vector of the current layer are performed in parallel.
[0065] In order to solve the above technical problems, the present invention also provides a fault-tolerant computing method, comprising:
[0066] After determining the information of the storage device and the computing device according to the model parallel computing task, reading the to-be-processed data corresponding to the model parallel computing task from the storage device;
[0067] Converting the data to be processed into an input vector, and inputting the input vector into the computing device on which the model parameters of the target model are deployed for iterative calculation;
[0068] In the propagation calculation of the current iterative calculation of the target model, after generating a redundant matrix according to the weight matrix of the current layer, general matrix multiplication is performed on the weight matrix, the redundant matrix and the input vector of the current layer respectively, and the data calculation result of the propagation calculation of the current layer and the first verification value are obtained correspondingly, and a second verification value is generated from the data calculation result, and the data calculation result of the current layer is verified according to the consistency comparison result of the second verification value and the corresponding first verification value. If the data calculation results of the current layer pass the verification, the propagation calculation of the next layer is entered, otherwise the data calculation results of the current layer are error corrected;
[0069] After completing the propagation calculation of each layer of the target model, obtaining the generation result corresponding to the current iterative calculation and the data to be processed;
[0070] Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0071] In order to solve the above technical problems, the present invention further provides a fault-tolerant computing device, which is applied to artificial intelligence question answering, comprising:
[0072] A first receiving unit, configured to receive input question information, wherein the question information includes a prompt word;
[0073] A first conversion unit, used to convert the prompt word into a word vector, and input the word vector into a target language model for iterative calculation;
[0074] A first calculation unit is used for, in the propagation calculation of the current iterative calculation of the target language model, after generating a redundant matrix according to the weight matrix of the current layer, respectively performing general matrix multiplication calculation on the weight matrix, the redundant matrix and the input word vector of the current layer, correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first check value, generating a second check value from the data calculation result, and checking the data calculation result of the current layer according to the consistency comparison result between the second check value and the corresponding first check value, if the data calculation results of the current layer pass the verification, entering the propagation calculation of the next layer, otherwise performing error correction processing on the data calculation result of the current layer; after completing the propagation calculation of each layer of the target language model, obtaining the generation result of the current iterative calculation corresponding to the problem information;
[0075] Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0076] In order to solve the above technical problems, the present invention further provides a fault-tolerant computing device, comprising:
[0077] An information determination unit, configured to determine information of a storage device and information of a computing device according to a model parallel computing task, and then read to-be-processed data corresponding to the model parallel computing task from the storage device;
[0078] A second receiving unit, configured to convert the data to be processed into an input vector, and input the input vector into the computing device on which the model parameters of the target model are deployed for iterative calculation;
[0079] A second calculation unit is used for, in the propagation calculation of the current iterative calculation of the target model, generating a redundant matrix according to the weight matrix of the current layer, and then performing general matrix multiplication calculation on the weight matrix, the redundant matrix and the input vector of the current layer respectively, so as to obtain the data calculation result of the propagation calculation of the current layer and the first verification value accordingly, generating a second verification value from the data calculation result, and verifying the data calculation result of the current layer according to the consistency comparison result between the second verification value and the corresponding first verification value, if the data calculation results of the current layer pass the verification, entering the propagation calculation of the next layer, otherwise performing error correction processing on the data calculation results of the current layer; after completing the propagation calculation of each layer of the target model, obtaining the generation result corresponding to the current iterative calculation and the data to be processed;
[0080] Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0081] In order to solve the above technical problems, the present invention further provides a fault-tolerant computing device, comprising:
[0082] Memory for storing computer programs;
[0083] A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the fault-tolerant computing method as described in any one of the above items are implemented.
[0084] In order to solve the above technical problems, the present invention also provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the fault-tolerant computing method as described in any one of the above items are implemented.
[0085] In order to solve the above technical problems, the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the fault-tolerant computing method as described in any one of the above when executed by a processor.
[0086] The fault-tolerant calculation method provided by the present invention has the beneficial effect of being applied to artificial intelligence question and answer. In the process of converting prompt words in input question information into word vectors and inputting them into a target language model for iterative calculation, when calculating the weight matrix and the input word vector in the propagation calculation, the weight matrix is divided into multiple data blocks by row, and multiple different redundant vectors are generated in a manner of forming corresponding redundant vectors by using column elements of each row in one or more of the data blocks and generating redundant values to form a redundant matrix, and the weight matrix and the redundant matrix are respectively subjected to general matrix multiplication calculation with the input word vector, and corresponding data calculation results and first check values are obtained, and then the data calculation results are generated into a second check value according to the redundant value generation method, and the data calculation results of the current layer are checked according to the consistency comparison result of the second check value and the first check value, and if both pass the check, the propagation calculation of the next layer is entered, otherwise, the data calculation results are corrected; and then after completing the propagation calculation of each layer of the target language model, the generation result corresponding to the current iterative calculation and the question information is obtained, and the fault-tolerant calculation of the target language model is realized, and then the error detection and error correction in the language model training or reasoning process are realized, and the accuracy of the generated language model or the accuracy of the generated answer information when performing the artificial intelligence question and answer task is ensured.
[0087] The present invention also provides a fault-tolerant computing method, which determines the information of the storage device and the computing device according to the model parallel computing task, reads the to-be-processed data corresponding to the model parallel computing task from the storage device, converts the to-be-processed data into an input vector, and inputs the input vector into a computing device deployed with the model parameters of the target model for iterative calculation, and when calculating the weight matrix and the input vector in the propagation calculation, divides the weight matrix into a plurality of data blocks by row, generates a plurality of different redundant vectors in a manner of forming a corresponding redundant vector by using the column elements of each row in one or more of the data blocks and generating redundant values, and performs general matrix multiplication calculations on the weight matrix and the redundant matrix with the input word vector respectively. , corresponding to the data calculation result and the first check value, then the data calculation result is used to generate a second check value according to the redundant value generation method, and the data calculation result of the current layer is checked according to the consistency comparison result between the second check value and the first check value. If both pass the check, the propagation calculation of the next layer is entered, otherwise the data calculation result is corrected; and then after completing the propagation calculation of each layer of the target model, the generation result corresponding to the current iterative calculation and the data to be processed is obtained, and the fault-tolerant calculation of the target model is realized, and then the error detection and correction in the process of model training or model reasoning is realized, which ensures the accuracy of the model generated by using model parallel computing training or the accuracy of the generation result of the model reasoning task performed by using model parallel computing.
[0088] The present invention also provides a fault-tolerant computing device, a fault-tolerant computing apparatus, a fault-tolerant computing equipment, a non-volatile storage medium and a computer program product, which have the above-mentioned beneficial effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0090] Figure 1 A flowchart of a first fault-tolerant computing method provided by an embodiment of the present invention;
[0091] Figure 2 A schematic diagram of the structure of a first fault-tolerant computing device provided by an embodiment of the present invention;
[0092] Figure 3 A schematic diagram of a redundant matrix construction process provided by an embodiment of the present invention;
[0093] Figure 4 A flowchart of a second fault-tolerant computing method provided by an embodiment of the present invention;
[0094] Figure 5 A schematic diagram of another redundant matrix construction process provided by an embodiment of the present invention;
[0095] Figure 6 A schematic diagram of a 5-module majority voting process provided by an embodiment of the present invention;
[0096] Figure 7 A flowchart of a third fault-tolerant computing method provided by an embodiment of the present invention;
[0097] Figure 8 A schematic diagram of the structure of a fault-tolerant computing device provided by an embodiment of the present invention;
[0098] Fig. 9 A schematic diagram of the structure of another fault-tolerant computing device provided by an embodiment of the present invention;
[0099] Fig.10 A schematic diagram of the structure of a fault-tolerant computing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0100] The core of the present invention is to provide a fault-tolerant computing method, device, equipment, medium and computer program product for improving the accuracy of artificial intelligence model calculations.
[0101] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0102] With the rapid rise of large models and the new development of artificial intelligence (AI) technology, the accuracy of model calculations has been required in the process of training AI models and using AI models for reasoning calculations to solve practical problems. With the simultaneous improvement of hardware devices, the current mainstream model calculation device is a computing unit array, which adopts a parallel computing architecture and consists of many computing units (Processing Element, PE). Computing unit arrays such as graphics processing units (GPUs) can perform calculations on computing units in parallel, thereby accelerating model calculations. In order to achieve efficient calculations, a computing unit array uses a large number of computing units to amplify the failure rate of a single computing unit, resulting in the accuracy of model calculation results increasingly unable to meet the needs.
[0103] Model calculation is mainly used in two occasions: model training and model reasoning. Model training is to adjust model parameters according to sample data training to obtain an artificial intelligence model. Model reasoning is to use the trained artificial intelligence model to perform actual tasks, such as using the trained large language model (LLM) to complete artificial intelligence question-answering tasks, such as translation, article generation, summary generation, information search, image generation, image analysis, code generation, etc.
[0104] Model calculation mainly includes two main steps, namely forward propagation calculation and back propagation calculation. In the forward propagation calculation, the output of the previous layer of the model is used as the input of the next layer of the model, and the vector input to the next layer is The input vector of this layer X After calculation of this layer, we get:
[0105] ;
[0106] in, is a general matrix multiplication (GEMM) calculation, It is called the weight matrix, and the function is the nonlinear function of this layer.
[0107] The backpropagation calculation process is more complicated, but still involves general matrix multiplication calculations.
[0108] Therefore, the computing unit array designed to perform model calculation tasks is mainly used to implement general matrix multiplication calculations. Therefore, in order to improve the accuracy of model calculations and thus ensure the accuracy of model training and model reasoning processes, it is necessary to perform error detection and error correction on the calculation results of general matrix multiplication calculations.
[0109] The fault-tolerant computing method provided by the embodiment of the present invention can be applied to a single computing device or to a cluster composed of multiple computing devices. If a cluster is used, each computing device can use the same type of computing device or a heterogeneous computing device. The type of computing device may include but is not limited to a graphics processing unit (GPU), a field programmable gate array device (FPGA), an application specific integrated circuit device (ASIC), and a processor distributed processing unit device (DPU).
[0110] Whether performing model training tasks or model inference tasks, a large amount of storage space is required to store model parameters and data to be processed. This storage space can be provided by a computing device, so the computing device can be a host or a host + accelerator architecture. This storage space can also be provided by another storage device, or by a storage pool composed of multiple storage devices in a cluster.
[0111] Based on the above architecture, the fault-tolerant computing method provided by the embodiment of the present invention is described below in conjunction with the accompanying drawings.
[0112] Figure 1 A flowchart of a first fault-tolerant computing method provided by an embodiment of the present invention; Figure 2 A schematic diagram of the structure of a first fault-tolerant computing device provided by an embodiment of the present invention.
[0113] like Figure 1 As shown, the fault-tolerant computing method provided by the embodiment of the present invention includes:
[0114] S101: After determining the information of the storage device and the computing device according to the model parallel computing task, read the to-be-processed data corresponding to the model parallel computing task from the storage device.
[0115] S102: Convert the data to be processed into an input vector, and input the input vector into a computing device on which model parameters of the target model are deployed for iterative calculation.
[0116] S103: In the propagation calculation of the current iterative calculation of the target model, after generating a redundant matrix according to the weight matrix of the current layer, general matrix multiplication is performed on the weight matrix, the redundant matrix and the input vector of the current layer respectively, and the data calculation result of the propagation calculation of the current layer and the first verification value are obtained accordingly, and a second verification value is generated from the data calculation result. The data calculation result of the current layer is verified according to the consistency comparison result between the second verification value and the corresponding first verification value. If the data calculation results of the current layer pass the verification, the propagation calculation of the next layer is entered, otherwise the data calculation results of the current layer are corrected.
[0117] Among them, generating a redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and composing the redundant vectors into a redundant matrix; a redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0118] S104: After completing the propagation calculations of each layer of the target model, the generation result corresponding to the current iterative calculation and the data to be processed is obtained.
[0119] In the specific implementation, for S101, the model parallel computing task can be in the model training process or in the model reasoning process. In the model training process, the data to be processed obtained is sample data, and the target model is iteratively calculated based on the sample data. In the iterative calculation, forward propagation calculation and back propagation calculation are performed to adjust the model parameters of the target model, and an iterative calculation is completed. After the iteration end condition is reached, the trained target model is obtained. In the model reasoning process, the data to be processed obtained is the data that needs to be calculated. For example, when the target model is a large language model, the data to be processed is question information containing prompt words (prompt); forward propagation calculation is performed in the iterative calculation to output the generated result, and the generated result is output after the iteration end condition is reached. For example, when the target model is a large language model, the output result is response information.
[0120] The architecture of the storage device and the computing device may refer to the description of the above embodiments of the present invention.
[0121] For S102, the input data to be processed is converted into a vector form to obtain an input vector that meets the model calculation requirements of the target model, and the input vector is input into the target model for iterative calculation.
[0122] For S103, when calculating the weight matrix and the input vector in the propagation calculation, the weight matrix is divided into multiple data blocks by row, and multiple different redundant vectors are generated in a manner of forming corresponding redundant vectors by using the column elements of each row in one or more of the data blocks and the generated redundant values to form a redundant matrix, and the weight matrix and the redundant matrix are respectively subjected to general matrix multiplication calculation with the input word vector to obtain the data calculation result and the first check value accordingly, and then the data calculation result is generated into a second check value according to the redundant value generation method, and the data calculation result of the current layer is checked according to the consistency comparison result between the second check value and the first check value, and if both pass the check, the propagation calculation of the next layer is entered, otherwise the data calculation result is corrected; and then after completing the propagation calculation of each layer of the target model, the generation result corresponding to the current iterative calculation and the data to be processed is obtained, and the fault-tolerant calculation of the target model is realized, and then the error detection and error correction in the model training or model reasoning process are realized, and the accuracy of the generated model generated by model parallel computing training or the accuracy of the generated result of the model reasoning task performed by model parallel computing is ensured.
[0123] It can be seen that in the embodiment of the present invention, by dividing the weight matrix into multiple data blocks, each data block corresponds to multiple rows of elements in the weight matrix. Redundant vectors are generated according to the data blocks to obtain a redundant matrix, so there is a corresponding relationship between the redundant vectors and the data blocks. By performing general matrix multiplication calculations on the weight matrix and the redundant matrix with the input vector respectively, the data calculation results and the first check value are obtained correspondingly, then each row of the weight matrix corresponds to a data calculation result, that is, each row of a data block corresponds to a data calculation result, a data block corresponds to multiple data calculation results, and each row of the redundant matrix corresponds to a first check value. According to the corresponding relationship between the data blocks and the redundant vectors, the corresponding relationship between the data calculation results and the first check value can be obtained, and then the corresponding data calculation results can be summed according to the corresponding relationship to obtain the second check value corresponding to the first check value, that is, "the second check value corresponds to the calculation method of the redundant value" in the embodiment of the present invention.
[0124] Without considering the influence of error compensation, if the calculation process of the first check value corresponding to a redundant vector generated according to one or more data blocks is correct, and the data calculation results corresponding to the corresponding one or more data blocks are all calculated correctly, then the consistency comparison result of the second check value and the first check value should be that the second check value is equal to the corresponding first check value. Therefore, in S103, the data calculation result of the current layer is verified according to the consistency comparison result of the second check value and the corresponding first check value, which may include: if the second check value is equal to the corresponding first check value, then it is determined that the first check value passes the verification, and then it is determined that the data block corresponding to the first check value passes the verification, and then it is determined that the data calculation result corresponding to the first check value passes the verification; if the second check value is not equal to the corresponding first check value, then it is determined that the first check value does not pass the verification, and then it is determined that the data block corresponding to the first check value does not pass the verification, and then it is determined that the data calculation result corresponding to the first check value does not pass the verification.
[0125] By using the fault-tolerant calculation method provided by the embodiment of the present invention, erroneous blocks can be found from the data blocks, and verification of part or all of the data calculation results in the general matrix multiplication calculation of the weight matrix can be achieved. That is, it can be understood that if verification of all data calculation results in the general matrix multiplication calculation of the weight matrix is to be achieved, the generated redundant vector should cover all data blocks. For example, a redundant vector can be generated for each data block or every few data blocks.
[0126] Since the minimum unit for verification in the embodiment of the present invention is a data block, when an erroneous block that fails the verification is found, the erroneous block is re-calculated with the input word vector by general matrix multiplication to obtain the correct data calculation result.
[0127] For S104, after error detection and error correction of the general matrix multiplication calculation in the propagation calculation of the target model in S103, the propagation calculation of each layer is sequentially performed. After the propagation calculation of each layer is completed, the generation result corresponding to the current iterative calculation and the problem information is obtained. If the model calculation is in the model training process, after the forward propagation calculation of each layer is completed, and then the reverse propagation calculation of each layer is completed, the generation result corresponding to the current iterative calculation and the problem information is obtained. If the model calculation is in the model reasoning process, after the forward propagation calculation of each layer is completed, the generation result corresponding to the current iterative calculation and the data to be processed is obtained.
[0128] In the fault-tolerant calculation method provided in the embodiment of the present invention, the process of constructing the weight matrix and the process of generating the second check value from the data calculation result are both sum calculations, the process of comparing the second check value with the first check value is a comparison calculation, and the process of performing general matrix multiplication calculations on the weight matrix, the redundant matrix and the input vector of the current layer is a general matrix multiplication calculation process. Figure 2 As shown, the computing device used in the embodiment of the present invention may include an adder 201, a comparator 202 and a general matrix multiplication calculator 203, wherein the adder 201 is used to sum the column elements of the data block to obtain a redundancy value and to sum the data calculation results according to the redundancy value generation method to obtain a second check value; the comparator 202 is used to compare whether the second check value is equal to the first check value; the general matrix multiplication calculator 203 is used to perform general matrix multiplication calculations on the weight matrix, the redundancy matrix and the input vector of the current layer respectively. It should be noted that Figure 2 The fault-tolerant computing device shown only implements the functions of the hardware of the computing device according to the computing types required by the fault-tolerant computing method provided by the embodiment of the present invention, and does not mean that the fault-tolerant computing device only includes these computing modules.
[0129] Figure 3 A schematic diagram of a redundant matrix construction process provided by an embodiment of the present invention; Figure 4 A flowchart of a second fault-tolerant computing method provided by an embodiment of the present invention.
[0130] Based on the above embodiment, the embodiment of the present invention further illustrates the fault-tolerant calculation method.
[0131] In the embodiment of the present invention, in S103, the weight matrix is divided into a plurality of data blocks by row, and a plurality of different redundant vectors are generated according to the data blocks, and each redundant vector is formed into a redundant matrix, which may include:
[0132] Divide the weight matrix evenly into rows Data blocks;
[0133] Calculate the column elements of the same column elements in a single data block and obtain the redundancy value of the corresponding column to obtain the redundancy vector corresponding to the single data block in sequence, then calculate the column elements of the same column elements and obtain the redundancy value of the corresponding column of the data blocks in groups of two without repetition to obtain the corresponding redundancy vector in sequence, and so on until the elements of the same column of all data blocks and the corresponding redundancy vectors are obtained;
[0134] The redundant vectors are concatenated up and down to obtain a redundant matrix;
[0135] in, p is the blocking factor and p Is a positive integer.
[0136] In this embodiment of the present invention, the input vector of the current layer can be recorded as X , the weight matrix of the current layer is recorded as , that is, the weight matrix is a n OK d A matrix of columns, Represents the weight matrix Middle i Line j The elements of the column, i =1,2,……, n ; j =1,2,……, d .
[0137] Get the blocking factor p ,Require p is an integer and satisfies In the embodiment of the present invention, the blocking factor p It can be dynamically input according to the demand, can be set by the staff, or can be calculated by a set function. In some optional implementations of the embodiments of the present invention, the block factor can be determined based on the computing resources of the computing device that performs the propagation calculation of the current layer and the number of rows of the weight matrix, so that the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix is less than or equal to the maximum computing resource provided by the computing device for the propagation calculation of the current layer. In some optional implementations of the embodiments of the present invention, p You can choose , This is a floor operation.
[0138] According to the block factor p , the weight matrix Divide evenly into rows data blocks, and the number of rows in a data block is recorded as the height of the data block. , then the weight matrix Middle k The weight matrix corresponding to each data block No. Go to kh OK, remember k is the sequence number of the data block, k =1,2,……, .
[0139] It should be noted that, in the embodiment of the present invention, “evenly partitioning” does not mean that the number of rows in all data partitions is the same. For example, the number of rows in the last data partition may be less than the number of rows in other data partitions. kh > n It is not counted, that is, the last data block is n The behavior stops.
[0140] Build OK d Column Redundancy Matrix , Represents the redundant matrix Middle Line j The elements of the column, =1,2,……, ; j =1,2,……, d .
[0141] In some optional implementations of the embodiments of the present invention, the construction process of the redundant matrix includes constructing OK d Redundancy matrix of columns :
[0142] right j =1,2,……, d ,
[0143] when When is an odd number, ,in, =2 k -1, ; (1)
[0144] when When is an even number, ,in, , l satisfy ; (2)
[0145] in, , ;
[0146] The weight matrix includes n OK d List; k is the sequence number of the data block, , No. k The data block corresponds to the weight matrix Go to kh Row, if the row number of the last row of the last data block n Less than kh Then to the n Behavior stops; h The number of rows for a data block; is the redundant matrix Line j The elements of the column, is the redundant matrix Line j The elements of the column, is the redundant matrix Line j The elements of the column, is the weight matrix i Line j The elements of the column, l is the exponential parameter, express Completely divisible , p is the blocking factor, This is a round-up operation.
[0147] in express Completely divisible ,Right now but .
[0148] According to the above recursive relationship, we can first calculate the redundant vector corresponding to a single data block, that is, we can obtain the redundant matrix Bank of China serial number The redundant value of the redundant vector is an odd number, and then the redundant vectors corresponding to the two data blocks are calculated, that is, the redundant matrices are obtained respectively. Bank of China serial number The redundant vector is an even number but not a multiple of 4, and so on. Finally, the redundant vectors corresponding to all data blocks are calculated, that is, in the redundant matrix Bank of China serial number for Through the calculation of the above recursive relationship, the redundant vectors of each row can be obtained in turn to form a redundant matrix .
[0149] Alternatively, each row of redundant vectors can be calculated in parallel based on the computing unit array, and equations (1) and (2) can be expressed as:
[0150] , ,m satisfy . (3)
[0151] in, m is the exponential parameter, express Completely divisible ,Right now but .
[0152] In the weight matrix On the basis of Substitute into equation (3) to calculate and get the entire redundant matrix .
[0153] In some optional implementations of the embodiments of the present invention, in S103, respectively performing general matrix multiplication calculations on the weight matrix, the redundancy matrix, and the input word vector of the current layer, and correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first check value, may include:
[0154] Concatenate the redundant matrix under the weight matrix to obtain the check matrix;
[0155] Perform a general matrix multiplication on the check matrix and the input word vector to obtain the check vector. n The components are the data calculation results corresponding to each row of the weight matrix, and the back of the check vector The components are the first check values corresponding to each row of the redundant matrix.
[0156] The redundant matrix and the weight matrix Splice up and down, for example, the redundant matrix Concatenated in weight matrix Below, the check matrix is constructed , then the check matrix is a OK d The matrix of columns, its first ~ n Rows correspond to weight matrices The row vector of n +1~ Rows correspond to redundant matrices The row vector of . Check matrix The scale is the weight matrix of times.
[0157] Figure 3 is a blocking factor p =2 example, such as Figure 3 As shown, the weight matrix can be Divided into =4 data blocks, according to It can be seen that the redundant matrix constructed = Includes 7 redundant vectors.
[0158] If equations (1) and (2) are used and the redundant vectors are calculated according to the recursive relationship, the redundant vector corresponding to a single data block can be calculated according to equation (1). The redundant vector corresponding to the first data block is V1, the redundant vector corresponding to the second data block is V3, the redundant vector corresponding to the third data block is V5, and the redundant vector corresponding to the fourth data block is V7. The serial number indicates the redundant vector in the redundant matrix The number of rows in .
[0159] The redundant vectors V2, V4, and V6 corresponding to two or more data blocks can be calculated based on the redundant vector corresponding to a single data block and equation (2). For example, V2=V1+V3 represents the redundant vectors corresponding to the first data block and the second data block, and V2 can be directly calculated based on V1 and V3 calculated above; V6=V5+V7 represents the redundant vectors corresponding to the third data block and the fourth data block, and V6 can be directly calculated based on V5 and V7 calculated above; V4=V2+V6, and V4 can be directly calculated based on V2 and V6 calculated above.
[0160] It can be seen that after three rounds of calculation, the redundant vectors corresponding to one data block, two data blocks, and four data blocks are obtained respectively, and each redundant vector is constructed into a redundant matrix with 7 rows. , and then the check matrix is obtained as .
[0161] Alternatively, the redundant vectors of each row can be calculated in parallel based on the computing unit array according to equation (3), that is, Substituting into equation (3), after obtaining each redundant vector in parallel, each redundant vector is constructed into a redundant matrix with 7 rows , and then the check matrix is obtained as .
[0162] After constructing the check matrix Then, get the input vector , and use the check matrix Instead of the weight matrix , the input vector Sum check matrix Input the calculation unit array and calculate the check vector in the calculation unit array As a result, we get:
[0163] ; (4)
[0164] Among them, the superscript T Represents the transpose of a vector.
[0165] It can be seen that the check vector Y Before n The components are respectively The data calculation results corresponding to each row, the check vector Y After The components are respectively The first check value corresponding to each row.
[0166] Check Vector Y In n The calculation results of the data also correspond to data blocks, and the k Data blocks ( k =1,2,……, ) corresponds to the check vector Y Middle To kh Components, that is , and the first The calculation result of the data blocks is the check vector Y Middle To n Components, that is . Note the check vector Y Middle To kh The calculation result of this set of data is k The data calculation results corresponding to each data block.
[0167] As you can see, the blocking factor p The size of the check vector Y The computational efficiency of the check matrix The scale is the weight matrix of times, so to complete the same scale of target computing tasks, the required hardware scale is also required to be Conversely, under the same hardware scale conditions, the efficiency of the general matrix multiplication calculation of the current layer is The appropriate value of the block factor can be selected according to the hardware resources of the computing unit array and the time requirement of the iterative calculation.
[0168] The redundant matrix provided by the embodiment of the present invention The definition of , the component values of the check vector should satisfy the relationship:
[0169] , , m satisfy ; (5)
[0170] in, m is the exponential parameter, express Completely divisible ,Right now but .
[0171] The sum value on the right side of equation (5) may be calculated first, that is, the sum value of the data calculation results of all data blocks corresponding to a first check value, that is, the number of sum values is equal to the number of first check values.
[0172] In the process of calculating the sum of the right side of equation (5), the same calculation method as equations (1) and (2) can be used, that is, respectively calculating For odd numbers and The value when is an even number. Then, in S103, the data calculation result is used to generate a second check value, which may include recursively calculating the second check value corresponding to the data block using the following formula:
[0173] when When is an odd number, ,in, =2 k -1, ; (6)
[0174] when When is an even number, ,in, , l satisfy ; (7)
[0175] in, express Completely divisible ,Right now but .
[0176] in, is the first A second check value is calculated by calculating the data calculation result corresponding to the first check value, is the first A second check value is calculated by calculating the data calculation result corresponding to the first check value, is the first A second check value is calculated by calculating the data calculation result corresponding to the first check value, h is the number of rows in a data block, n is the number of rows in the weight matrix,l is the exponential parameter, express Completely divisible , p is the blocking factor.
[0177] That is, according to the recursive relationship, we can first calculate The sum of the data calculation results corresponding to the first check value of an odd number, and then calculate The sum of the data calculation results corresponding to the first check value that is an even number but not a multiple of 4, and so on, and finally calculate for The sum of the data calculation results corresponding to the first check value, that is, the sum of the data calculation results corresponding to all data blocks.
[0178] Alternatively, generating the second check value from the data calculation result in S103 may also include: obtaining the second check value corresponding to each first check value by parallel calculation according to the redundant value calculation method. Substituting into equation (5) for calculation, since the calculation instructions involved are the same as those of equation (3), the same calculation instructions can be used on the same hardware structure to complete the calculation.
[0179] According to equation (5), the left side of the equal sign is In the check vector Y After determining the first check values, the check vector is summed up according to the right side of equation (5). Y forward n The data calculation results are used to calculate the second check value corresponding to the first check value, and the corresponding first check value and second check value are compared. If they are consistent, the group of check values passes the check; if they are inconsistent, the group of check values fails the check, and the next step of check and error correction is performed.
[0180] Without considering error compensation (i.e., two or more calculation errors cancel each other out so that the verification relationship still holds), if soft errors such as bit flipping occur during the calculation of the data calculation results, some data calculation results will change, and the equation relationship between the corresponding first check value and the corresponding second check value will no longer hold.
[0181] In the embodiment of the present invention, the data calculation result in S103 failing to pass the verification may include: a second verification value calculated according to the data calculation result is inconsistent with the corresponding first verification value.
[0182] The second check value is inconsistent with the corresponding first check value, which can be expressed by the following formula:
[0183] , , m satisfy ; (6)
[0184] in, is the first Quantity, is the first i Quantity, h is the number of rows in a data block, n is the number of rows in the weight matrix, m is the exponential parameter, express Completely divisible ,Right now but , p is the blocking factor.
[0185] Based on this, an embodiment of the present invention provides a verification process of a data calculation result of a general matrix multiplication calculation, and in S103, the data calculation result of the current layer is verified according to the consistency comparison result between the second verification value and the corresponding first verification value, which may include:
[0186] If the second check values corresponding to all data blocks are consistent with the corresponding first check values, it is determined that the first check values corresponding to all data blocks pass the check, and further it is determined that the data calculation results of the current layer all pass the check;
[0187] If the second check values corresponding to all data blocks are inconsistent with the corresponding first check values, a check is performed step by step according to the first check values;
[0188] In the step-by-step verification process, if the current first verification value passes the verification, the branch indicator of the first verification value is not verified; if the current first verification value does not pass the verification, and the first verification value has a branch indicator, the branch indicator of the first verification value is verified; if the current first verification value does not pass the verification, and the first verification value does not have a branch indicator, it is determined that the data block corresponding to the first verification value is an erroneous block; wherein, if the current first verification value does not pass the verification but all branch indicators of the first verification value pass the verification, the current first verification value is set to pass the verification;
[0189] Determine that a data calculation result corresponding to an erroneous block is an erroneous result, and determine that a data calculation result corresponding to a first verification value that passes verification is a correct result;
[0190] Among them, the branch index is the first check value in the sort order The sorting order The first check value and the first check value, is the sequence number of the current first check value, l is the exponential parameter,l satisfy , express Completely divisible .
[0191] In the embodiment of the present invention, in order to verify whether all data calculation results are correct, the verification can be performed according to the following process:
[0192] 1) Perform initialization settings and record the error block number set S =Φ, exponential parameter l = p , initial indicator ;
[0193] 2) Verify whether the second check value is related to the corresponding first check value ; If true, no additional operation is performed; if not true, when the index parameter l =0, update the number set ; When the index parameter l >0, let , respectively and (These two indicators are called branch indicator) and repeat step 2);
[0194] 3) Output the error block number set after the update is completed S , then for any ,like , then k There are errors in the calculation results of the data in the data blocks; ,like , then k The data calculation results in each data block are all correct results.
[0195] Without considering the influence of error compensation, when an error occurs in the calculation of a data calculation result, the check of the first check value corresponding to the error block containing the error result will always fail. Therefore, the above-mentioned check process can always detect the error block number where the error result is located.
[0196] However, when the first check value corresponding to two or more data blocks fails to pass the check, but the data calculation results corresponding to all data blocks corresponding to the first check value are correct, although the first check value fails to pass the check, the branch indicator of the first check value (i.e., step 3) and ) have passed the verification. At this time, in the verification vector Y After The corresponding serial number in the component The failure of the even-numbered first check value to pass the check will not affect the check process of the data calculation result, that is, as stated above, "if the current first check value fails the check but all branch indicators of the first check value pass the check, the current first check value is set to pass the check."
[0197] However, if the first check value corresponding to a single data block fails to pass the check, that is, in the check vector Y After The corresponding serial number in the component The first check value that is an odd number fails the check. Since there is no branch indicator for the odd number indicator, the failure to pass the check will directly mark the corresponding data block as an erroneous block.
[0198] In the above verification process, if the first verification If it is established, the verification process ends directly, and no other first verification values are verified. S There is still no empty set, which means that all data calculation results are correct. S If it is not an empty set, it means that an erroneous calculation result is found during the verification process, and the erroneous calculation result can be located in a specific data block and recorded as the erroneous block, and the remaining data blocks are recorded as correct blocks. Then continue to perform secondary calculations on the erroneous blocks until the correct calculation result is obtained, thus achieving error correction.
[0199] Through the above verification process provided by the embodiment of the present invention, it is not necessary to use all the first verification values for verification at one time, but to use the verification vectors Y After The first Starting from the first check value, the branch indicators, the branch indicators of the branch indicators, etc. are checked in turn. If all the first check values of a certain layer pass the check, there is no need to check its branch indicators again, thereby reducing the check and comparison process.
[0200] The erroneous blocks detected in the above steps can be repeatedly calculated and then the correct result can be obtained by voting. The process may include:
[0201] According to the error block set S , the number of error blocks is ,remember g is the sequence number of the error block. The sequence number of the error block is divided according to the order of the error block from small to large in the data block. , Indicates the first g The data block sequence number corresponding to the error block, .
[0202] On the basis of the above embodiment, in the embodiment of the present invention, the error correction processing of the data calculation result of the current layer in S103 may include:
[0203] When determining that the second check value is inconsistent with the corresponding first check value, the corresponding data block is an erroneous block;
[0204] Divide each error block into a recalculation matrix;
[0205] Perform a general matrix multiplication on the recalculation matrix and the input word vector of the current layer to obtain the recalculation result;
[0206] The data calculation results of the propagation calculation of the current layer are corrected according to the recalculation results.
[0207] In some optional implementations of the embodiments of the present invention, generating a recalculation matrix from each error block may include:
[0208] Each error block is copied into multiple copies and then spliced to obtain a recalculated matrix;
[0209] According to the recalculation results, error correction is performed on the data calculation results of the propagation calculation of the current layer, including:
[0210] The result that appears most frequently in the recalculated results corresponding to the erroneous block is taken as the final calculation result corresponding to the erroneous block, and the final calculation result is used to replace the data calculation result corresponding to the erroneous block.
[0211] The process of copying each error block into multiple copies and then splicing them together to obtain a recalculated matrix may include:
[0212] Get the recalculated redundant modulus;
[0213] According to the recalculated redundant modulus, the error block is copied multiple times and then spliced into a recalculated matrix, so that the number of each error block in the recalculated matrix is the recalculated redundant modulus.
[0214] The recalculation redundancy modulus can be defined as ,in, t To recalculate the redundant modulus, n is the number of rows in the weight matrix, is the number of rows of the redundant matrix, s is the number of error blocks, h is the number of rows in a data block, p is the blocking factor, This is a floor operation.
[0215] This allows full use of the check matrix Hardware resources for general matrix multiplication calculations.
[0216] The data calculation result corresponding to the error block is the check vector Y Before n The calculation results of the data of the components The corresponding error block in the weight matrix The component of the sequence number of the data block in, that is, ( , , ) may include erroneous calculation results, while the rest of the data calculation results are correct.
[0217] Note the weight matrix Divide into A data block can be expressed as:
[0218] ; (7)
[0219] in, Indicates the first data block, Indicates the second data block, Indicates Data blocks.
[0220] Then construct the recalculation matrix F It can be expressed as:
[0221] ; (8)
[0222] in, Indicates the first error block, Indicates the second error block, Indicates There are erroneous blocks. It can be seen that when recalculating the matrix F In , each error block is copied as t , and in the equation Under the constraint of F The size will not exceed the check matrix .
[0223] After constructing the matrix, recalculate F Then, the input vector and recalculate the matrix F The input computational cell array performs a general matrix multiplication to obtain a recomputed vector:
[0224] . (9)
[0225] Therefore, each error block h The wrong calculation results were t It can be observed that as the range of possible values of the data calculation results increases, when the matrix is recalculatedF Each error block is performed t When the calculation is repeated, even if multiple incorrect calculation results appear again, the possibility of two equal incorrect calculation results will be reduced, and the correct calculation results will always be the same. t The recalculation results corresponding to the repeated calculations are found, and the recalculation result with the largest number of occurrences is used as the final calculation result corresponding to the error block. This process is called t Modular voting. By selecting a suitable and large block factor p ,make t ≥3, then recalculate the vector Able to pass t The correct calculation result of each erroneous block is obtained by modular voting. The final calculation result corresponding to the erroneous block is used to replace the data calculation result corresponding to the erroneous block, and is retained in the check matrix. The correct result of the data calculation result obtained by performing the general matrix multiplication calculation remains unchanged, thereby obtaining the final correct target vector of the general matrix multiplication of the current layer.
[0226] If the same hardware resources are used to recalculate the matrix F General matrix multiplication calculation and check matrix The recalculation of the general matrix multiplication calculation does not incur additional hardware overhead, but the time spent on the general matrix multiplication calculation of the current layer will be twice as long as the original calculation time. However, this realizes the error detection and correction of the target vector obtained by the general matrix multiplication calculation, ensures the correctness of the result of the target vector, and thus realizes the fault-tolerant calculation of the general matrix multiplication on the computing unit array.
[0227] exist Figure 2 As shown in the fault-tolerant computing device based on Figure 4 As shown, the fault-tolerant computing method provided by the embodiment of the present invention may include:
[0228] S401: construct a check matrix;
[0229] S402: Calculate a check vector;
[0230] S403: Calculate a second check value;
[0231] S404: Verify data block correctness;
[0232] S405: Recalculate the erroneous blocks.
[0233] Figure 4In the figure, the circular box diagram represents the input or output value, the square box diagram represents the process steps, the diamond box diagram represents the judgment branch, and the dotted box indicates that S402 and S405 are performed on the same hardware structure, that is, the general matrix multiplication operation is performed on the same general matrix multiplication calculator, and there is a possibility that the result of this calculation is erroneous.
[0234] For the specific implementation of the embodiments of the present invention, please refer to the description of the above embodiments.
[0235] In some other optional implementations of the embodiments of the present invention, before performing a general matrix multiplication calculation on the recalculation matrix and the input word vector of the current layer to obtain the recalculation result, the fault-tolerant calculation method provided by the embodiments of the present invention may further include:
[0236] Determine whether the number of rows of the recalculated matrix exceeds the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix;
[0237] If yes, return to the step of generating the redundant matrix according to the weight matrix of the current layer;
[0238] If not, it proceeds to the step of performing general matrix multiplication of the recomputed matrix with the input word vector of the current layer.
[0239] That is, in order not to exceed the original hardware resources, if the recalculated matrix size exceeds the check matrix size, the current layer propagation calculation is re-performed instead of recalculating the error blocks.
[0240] In some other optional implementations of the embodiments of the present invention, the fault-tolerant computing method may further include:
[0241] If the number of steps of generating a redundant matrix based on the weight matrix of the current layer exceeds the recalculation threshold, the iterative calculation of the target language model is stopped and an error message indicating a computing device failure is output.
[0242] That is to say, if the propagation calculation of the current layer is repeated multiple times, the model iteration calculation will be stopped and an error will be reported, because the calculation error at this time may be caused by a failure of the computing device.
[0243] In some other optional implementations of the embodiments of the present invention, in S103, respectively performing general matrix multiplication calculations on the weight matrix, the redundancy matrix, and the input word vector of the current layer, and correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first check value, may also include:
[0244] The general matrix multiplication computation of the weight matrix with the input word vector of the current layer and the general matrix multiplication computation of the redundancy matrix with the input word vector of the current layer are performed in parallel.
[0245] If hardware computing resources allow, the general matrix multiplication calculation of the weight matrix and the input word vector of the current layer and the general matrix multiplication calculation of the redundant matrix and the input word vector of the current layer can be performed in parallel to improve computing efficiency. For example, a general matrix multiplication calculator for performing the general matrix multiplication calculation of the weight matrix and the input word vector of the current layer and the general matrix multiplication calculation of the redundant matrix and the input word vector of the current layer can be deployed locally on the computing device in advance, or one of the computing tasks can be sent to another computing device for general matrix multiplication calculation.
[0246] Figure 5 A schematic diagram of another redundant matrix construction process provided by an embodiment of the present invention; Figure 6 A schematic diagram of a 5-module majority voting process provided by an embodiment of the present invention.
[0247] Below is a 32×32 weight matrix With a 32×1 input vector Taking matrix multiplication as an example, the fault-tolerant calculation method of general matrix multiplication provided by an embodiment of the present invention is introduced.
[0248] like Figure 5 As shown, according to the weight matrix The scale can be selected by the blocking factor p =3, thus the weight matrix Divided into Block, recorded as data block , the matrix size of each data block is 4×32. Then the data block and weight matrix The relationship is:
[0249] .
[0250] Among them, the height of each data block h is 4.
[0251] according to The number of rows in the redundant matrix can be determined =15, then according to equations (1) and (2), for any , build The redundant matrix , the redundant matrix Elements Defined as:
[0252] ,in, ; (10)
[0253] ,in, ; (11)
[0254] ,in, ; (12)
[0255] ,in, . (13)
[0256] right , all redundant values can be obtained by recursively calculating according to the above process , or all redundant values corresponding to each column in the calculation cell array Perform parallel computing.
[0257] Weight Matrix Data chunking and the redundancy matrix = The corresponding relationship can be used Figure 5 express.
[0258] The redundant matrix Concatenated in weight matrix Below, we get a check matrix of size 47×32 .
[0259] The input vector Sum check matrix Input the calculation unit array and calculate the check vector :
[0260] ; (14)
[0261] Among them, the superscript T Represents the transpose of a vector.
[0262] Therefore, the check vector The first 32 components of are the weight matrix The corresponding 32 data calculation results, check vector The last 15 components of are redundant matrices The corresponding 15 first check values.
[0263] The 32 data calculation results also correspond to 8 data blocks, among which Data blocks correspond to check vectors Middle To Components, that is , and the calculation results of this set of data are called k The data calculation results of each data block.
[0264] In order to detect the correctness of the data calculation result, the data calculation result can be calculated according to equation (5) to obtain 15 second check values, and the consistency comparison result between the second check values and the first check values is used to detect whether the data calculation result is wrong.
[0265] According to equations (10) to (13), the second check value is calculated ( ) process is as follows:
[0266] ,in, ; (15)
[0267] ,in, ; (16)
[0268] ,in, ; (17)
[0269] ,in, . (18)
[0270] According to the recursive relationship of the second check value, the second check value of all odd subscripts can be calculated first, and then the second check value of all even subscripts that are not multiples of 4 can be calculated, and so on, and finally the second check value of the subscript 8 can be calculated. .
[0271] Alternatively, it is also possible to parallelize the Substituting into equation (5) for calculation, since the calculation instructions involved are the same as those of equation (3), the same calculation instructions can be used on the same hardware structure to complete the calculation.
[0272] After the calculation of the second check value is completed, the corresponding data calculation result is determined to be correct by checking whether the second check value and the corresponding first check value satisfy the equality relationship. As an example, suppose that when calculating the check vector In the process of data calculation, the results and the first check value If the calculation of is wrong, the verification process is as follows:
[0273] 1) Perform initialization settings and record the error block number set S =Φ, exponential parameter l =3, initial index .
[0274] 2) Verify whether the second check value is related to the corresponding first check value. First check = Is it true? Due to the data calculation results Is an error result, then = The failure to pass the verification is due to l >0, so continue to check its branch index;
[0275] make l =2, =4, check Is it true? Due to the data calculation results is an incorrect calculation result. The failure to pass the verification is due to l >0, so continue to check its branch index;
[0276] make l =1, =2, check Is it true? Due to the data calculation results is an incorrect calculation result. The failure to pass the verification is due to l >0, so continue to check its branch index;
[0277] make l =0, =1, check Is it true? Due to the data calculation results is an incorrect calculation result. The failure to pass the verification is due to l =0, so update the error block number set S for , indicating that the first data block is an error block;
[0278] make l =0, =3, check Is it true? Since there is no error result in the data calculation result corresponding to the third second check value, Pass verification;
[0279] make l =1, =6, check Is it true? Since there is no error result in the data calculation result corresponding to the 6th second check value, but the first check value If the calculation is wrong, Failed verification due to l >0, so continue to check its branch index;
[0280] make l =0, =5, check Is it true? Since there is no error result in the data calculation result corresponding to the 5th second check value, Pass verification;
[0281] make l =0, =7, check Is it true? Since there is no error result in the data calculation result corresponding to the 7th second check value, Pass verification;
[0282] make l =2, =12, check Is it true? Due to the data calculation results is an incorrect calculation result. Failed verification due to l >0, so continue to check its branch index;
[0283] make l =1, =10, check Is it true? Since there is no error result in the data calculation result corresponding to the 10th second check value, Pass verification;
[0284] make l =1, =14, check Is it true? Due to the data calculation results is an incorrect calculation result. Failed verification due to l >0, so continue to check its branch index;
[0285] make l =0, =13, check Is it true? Since there is no error result in the data calculation result corresponding to the 13th second check value, Passed verification.
[0286] make l =0, =15, check Is it true? Due to the data calculation results is an incorrect calculation result. Failed verification due to l =0, so update the error block number set S for , indicating that the first data block and the eighth data block are error blocks.
[0287] 3) Output the error block number set after the update is completed .
[0288] It can be seen that in the above application example, the serial numbers of all error blocks are found during the verification process, and the calculation error of the first verification value does not affect the verification result. It can be seen that the data calculation results corresponding to the second data block to the seventh data block are correct, while there are errors in the data calculation results corresponding to the first data block and the eighth data block.
[0289] Then the detected error blocks are recalculated to achieve error correction. , divide the corresponding data into blocks Each copy is made into 5 copies and concatenated, and the recalculation matrix is defined as follows:
[0290] ; (19)
[0291] Recalculate the matrix The size of the check matrix is slightly smaller than In the calculation · Recalculate the matrix on the computational cell array The general matrix multiplication of , gives the recalculated vector:
[0292] ; (20)
[0293] Recalculate vector is a 40×1 column vector, where each of the 4 components belongs to a group of error blocks, and the first 5 blocks are The recalculation result of the last 5 blocks is The recalculated result of . Therefore, the recalculated vector The value of can be regarded as and 5 modular redundancy. Calculate the recalculation vector The process and calculation of the check vector The process is similar to that of Figure 6 The process shown is obtained by voting and The correct result is taken as the final calculation result. Figure 6 The unshaded blocks in the figure represent multiple identical recalculation results, which are the correct results obtained by voting, i.e., the final calculation results. The other blocks with different shades represent different recalculation results, which are incorrect results.
[0294] Figure 6In the 5-module majority voting system, when 3 or more of the 5 inputs are the same, Figure 6 3 / 5 (G) shown, takes the same value as output. It should be noted that each block of the recalculated vector contains 4 components, corresponding to the 4 components of the block information value, and 5-module redundancy can vote on each component separately.
[0295] For example, in When voting on the first component of The 1st, 5th, 9th, 13th, and 17th components of Figure 6 In the process, the calculation result of the fifth component is wrong, and the calculation results of the other four are correct. Therefore, there are 4 identical inputs in the 5-module redundancy, and the correct result can be output. Similarly, for When voting on the second component of The 2nd, 6th, 10th, 14th, and 18th components are Figure 6 In the process, the calculation result of the second component is wrong, and the calculation results of the other four are correct. Therefore, 4 of the 5 modular redundancies have the same input and can output the correct result. The corresponding recalculated vector In the first 5 blocks of , there are 2 blocks with calculation errors, but only one corresponding bit of each component is wrong. Among the corresponding five recalculation blocks, errors occurred in two blocks, and the error positions corresponded to the same component. Therefore, during the voting process of this component, two of the five inputs were wrong, and the remaining three identical inputs did not have errors. The same value was taken as the final value of this component.
[0296] Keep the check vector The calculation results of the data from the 2nd block to the 7th block in the same way remain unchanged, and the recalculation vector The final calculation results of the 1st block and the 8th block obtained by voting are obtained, so we get The correct calculation result of is obtained, thus realizing the fault-tolerant calculation of general matrix multiplication.
[0297] The following describes a fault-tolerant computing method for artificial intelligence question answering provided by an embodiment of the present invention in conjunction with the accompanying drawings.
[0298] Figure 7 A flowchart of a third fault-tolerant computing method provided by an embodiment of the present invention.
[0299] like Figure 7 As shown, the third fault-tolerant computing method provided by the embodiment of the present invention for artificial intelligence question answering includes:
[0300] S701: receiving input question information, where the question information includes prompt words.
[0301] S702: Convert the prompt word into a word vector, and input the word vector into the target language model for iterative calculation.
[0302] S703: In the propagation calculation of the current iterative calculation of the target language model, after generating a redundant matrix according to the weight matrix of the current layer, general matrix multiplication is performed on the weight matrix, the redundant matrix and the input word vector of the current layer respectively, and the data calculation result of the propagation calculation of the current layer and the first verification value are obtained accordingly, and a second verification value is generated from the data calculation result. The data calculation result of the current layer is verified according to the consistency comparison result between the second verification value and the corresponding first verification value. If the data calculation results of the current layer pass the verification, the propagation calculation of the next layer is entered, otherwise the data calculation results of the current layer are corrected.
[0303] Among them, generating a redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and composing the redundant vectors into a redundant matrix; a redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0304] S704: After completing the propagation calculations of each layer of the target language model, a generation result corresponding to the current iterative calculation and the question information is obtained.
[0305] Large Language Model (LLM) is a deep learning model trained on massive text data. Its core capabilities include generating natural language text and deeply understanding the meaning of text. This type of model can perform a variety of natural language processing tasks, such as text summarization, question answering, translation, etc.
[0306] Large language models are designed to simulate human language comprehension and generation capabilities. They are usually trained on large datasets to learn language structure, grammar, and contextual information.
[0307] In an embodiment of the present invention, for S701, a large language model is trained based on sample data. When performing iterative calculations, the input question information is the sample data, and the question information includes prompts. After forward propagation calculations and back propagation calculations, the generation result of the current iterative calculation is generated. After the iteration end condition is reached, a large language model with adjusted model parameters is obtained.
[0308] When performing AI question-answering tasks, it is usually to receive question information input by the user, which includes prompt words, and input the prompt words into the large language model for a preset number of inference calculations. In the process of using the large language model for inference calculations, a new token is generated by inputting the prompt words into the large language model, and the newly generated token is spliced with the prompt words and then input into the model to generate a new token. The sequence generated by analogy is the answer information.
[0309] For S702, the prompt words in the input question information are converted into vector form to obtain word vectors that meet the model calculation requirements of the target language model, and the word vectors are input into the target language model for iterative calculation.
[0310] The specific implementation of S703 may refer to the description of the specific implementation of S103.
[0311] For S104, after error detection and error correction of the general matrix multiplication calculation in the propagation calculation of the target language model in S103, the propagation calculation of each layer is sequentially performed. After the propagation calculation of each layer is completed, the generation result corresponding to the current iterative calculation and the question information is obtained. If the model calculation is in the model training process, after the forward propagation calculation of each layer is completed, and then the reverse propagation calculation of each layer is completed, the generation result corresponding to the current iterative calculation and the question information is obtained. If the model calculation is in the model reasoning process, after the forward propagation calculation of each layer is completed, the generation result corresponding to the current iterative calculation and the question information is obtained.
[0312] On the basis of the above embodiment, in S703, the weight matrix is divided into multiple data blocks by row, and multiple different redundant vectors are generated according to the data blocks, and each redundant vector is combined into a redundant matrix, which may include:
[0313] Divide the weight matrix evenly into rows Data blocks;
[0314] Calculate the column elements of the same column elements in a single data block and obtain the redundancy value of the corresponding column to obtain the redundancy vector corresponding to the single data block in sequence, then calculate the column elements of the same column elements and obtain the redundancy value of the corresponding column of the data blocks in groups of two without repetition to obtain the corresponding redundancy vector in sequence, and so on until the elements of the same column of all data blocks and the corresponding redundancy vectors are obtained;
[0315] The redundant vectors are concatenated up and down to obtain a redundant matrix;
[0316] in, p is the blocking factor and p Is a positive integer.
[0317] In some optional implementations of the embodiments of the present invention, the construction process of the redundant matrix includes constructing OK d Redundancy matrix of columns :
[0318] right j =1,2,……, d ,
[0319] when When is an odd number, ,in, =2 k -1, ;
[0320] when When is an even number, ,in, , l satisfy ;
[0321] in, , ;
[0322] The weight matrix includes n OK d List; k is the sequence number of the data block, , No. k The data block corresponds to the weight matrix Go to kh Row, if the row number of the last row of the last data block n Less than kh Then to the n Behavior stops; h The number of rows for a data block; is the redundant matrix Line j The elements of the column, is the redundant matrix Line j The elements of the column, is the redundant matrix Line j The elements of the column, is the weight matrix i Line j The elements of the column, l is the exponential parameter, express Completely divisible , p is the blocking factor, This is a round-up operation.
[0323] In some optional implementations of the embodiments of the present invention, in S703, respectively performing general matrix multiplication calculations on the weight matrix, the redundancy matrix, and the input word vector of the current layer, and correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first check value, may include:
[0324] Concatenate the redundant matrix under the weight matrix to obtain the check matrix;
[0325] Perform a general matrix multiplication on the check matrix and the input word vector to obtain the check vector. n The components are the data calculation results corresponding to each row of the weight matrix, and the back of the check vector The components are the first check values corresponding to each row of the redundant matrix.
[0326] In some optional implementations of the embodiments of the present invention, the data calculation result in S703 fails to pass the verification, which may include:
[0327] The second check value calculated according to the data calculation result is inconsistent with the corresponding first check value;
[0328] The second check value is inconsistent with the corresponding first check value, which is expressed by the following formula:
[0329] , , m satisfy ;
[0330] in, is the first Quantity, is the first i Quantity, h is the number of rows in a data block, n is the number of rows in the weight matrix, m is the exponential parameter, express Completely divisible , p is the blocking factor.
[0331] In some optional implementations of the embodiments of the present invention, generating a second check value from the data calculation result in S703 includes recursively calculating the second check value corresponding to the data block using the following formula:
[0332] when When is an odd number, ,in, =2 k -1, ;
[0333] when When is an even number, ,in, , l satisfy ;
[0334] in, is the first A second check value is calculated by calculating the data calculation result corresponding to the first check value, is the first A second check value is calculated by calculating the data calculation result corresponding to the first check value, is the first A second check value is calculated by calculating the data calculation result corresponding to the first check value, h is the number of rows in a data block, n is the number of rows in the weight matrix, l is the exponential parameter, express Completely divisible , p is the blocking factor.
[0335] In some other optional implementations of the embodiments of the present invention, generating a second check value from the data calculation result in S703 includes:
[0336] The second check values corresponding to the first check values are obtained by parallel calculation according to the redundancy value calculation method.
[0337] In some optional implementations of the embodiments of the present invention, verifying the data calculation result of the current layer according to the consistency comparison result between the second verification value and the corresponding first verification value in S703 may include:
[0338] If the second check values corresponding to all data blocks are consistent with the corresponding first check values, it is determined that the first check values corresponding to all data blocks pass the check, and further it is determined that the data calculation results of the current layer all pass the check;
[0339] If the second check values corresponding to all data blocks are inconsistent with the corresponding first check values, a check is performed step by step according to the first check values;
[0340] In the step-by-step verification process, if the current first verification value passes the verification, the branch indicator of the first verification value is not verified; if the current first verification value does not pass the verification, and the first verification value has a branch indicator, the branch indicator of the first verification value is verified; if the current first verification value does not pass the verification, and the first verification value does not have a branch indicator, it is determined that the data block corresponding to the first verification value is an erroneous block; wherein, if the current first verification value does not pass the verification but all branch indicators of the first verification value pass the verification, the current first verification value is set to pass the verification;
[0341] Determine that a data calculation result corresponding to an erroneous block is an erroneous result, and determine that a data calculation result corresponding to a first verification value that passes verification is a correct result;
[0342] Among them, the branch index is the first check value in the sort order The sorting order The first check value and the first check value, is the sequence number of the current first check value, l is the exponential parameter, l satisfy , express Completely divisible .
[0343] In some optional implementations of the embodiments of the present invention, the blocking factor is determined based on the computing resources of the computing device that performs the propagation calculation of the current layer and the number of rows of the weight matrix, so that the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix is less than or equal to the maximum computing resources provided by the computing device for the propagation calculation of the current layer.
[0344] In some optional implementations of the embodiments of the present invention, the error correction processing on the data calculation result of the current layer in S703 may include:
[0345] When determining that the second check value is inconsistent with the corresponding first check value, the corresponding data block is an erroneous block;
[0346] Divide each error block into a recalculation matrix;
[0347] Perform a general matrix multiplication on the recalculation matrix and the input word vector of the current layer to obtain the recalculation result;
[0348] The data calculation results of the propagation calculation of the current layer are corrected according to the recalculation results.
[0349] The step of dividing each error block into a recalculation matrix may include:
[0350] Each error block is copied into multiple copies and then spliced to obtain a recalculated matrix;
[0351] According to the recalculation results, error correction is performed on the data calculation results of the propagation calculation of the current layer, including:
[0352] The result that appears most frequently in the recalculated results corresponding to the erroneous block is taken as the final calculation result corresponding to the erroneous block, and the final calculation result is used to replace the data calculation result corresponding to the erroneous block.
[0353] The process of copying each error block into multiple copies and then splicing them together to obtain a recalculated matrix may include:
[0354] Get the recalculated redundant modulus;
[0355] According to the recalculated redundant modulus, the error block is copied multiple times and then spliced into a recalculated matrix, so that the number of each error block in the recalculated matrix is the recalculated redundant modulus.
[0356] Among them, the recalculated redundant modulus can be obtained by the following formula:
[0357] ;
[0358] in, t To recalculate the redundant modulus, n is the number of rows in the weight matrix, is the number of rows of the redundant matrix, s is the number of erroneous blocks, h is the number of rows in a data block, p is the blocking factor, To perform floor operation, This is a round-up operation.
[0359] In the embodiment of the present invention, before performing a general matrix multiplication calculation on the recalculation matrix and the input word vector of the current layer to obtain the recalculation result, the fault-tolerant calculation method may further include:
[0360] Determine whether the number of rows of the recalculated matrix exceeds the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix;
[0361] If yes, return to the step of generating the redundant matrix according to the weight matrix of the current layer;
[0362] If not, it proceeds to the step of performing general matrix multiplication of the recomputed matrix with the input word vector of the current layer.
[0363] In an embodiment of the present invention, the fault-tolerant computing method may further include:
[0364] If the number of steps of generating a redundant matrix based on the weight matrix of the current layer exceeds the recalculation threshold, the iterative calculation of the target language model is stopped and an error message indicating a computing device failure is output.
[0365] In some other optional implementations of the embodiments of the present invention, in S703, respectively performing general matrix multiplication calculations on the weight matrix, the redundancy matrix, and the input word vector of the current layer, and correspondingly obtaining the data calculation result and the first check value of the propagation calculation of the current layer, may include:
[0366] The general matrix multiplication computation of the weight matrix with the input word vector of the current layer and the general matrix multiplication computation of the redundancy matrix with the input word vector of the current layer are performed in parallel.
[0367] It should be noted that in the embodiments of the fault-tolerant computing method of the present invention, some of the steps or features may be ignored or not executed. The hardware or software functional modules divided for convenience of description are not the only implementation form of the fault-tolerant computing method provided in the embodiments of the present invention.
[0368] The above describes in detail various embodiments corresponding to the fault-tolerant computing method. On this basis, the present invention also discloses a fault-tolerant computing device, equipment, non-volatile storage medium and computer program product corresponding to the above method.
[0369] Figure 8 A schematic diagram of the structure of a fault-tolerant computing device provided by an embodiment of the present invention.
[0370] like Figure 8 As shown, the fault-tolerant computing device provided by the embodiment of the present invention includes:
[0371] An information determination unit 801 is used to determine the information of the storage device and the information of the computing device according to the model parallel computing task, and then read the to-be-processed data corresponding to the model parallel computing task from the storage device;
[0372] The second receiving unit 802 is used to convert the data to be processed into an input vector, and input the input vector into a computing device where the model parameters of the target model are deployed for iterative calculation;
[0373] The second calculation unit 803 is used for, in the propagation calculation of the current iterative calculation of the target model, after generating a redundant matrix according to the weight matrix of the current layer, respectively performing general matrix multiplication calculations on the weight matrix, the redundant matrix and the input vector of the current layer, and correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first verification value, generating a second verification value from the data calculation result, and verifying the data calculation result of the current layer according to the consistency comparison result between the second verification value and the corresponding first verification value, if the data calculation results of the current layer pass the verification, entering the propagation calculation of the next layer, otherwise performing error correction processing on the data calculation results of the current layer; after completing the propagation calculation of each layer of the target model, obtaining the generation result corresponding to the current iterative calculation and the data to be processed;
[0374] Among them, generating a redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and composing the redundant vectors into a redundant matrix; a redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0375] The fault-tolerant computing device provided by the embodiment of the present invention may further include:
[0376] The second judgment unit is used to judge whether the number of rows of the recalculation matrix exceeds the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix before performing general matrix multiplication on the recalculation matrix and the input word vector of the current layer to obtain the recalculation result; if so, return to the step of generating the redundant matrix according to the weight matrix of the current layer; if not, enter the step of performing general matrix multiplication on the recalculation matrix and the input word vector of the current layer.
[0377] The fault-tolerant computing device provided by the embodiment of the present invention may further include:
[0378] The second error reporting unit is used to stop the iterative calculation of the target language model and output an error message of a computing device failure if the number of times the step of generating a redundant matrix based on the weight matrix of the current layer is returned exceeds a recalculation threshold.
[0379] Fig. 9 A schematic diagram of the structure of another fault-tolerant computing device provided by an embodiment of the present invention.
[0380] like Fig. 9 As shown, another fault-tolerant computing device provided by an embodiment of the present invention for artificial intelligence question answering includes:
[0381] The first receiving unit 901 is used to receive input question information, where the question information includes prompt words;
[0382] A first conversion unit 902 is used to convert the prompt word into a word vector, and input the word vector into a target language model for iterative calculation;
[0383] The first calculation unit 903 is used for, in the propagation calculation of the current iterative calculation of the target language model, after generating a redundant matrix according to the weight matrix of the current layer, respectively performing general matrix multiplication calculation on the weight matrix, the redundant matrix and the input word vector of the current layer, correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first check value, generating a second check value from the data calculation result, and checking the data calculation result of the current layer according to the consistency comparison result between the second check value and the corresponding first check value, if the data calculation results of the current layer pass the verification, entering the propagation calculation of the next layer, otherwise performing error correction processing on the data calculation results of the current layer; after completing the propagation calculation of each layer of the target language model, obtaining the generation result corresponding to the current iterative calculation and the problem information;
[0384] Among them, generating a redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and composing the redundant vectors into a redundant matrix; a redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
[0385] The fault-tolerant computing device provided by the embodiment of the present invention may further include:
[0386] The first judgment unit is used to judge whether the number of rows of the recalculation matrix exceeds the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix before performing general matrix multiplication on the recalculation matrix and the input word vector of the current layer to obtain the recalculation result; if so, return to the step of generating the redundant matrix according to the weight matrix of the current layer; if not, enter the step of performing general matrix multiplication on the recalculation matrix and the input word vector of the current layer.
[0387] The fault-tolerant computing device provided by the embodiment of the present invention may further include:
[0388] The first error reporting unit is used to stop the iterative calculation of the target language model and output error information of a computing device failure if the number of times the step of generating a redundant matrix based on the weight matrix of the current layer is returned exceeds a recalculation threshold.
[0389] It should be noted that in each implementation of the fault-tolerant computing device provided by the embodiment of the present invention, the division of units is only a logical functional division, and other division methods can be used. The connection method between different units can be electrical, mechanical or other connection methods. The separated units can be located in the same physical location or distributed on multiple network nodes. Each unit can be implemented in the form of hardware or in the form of a software functional unit. That is, part or all of the units provided by the embodiment of the present invention can be selected according to actual needs and the corresponding connection method or integration method can be adopted to achieve the purpose of the embodiment of the present invention.
[0390] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0391] Fig.10 A schematic diagram of the structure of a fault-tolerant computing device provided by an embodiment of the present invention.
[0392] like Fig.10 As shown, the fault-tolerant computing device provided by the embodiment of the present invention includes:
[0393] A memory 1010, used for storing a computer program 1011;
[0394] The processor 1020 is used to execute the computer program 1011. When the computer program 1011 is executed by the processor 1020, the steps of the fault-tolerant computing method provided in any one of the above embodiments are implemented.
[0395] Among them, the processor 1020 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc. The processor 1020 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 1020 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1020 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1020 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0396] The memory 1010 may include one or more non-volatile storage media, which may be non-transitory. The memory 1010 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 1010 is at least used to store the following computer program 1011, wherein the computer program 1011 can implement the relevant steps in the fault-tolerant computing method disclosed in any of the aforementioned embodiments after being loaded and executed by the processor 1020. In addition, the resources stored in the memory 1010 may also include an operating system 1012 and data 1013, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 1012 may be Windows, Lunux or other types of operating systems. Data 1013 may include, but is not limited to, the data involved in the above method.
[0397] In some embodiments, the fault-tolerant computing device may further include a display screen 1030 , a power supply 1040 , a communication interface 1050 , an input / output interface 1060 , a sensor 1070 , and a communication bus 1080 .
[0398] Those skilled in the art will understand that Fig.10 The structure shown in the figure does not constitute a limitation of the fault-tolerant computing device, and may include more or fewer components than shown.
[0399] The fault-tolerant computing device provided by the embodiment of the present invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the steps of the fault-tolerant computing method provided by the above embodiment, and the effect is the same as above.
[0400] An embodiment of the present invention provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the fault-tolerant computing method provided in any one of the above embodiments can be implemented.
[0401] The non-volatile storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0402] For the introduction of the non-volatile storage medium provided in the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the fault-tolerant computing method provided in the embodiment of the present invention, and the present invention will not elaborate on it here.
[0403] An embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the fault-tolerant computing method provided in any one of the above embodiments.
[0404] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the fault-tolerant computing method provided by the embodiment of the present invention, and the present invention will not elaborate on it here.
[0405] The above is a detailed introduction to a fault-tolerant computing method, device, equipment, medium and computer program product provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can refer to each other. For the device, equipment, non-volatile storage medium and computer program product disclosed in the embodiment, since they correspond to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can refer to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
[0406] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A fault-tolerant computing method, It is characterized in that Applied to AI question answering, including: receiving input question information, wherein the question information includes prompt words; Convert the prompt word into a word vector, and input the word vector into a target language model for iterative calculation; In the propagation calculation of the current iterative calculation of the target language model, after generating a redundant matrix according to the weight matrix of the current layer, general matrix multiplication is performed on the weight matrix, the redundant matrix and the input word vector of the current layer respectively, and the data calculation result of the propagation calculation of the current layer and the first verification value are obtained correspondingly, and a second verification value is generated from the data calculation result, and the data calculation result of the current layer is verified according to the consistency comparison result of the second verification value and the corresponding first verification value. If the data calculation results of the current layer pass the verification, the propagation calculation of the next layer is entered, otherwise, the data calculation results of the current layer are corrected; After completing the propagation calculation of each layer of the target language model, obtaining a generation result corresponding to the current iterative calculation and the question information; Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
2. The fault-tolerant computing method according to claim 1, It is characterized in that Dividing the weight matrix into a plurality of data blocks by row, generating a plurality of different redundant vectors according to the data blocks, and composing the redundant vectors into the redundant matrix, including: The weight matrix is evenly divided into rows the data blocks; Calculate and obtain the column elements of the same column elements in a single data block and obtain the redundancy value of the corresponding column to sequentially obtain the redundancy vector corresponding to the single data block, then calculate the column elements of the same column elements and obtain the redundancy value of the corresponding column of the data blocks without repetition to sequentially obtain the corresponding redundancy vector, and so on until the elements of the same column of all the data blocks and the corresponding redundancy vectors are obtained; The redundant matrix is obtained by concatenating the redundant vectors from top to bottom; in, p is the blocking factor and p Is a positive integer.
3. The fault-tolerant computing method according to claim 2, It is characterized in that The construction process of the redundant matrix includes constructing OK d Redundancy matrix of columns : right j =1,2,……, d , when When is an odd number, ,in, =2 k -1, ; when When is an even number, ,in, , l satisfy ; in, , ; The weight matrix includes n OK d List; k is the sequence number of the data block, , No. k The data blocks correspond to the weight matrix Go to kh Row, if the row number of the last row of the last data block n Less than kh Then to the n Behavior stops; h is the number of rows of one of the data blocks; is the number of Line j The elements of the column, is the number of Line j The elements of the column, is the number of Line j The elements of the column, is the weight matrix i Line j The elements of the column, l is the exponential parameter, express Completely divisible , p is the blocking factor, This is a round-up operation.
4. The fault-tolerant computing method according to claim 3, It is characterized in that The weight matrix, the redundancy matrix and the input word vector of the current layer are respectively subjected to general matrix multiplication calculation to obtain the data calculation result of the propagation calculation of the current layer and the first check value, including: The redundant matrix is concatenated below the weight matrix to obtain a check matrix; The check matrix is multiplied by the input word vector to obtain a check vector. n The components are the data calculation results corresponding to each row of the weight matrix, and the back of the check vector The components are the first check values corresponding to each row of the redundant matrix.
5. The fault-tolerant computing method according to claim 4, It is characterized in that The data calculation results failed to pass the verification, including: The second verification value calculated according to the data calculation result is inconsistent with the corresponding first verification value; The second check value is inconsistent with the corresponding first check value, which is expressed by the following formula: , , m satisfy ; in, is the first Quantity, is the first i Quantity, h is the number of rows of the data block, n is the number of rows of the weight matrix, m is the exponential parameter, express Completely divisible , p is the blocking factor.
6. The fault-tolerant computing method according to claim 4, It is characterized in that Generating the second check value from the data calculation result includes recursively calculating the second check value corresponding to the data block using the following formula: when When is an odd number, ,in, =2 k -1, ; when When is an even number, ,in, , l satisfy ; The check vector the second check value obtained by calculating the data calculation result corresponding to the first check value, is the first the second check value obtained by calculating the data calculation result corresponding to the first check value, is the first the second check value obtained by calculating the data calculation result corresponding to the first check value, h is the number of rows of the data block, n is the number of rows of the weight matrix, l is the exponential parameter, express Completely divisible , p is the blocking factor.
7. The fault-tolerant computing method according to claim 1, It is characterized in that Generating the second verification value from the data calculation result includes: The second check values corresponding to the first check values are obtained by parallel calculation according to the redundancy value calculation method.
8. The fault-tolerant computing method according to claim 4, It is characterized in that Verifying the data calculation result of the current layer according to a consistency comparison result between the second verification value and the corresponding first verification value includes: If the second check value corresponding to all the data blocks is consistent with the corresponding first check value, it is determined that the first check value corresponding to all the data blocks passes the check, and further it is determined that the data calculation results of the current layer all pass the check; If the second check value corresponding to all the data blocks is inconsistent with the corresponding first check value, performing level-by-level check according to the first check value; In the step-by-step verification process, if the current first verification value passes the verification, the branch indicator of the first verification value is not verified; if the current first verification value does not pass the verification, and the first verification value has the branch indicator, the branch indicator of the first verification value is verified; if the current first verification value does not pass the verification, and the first verification value does not have the branch indicator, it is determined that the data block corresponding to the first verification value is an erroneous block; wherein, if the current first verification value does not pass the verification but all the branch indicators of the first verification value pass the verification, the current first verification value is set to pass the verification; Determine that the data calculation result corresponding to the error block is an error result, and determine that the data calculation result corresponding to the first verification value that passes verification is a correct result; The branch index is the first check value in the order The sorting order the first verification value and the first verification value, is the sequence number of the current first check value, l is the exponential parameter, l satisfy , express Completely divisible .
9. The fault-tolerant computing method according to claim 2, It is characterized in that The blocking factor is determined based on the computing resources of the computing device that performs the propagation calculation of the current layer and the number of rows of the weight matrix, so that the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix is less than or equal to the maximum computing resources provided by the computing device for the propagation calculation of the current layer.
10. The fault-tolerant computing method according to claim 1, It is characterized in that Performing error correction processing on the data calculation result of the current layer, including: When determining that the second check value is inconsistent with the corresponding first check value, the corresponding data block is an error block; Generate a recalculation matrix from each of the error blocks; Performing a general matrix multiplication calculation on the recalculation matrix and the input word vector of the current layer to obtain a recalculation result; The data calculation result of the propagation calculation of the current layer is subjected to error correction processing according to the recalculation result.
11. The fault-tolerant computing method according to claim 10, It is characterized in that The step of dividing each of the error blocks into the recalculation matrix comprises: Copying each of the erroneous blocks into multiple copies and then splicing them together to obtain the recalculated matrix; The performing error correction processing on the data calculation result of the propagation calculation of the current layer according to the recalculation result includes: The result that appears most frequently in the recalculated results corresponding to the erroneous block is taken as the final calculation result corresponding to the erroneous block, and the data calculation result corresponding to the erroneous block is replaced by the final calculation result.
12. The fault-tolerant computing method according to claim 11, It is characterized in that Each of the error blocks is copied into multiple copies and then spliced to obtain the recalculation matrix, including: Get the recalculated redundant modulus; The erroneous blocks are copied multiple times according to the recalculated redundant modulus and then spliced into the recalculated matrix, so that the number of each erroneous block in the recalculated matrix is the recalculated redundant modulus.
13. The fault-tolerant computing method according to claim 12, It is characterized in that Before performing a general matrix multiplication calculation on the recalculation matrix and the input word vector of the current layer to obtain a recalculation result, the method further includes: Determining whether the number of rows of the recalculation matrix exceeds the sum of the number of rows of the weight matrix and the number of rows of the redundant matrix; If yes, return to the step of generating a redundant matrix according to the weight matrix of the current layer; If not, the step of performing general matrix multiplication calculation on the recalculated matrix and the input word vector of the current layer is entered.
14. The fault-tolerant computing method according to claim 13, It is characterized in that Also includes: If the number of times the step of generating a redundant matrix according to the weight matrix of the current layer is returned exceeds a recalculation threshold, the iterative calculation of the target language model is stopped and an error message indicating a computing device failure is output.
15. The fault-tolerant computing method according to claim 12, It is characterized in that The recalculated redundant modulus is obtained by the following formula: ; in, t for said recalculated redundancy modulus, n is the number of rows of the weight matrix, is the number of rows of the redundant matrix, s is the number of the erroneous blocks, h is the number of rows of the data block, p is the blocking factor, This is a floor operation.
16. The fault-tolerant computing method according to claim 1, It is characterized in that The method of performing general matrix multiplication calculation on the weight matrix, the redundancy matrix and the input word vector of the current layer respectively, and correspondingly obtaining the data calculation result and the first check value of the propagation calculation of the current layer, includes: A general matrix multiplication calculation of the weight matrix and the input word vector of the current layer and a general matrix multiplication calculation of the redundant matrix and the input word vector of the current layer are performed in parallel.
17. A fault-tolerant computing method, It is characterized in that include: After determining the information of the storage device and the information of the computing device according to the model parallel computing task, reading the to-be-processed data corresponding to the model parallel computing task from the storage device; Converting the data to be processed into an input vector, and inputting the input vector into the computing device on which the model parameters of the target model are deployed for iterative calculation; In the propagation calculation of the current iterative calculation of the target model, after generating a redundant matrix according to the weight matrix of the current layer, general matrix multiplication is performed on the weight matrix, the redundant matrix and the input vector of the current layer respectively, and the data calculation result of the propagation calculation of the current layer and the first verification value are obtained correspondingly, and a second verification value is generated from the data calculation result, and the data calculation result of the current layer is verified according to the consistency comparison result of the second verification value and the corresponding first verification value. If the data calculation results of the current layer pass the verification, the propagation calculation of the next layer is entered, otherwise the data calculation results of the current layer are error corrected; After completing the propagation calculation of each layer of the target model, obtaining the generation result corresponding to the current iterative calculation and the data to be processed; Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
18. A fault-tolerant computing device, It is characterized in that Applied to AI question answering, including: A first receiving unit, configured to receive input question information, wherein the question information includes a prompt word; A first conversion unit, used to convert the prompt word into a word vector, and input the word vector into a target language model for iterative calculation; A first calculation unit is used for, in the propagation calculation of the current iterative calculation of the target language model, after generating a redundant matrix according to the weight matrix of the current layer, respectively performing general matrix multiplication calculation on the weight matrix, the redundant matrix and the input word vector of the current layer, correspondingly obtaining the data calculation result of the propagation calculation of the current layer and the first check value, generating a second check value from the data calculation result, and checking the data calculation result of the current layer according to the consistency comparison result between the second check value and the corresponding first check value, if the data calculation results of the current layer pass the verification, entering the propagation calculation of the next layer, otherwise performing error correction processing on the data calculation result of the current layer; after completing the propagation calculation of each layer of the target language model, obtaining the generation result of the current iterative calculation corresponding to the problem information; Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
19. A fault-tolerant computing device, It is characterized in that include: An information determination unit, configured to determine information of a storage device and information of a computing device according to a model parallel computing task, and then read the to-be-processed data corresponding to the model parallel computing task from the storage device; A second receiving unit, configured to convert the data to be processed into an input vector, and input the input vector into the computing device on which the model parameters of the target model are deployed for iterative calculation; A second calculation unit is used for, in the propagation calculation of the current iterative calculation of the target model, generating a redundant matrix according to the weight matrix of the current layer, and then performing general matrix multiplication calculation on the weight matrix, the redundant matrix and the input vector of the current layer respectively, so as to obtain the data calculation result of the propagation calculation of the current layer and the first verification value accordingly, generating a second verification value from the data calculation result, and verifying the data calculation result of the current layer according to the consistency comparison result between the second verification value and the corresponding first verification value, if the data calculation results of the current layer pass the verification, entering the propagation calculation of the next layer, otherwise performing error correction processing on the data calculation results of the current layer; after completing the propagation calculation of each layer of the target model, obtaining the generation result corresponding to the current iterative calculation and the data to be processed; Among them, generating the redundant matrix according to the weight matrix includes: dividing the weight matrix into multiple data blocks by row, and generating multiple different redundant vectors according to the data blocks, and forming the redundant vectors into the redundant matrix; one redundant vector corresponds to one or more data blocks, and the redundant value in the redundant vector is the sum of the column elements of the corresponding column in the corresponding data block; the second check value corresponds to the calculation method of the redundant value.
20. A fault-tolerant computing device, It is characterized in that include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the fault-tolerant computing method according to any one of claims 1 to 17 are implemented.
21. A non-volatile storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the fault-tolerant computing method according to any one of claims 1 to 17 are implemented.
22. A computer program product comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the steps of the fault-tolerant computing method according to any one of claims 1 to 17 are implemented.
