Multi-element heterogeneous computing power adaptation method, device, equipment, medium and product
Through the use of framework unified interfaces and operator libraries, rapid adaptation and unified access of multiple heterogeneous artificial intelligence chips are achieved, solving the problems of difficulty in chip migration and insufficient compatibility, reducing costs and difficulty of migration, and improving depth Learning framework compatibility.
Patent Information
- Application Number
- CN202410867704.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-30
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-30
AI Technical Summary
The algorithm between artificial intelligence chips and development frameworks is difficult to adapt and labor costs are high, resulting in difficulty in chip migration and insufficient compatibility, requiring manufacturer support.
The unified interface of the framework is used to connect to the target deep learning framework. Through operator registration and foundation, the rapid adaptation and unified access of multiple heterogeneous artificial intelligence chips are realized. The operator library is used for adaptation and unified management, reducing the difficulty and cost of migration. .
It achieves rapid adaptation and unified access of different artificial intelligence chips, improves the compatibility of deep learning frameworks, reduces labor costs, reduces migration difficulty, and supports the training and inference code migration of deep learning models.
Smart Images

Figure CN118586477A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a multi-heterogeneous computing power adaptation method, device, equipment, medium and product. Background Art
[0002] With the surge in demand for high-throughput data processing applications, the artificial intelligence (AI) chip industry is developing rapidly. However, chip manufacturers usually need to invest a lot of manpower to adapt current AI chips to mainstream AI development frameworks, and there are deficiencies in operator compatibility. This chimney-style construction method wastes manpower in the industry and also makes it difficult for users to migrate between different chips. In addition, the development framework developed by manufacturers themselves also has the problem of not supporting new operators, and the algorithm is difficult to adapt, which requires support from manufacturers. Summary of the invention
[0003] The purpose of the present invention is to provide a multi-heterogeneous computing power adaptation method, device, equipment, medium and product, which can realize the rapid adaptation and unified access of different artificial intelligence chips, and the target deep learning framework has strong compatibility on different chips, low migration difficulty and low cost.
[0004] In order to solve the above technical problems, the present invention provides a multi-heterogeneous computing power adaptation method, the method comprising:
[0005] Use the framework unified interface to connect to the calling interface of the target deep learning framework;
[0006] Register operators related to the deep learning model using the target deep learning framework, and use the first operator unified interface to base the operators, and transmit the base-based operator information to the second operator unified interface;
[0007] The second operator unified interface is used to connect to the interface of the operator library, and the basic operator information is imported into the operator library;
[0008] According to the operator information in the operator library, multiple heterogeneous artificial intelligence chips are adapted and uniformly accessed.
[0009] In the first aspect, in the multi-heterogeneous computing power adaptation method provided by the present invention, the target deep learning framework is used to register operators related to the deep learning model, and the first operator unified interface is used to base the operators, including:
[0010] Register operators related to the deep learning model using the decoupled plug-in method of the target deep learning framework itself;
[0011] Decoupling the target deep learning framework from the registered operator base using a first operator unified interface, building a virtual device and registering it in the target deep learning framework;
[0012] At the same time, the parameters corresponding to the target deep learning framework are reused and converted to unify the parameters.
[0013] On the other hand, in the above-mentioned multi-heterogeneous computing power adaptation method provided by the present invention, in the process of basicizing the operator, it includes:
[0014] According to the text information in the configuration file, a tree structure for representing the composite operator is constructed; the nodes of the tree structure include basic operators and operators;
[0015] The tree structure is parsed, the output value shape information of each node is automatically derived and a temporary tensor storage area is created to obtain basic operator information.
[0016] On the other hand, in the multi-heterogeneous computing power adaptation method provided by the present invention, parsing the tree structure, automatically deriving the output value shape information of each node and creating a temporary tensor storage area, includes:
[0017] Traversing and parsing each node in the tree structure;
[0018] Operate on the current node, automatically derive the output value shape information of the current node and create a temporary tensor storage area for the current node;
[0019] Execute the basic operators in all nodes, recursively, until all calculations are completed and the basic operator information is obtained.
[0020] On the other hand, in the multi-heterogeneous computing power adaptation method provided by the present invention, performing operations on the current node includes:
[0021] Operate the current node through the function used for matrix operation;
[0022] And / or, the current node is operated by a corresponding activation function.
[0023] On the other hand, in the multi-heterogeneous computing power adaptation method provided by the present invention, the second operator unified interface is used to connect to the interface of the operator library, including:
[0024] Create an interface that is consistent with or similar to the deep neural network library interface as the second operator unified interface;
[0025] The second operator unified interface is connected to the interface of the operator library by using the manufacturer's operator adapter.
[0026] On the other hand, in the above-mentioned multi-heterogeneous computing power adaptation method provided by the present invention, after importing the basic operator information into the operator library, it also includes:
[0027] Use the event insertion method to perform dynamic analysis on the corresponding operator in a separate thread, and count the CPU time and device time of the executed operator respectively;
[0028] Output the analysis results and / or statistical results to a display interface or document.
[0029] On the other hand, in the above-mentioned multi-heterogeneous computing power adaptation method provided by the present invention, after adapting and uniformly accessing the multi-heterogeneous artificial intelligence chips, it also includes:
[0030] According to the target deep learning framework and the connected multi-heterogeneous artificial intelligence chip, the deep learning model is post-pre-trained, supervised fine-tuned and parameter fine-tuned.
[0031] On the other hand, in the multi-heterogeneous computing power adaptation method provided by the present invention, the process of supervising and fine-tuning the deep learning model includes:
[0032] Performing supervised fine-tuning on the deep learning model using a sharding strategy or using a tensor parallel distributed training approach or using both tensor parallel and pipeline parallel distributed training approaches;
[0033] The process of fine-tuning parameters of a large model includes:
[0034] The parameters of the deep learning model are fine-tuned by using a single-card training method or a tensor parallel distributed training method.
[0035] On the other hand, in the above-mentioned multi-heterogeneous computing power adaptation method provided by the present invention, after adapting and uniformly accessing the multi-heterogeneous artificial intelligence chips, it also includes:
[0036] Obtaining computing resource information of the multi-heterogeneous artificial intelligence chip;
[0037] The computing resource information of the multi-heterogeneous artificial intelligence chips is managed in a unified manner.
[0038] On the other hand, in the above-mentioned multi-heterogeneous computing power adaptation method provided by the present invention, the computing resource information of the multi-heterogeneous artificial intelligence chip is uniformly managed, including:
[0039] Performing memory caching and / or memory synchronization on the computing resource information of the multi-heterogeneous artificial intelligence chip;
[0040] When caching memory, the memory request is forwarded to different memory allocators according to the requested memory size, and the corresponding target memory allocator is determined to release the memory according to the memory pointer passed into the memory release function.
[0041] In order to solve the above technical problems, the present invention further provides a multi-heterogeneous computing power adaptation device, the device comprising:
[0042] The framework docking module is used to dock with the calling interface of the target deep learning framework using the framework unified interface;
[0043] An operator processing module, used to register operators related to the deep learning model using the target deep learning framework, and use the first operator unified interface to base the operators, and transmit the base operator information to the second operator unified interface;
[0044] An operator library docking module, used to use the second operator unified interface to dock with the interface of the operator library, and import the basic operator information into the operator library;
[0045] The chip adaptation module is used to adapt and uniformly access multiple heterogeneous artificial intelligence chips according to the operator information in the operator library.
[0046] In order to solve the above technical problems, the present invention further provides a multi-heterogeneous computing power adaptation device, the device comprising:
[0047] Memory for storing computer programs;
[0048] A processor is used to implement the steps of the above-mentioned multi-heterogeneous computing power adaptation method when executing the computer program.
[0049] 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 above-mentioned multi-heterogeneous computing power adaptation method are implemented.
[0050] 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 above-mentioned multi-heterogeneous computing power adaptation method when executed by a processor.
[0051] It can be seen from the above technical scheme that the present invention provides a method for adapting multi-heterogeneous computing power, which includes: using a framework unified interface to connect to the calling interface of the target deep learning framework; using the target deep learning framework to register operators related to the deep learning model, and using the first operator unified interface to basicize the operators, and transmitting the basicized operator information to the second operator unified interface; using the second operator unified interface to connect to the interface of the operator library, and importing the basicized operator information into the operator library; according to the operator information in the operator library, adapting and uniformly accessing the multi-heterogeneous artificial intelligence chips.
[0052] The beneficial effect of the present invention lies in that the above-mentioned multi-heterogeneous computing power adaptation method provided by the present invention first performs framework docking, adopts the framework unified interface to dock with the calling interface of the target deep learning framework, uses the target deep learning framework to register operators, then basicizes the operators, and uses the operator unified interface to dock with the interface of the operator library, and finally adapts and uniformly accesses the multi-heterogeneous artificial intelligence chips based on the docked operator library, so that the vertical connection between the framework and computing power can be achieved, and then the rapid adaptation and unified access of multiple different artificial intelligence chips can be achieved. The whole method is easy to use, improves the compatibility of the target deep learning framework on different artificial intelligence chips, and the operator supports the target deep learning framework without the need for manufacturer support, which saves labor costs, reduces the difficulty of migration, and can better complete the deep learning model training and reasoning code migration based on the target deep learning framework.
[0053] In addition, the present invention also provides corresponding multi-heterogeneous computing power adaptation devices, multi-heterogeneous computing power adaptation equipment, non-volatile storage media and computer program products for the multi-heterogeneous computing power adaptation method, which have the same or corresponding technical features as the above-mentioned multi-heterogeneous computing power adaptation method and have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. 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.
[0055] Figure 1 A flowchart of a multi-heterogeneous computing power adaptation method provided by an embodiment of the present invention;
[0056] Figure 2 A schematic diagram of a framework corresponding to the multi-heterogeneous computing power adaptation method provided in an embodiment of the present invention;
[0057] Figure 3 A schematic diagram of an operator library encapsulation provided by an embodiment of the present invention;
[0058] Figure 4 A schematic diagram of the structure of a multi-heterogeneous computing power adaptation device provided in an embodiment of the present invention;
[0059] Figure 5 A schematic diagram of the structure of a multi-heterogeneous computing power adaptation device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0060] 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.
[0061] The core of the present invention is to provide a multi-heterogeneous computing power adaptation method, device, equipment, medium and product to solve technical problems such as difficult algorithm adaptation between artificial intelligence chips and artificial intelligence development frameworks and high labor costs.
[0062] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Figure 1 A flowchart of a multi-heterogeneous computing power adaptation method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes:
[0063] S101. Use the framework unified interface to connect to the calling interface of the target deep learning framework.
[0064] In practical applications, deep learning frameworks are software toolkits used to build and train deep learning models. They provide a set of high-level application programming interfaces (APIs) and tools that enable researchers and developers to more easily design, implement, and optimize neural network models. Deep learning frameworks not only simplify the design and implementation process of models, but also provide a wealth of pre-trained models and tools, enabling developers to conduct research and application development more efficiently.
[0065] In practical applications, mainstream deep learning frameworks may include TensorFlow (a symbolic mathematical system based on data flow programming, an open source deep learning framework that supports distributed computing and can run on a variety of hardware) and PyTorch (a Python machine learning library, an open source deep learning framework with dynamic computational graph features and ease of use, supporting distributed training and multiple hardware accelerations).
[0066] In implementation, the target deep learning framework of the present invention can use the domestic PaddlePaddle framework, that is, when executing step S101, the framework unified interface is used to connect to the calling interface of the PaddlePaddle framework. PaddlePaddle is based on deep learning technology research and business applications, integrating core framework, basic model library, end-to-end development kit, rich tool components, and Galaxy community. It is an open source and open industrial-grade deep learning platform. In this way, it can support domestic central processing units and domestic operating systems, help chip manufacturers and users to use the PaddlePaddle framework on multiple heterogeneous chips without feeling, and help chip manufacturers and users to easily realize the migration of different open source domestic large models. Specifically, it can complete the migration of domestic open source large model training and reasoning code based on the PaddlePaddle framework. Of course, the target deep learning framework of the present invention can also adopt the above-mentioned deep learning framework TensorFlow, PyTorch or other deep learning frameworks, which will not be repeated here.
[0067] S102: register operators related to the deep learning model using the target deep learning framework, and use the first operator unified interface to make the operators basic, and transmit the basicized operator information to the second operator unified interface.
[0068] It should be noted that operators are basic operations or functions used to process and optimize deep learning models (which can be large models). As the scale and complexity of deep learning models continue to increase, especially when training large models with billions of parameters, the design and implementation of operators become particularly important. Operator information can include the operator's model file, weight information, etc.
[0069] Taking into account certain differences in operators related to deep learning models, the present invention defines a unified operator interface, with the aim of enabling existing operators and models to be used in the framework and calling artificial intelligence chips for calculations.
[0070] When executing step S102, the PaddlePaddle framework can be used to register operators related to the deep learning model, and the first operator unified interface (the local manufacturer's operator unified interface) can be used to basicize the operators, and the basicized operator information can be transmitted to the second operator unified interface (the operator unified interface of other manufacturers). The basicized operator information can include registered operator information, composite operator information, and other new operator information.
[0071] S103: Use the second operator unified interface to connect to the interface of the operator library, and import the basic operator information into the operator library.
[0072] It should be noted that operators are the smallest units that constitute deep learning models and algorithms. Adapting operators means adapting deep learning models. Therefore, it is necessary to import basic operator information into the operator library so that deep learning models trained on hardware can run on different artificial intelligence chips. Operator library docking can realize the scheduling and distribution of different hardware operator libraries, reducing the complexity and manpower requirements of chip operator library access.
[0073] S104. Adapt and uniformly access multiple heterogeneous artificial intelligence chips based on the operator information in the operator library.
[0074] It should be noted that a heterogeneous multi-core artificial intelligence chip is an integrated circuit that contains multiple different types of processing units. These processing units (or "cores") may have different architectures and functions and are optimized to perform specific types of tasks. This design approach aims to make full use of the advantages of various processing units to improve overall system performance and energy efficiency.
[0075] In implementation, the multi-heterogeneous artificial intelligence chip of the present invention can be a domestically produced multi-heterogeneous artificial intelligence chip. The present invention can widely and conveniently migrate models or algorithms running on existing graphics processors to various domestically produced artificial intelligence chips, simplifying the application development and adaptation for domestically produced artificial intelligence chips.
[0076] When executing step S104, a variety of domestically produced multi-heterogeneous artificial intelligence chips can be adapted and uniformly accessed according to the operator information in the hardware operator library, and the PaddlePaddle framework's large-model efficient distributed training and reasoning optimization capabilities can be fully utilized subsequently.
[0077] In the above-mentioned multi-heterogeneous computing power adaptation method provided by the embodiment of the present invention, the framework is first docked, and the framework unified interface is used to dock the calling interface of the target deep learning framework, and the target deep learning framework is used to register the operator. Then the operator is basicized and the operator unified interface is used to dock the interface of the operator library. Finally, based on the docked operator library, the multi-heterogeneous artificial intelligence chip is adapted and uniformly accessed. In this way, the vertical connection between the framework and the computing power can be achieved, and then the rapid adaptation and unified access of multiple different artificial intelligence chips can be achieved. The whole method is easy to use, improves the compatibility of the target deep learning framework on different artificial intelligence chips, and the operator supports the target deep learning framework without the need for manufacturer support, which saves labor costs, reduces the difficulty of migration, and can better complete the deep learning model training and reasoning code migration based on the target deep learning framework.
[0078] It should be pointed out that the domestic open source big models in the industry have problems such as inconsistent training and reasoning frameworks, poor adaptation and compatibility, insufficient support from domestic artificial intelligence acceleration chips, and serious reliance on adaptation to foreign service frameworks. The multi-heterogeneous computing power adaptation method provided in the embodiments of the present invention can be understood as building a multi-heterogeneous computing power execution framework to achieve upward docking with the target deep learning (such as PaddlePaddle) framework and downward docking with different domestic artificial intelligence acceleration chips, and support more than one mainstream open source big model to achieve a general performance optimization solution, solving the adaptation and migration problems of customers in various industries in conducting artificial intelligence research and development and deployment on multi-heterogeneous chips.
[0079] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in an embodiment of the present invention, step S102 utilizes the target deep learning framework to register operators related to the deep learning model, and utilizes the first operator unified interface to basicize the operators, which may specifically include: utilizing the target deep learning framework's own decoupling plug-in method to register operators related to the deep learning model; utilizing the first operator unified interface to decouple the target deep learning framework from the registered operator basic, constructing a virtual device and registering it in the target deep learning framework; at the same time, reusing and converting the parameters corresponding to the target deep learning framework to unify the parameters.
[0080] In implementation, step S102 is the process of framework docking, which realizes a unified registration method for the target deep learning (such as PaddlePaddle) framework, and formulates a docking standard: by combining the target deep learning framework's own decoupling plug-in (custom device) method to register with the front-end framework, where the front-end framework refers to the software part that interacts with the user, which can be a user interface (User Interface) or a command line interface (Command-line Interface, CLI). The present invention does not invade the user-oriented interface layer code and does not change the user's usage habits.
[0081] Figure 2 The schematic diagram of the framework corresponding to the multi-heterogeneous computing power adaptation method provided in the embodiment of the present invention. Figure 2 As shown, the first operator unified interface is used to decouple the target deep learning framework from the operator base. By building a virtual device and registering it in each target deep learning framework, the operator conversion is performed in the core program (Kernel) implementation, the operator registration function of the framework is reused, and the parameters such as the network tensor (Tensor) of each framework are converted to unify the parameters of the framework.
[0082] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in the embodiment of the present invention, step S102, in the process of basicizing the operator, may specifically include: constructing a tree structure for representing the composite operator according to the text information in the configuration file; the nodes of the tree structure contain basic operators and operators; parsing the tree structure, automatically deriving the output value shape information of each node and creating a temporary tensor storage area to obtain the basicized operator information.
[0083] In implementation, the present invention can develop operators for inference-side business and model requirements. Operator basicization can develop operators to obtain composite operators; wherein, the composite operator can be understood as a new operator or model constructed by multiple operators, such as an addition (add) operator and a matrix multiplication (matmul) operator, and these two operators can constitute a new operator. Operator basicization is a composite operator implementation method based on a configuration file. The present invention can realize the representation of various composite operator calculation processes as the same calculation process by converting the text representation in the configuration file into a unified tree representation, and specifically constructing the composite operator into a tree structure, whose nodes contain basic operator information and operators, and then completing the calculation function of the composite operator by parsing and executing the tree structure. When executing the operation of each node, the output value shape information of the current node can be automatically derived and a temporary tensor can be created. As an expansion means of operator development, the operator basicization module can reduce the amount of backend code development and quickly implement the calculation functions of a part of the composite operator based on the existing basic operators.
[0084] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in an embodiment of the present invention, the tree structure is parsed, the output value shape information of each node is automatically derived, and a temporary tensor storage area is created. Specifically, it can include: traversing and parsing each node in the tree structure; performing operations on the current node, automatically deriving the output value shape information of the current node and creating a temporary tensor storage area for the current node; executing the basic operators in all nodes, recursively layer by layer, until all calculations are completed to obtain the basic operator information.
[0085] In implementation, each node in the parsing tree structure can be traversed from the beginning, a temporary tensor storage area can be automatically created for the node, and then the basic operators in the node can be executed, layer by layer, recursively, until all calculations are completed and the final result is obtained. Regardless of the calculation process of the composite operator, parsing and execution can be completed through a set of codes, which reduces the difficulty of system development.
[0086] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in an embodiment of the present invention, operations are performed on the current node, which may specifically include: operating on the current node through a function used for matrix operations; and / or operating on the current node through a corresponding activation function.
[0087] In implementation, the current node may be operated using a first formula through a function for matrix operation; the first formula is:
[0088] Out1=β*input+α*(mat1@mat2); (1)
[0089] Among them, Out1 is the result matrix output by the function for matrix operation; input is the input element of the function for matrix operation, mat1 and mat2 are two tensors for matrix multiplication, and α and β are weight coefficients. α and β are optional and the default value is 1.0.
[0090] In addition, the second formula can be used to operate the current node through the corresponding activation function; the second formula is:
[0091] Out2=0.5*x*(1+tanh(sqrt(2 / π)*(x+0.044715*x^3))); (2)
[0092] Among them, Out2 is the output result of the activation function, x is the input value, tanh is the hyperbolic tangent function, sqrt is the square root function, and ^3 represents cube.
[0093] In implementation, the mathematical expressions of formulas (1) and (2) above are used to perform node operations, which can expand the support range of framework operators, use basic operators to support complex operators, achieve rapid support for complex operators and new operators, and reduce dependence on chip operator libraries.
[0094] Furthermore, in the specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in the embodiment of the present invention, step S103 uses the second operator unified interface to connect to the interface of the operator library, which can specifically include: creating an interface that is consistent with or similar to the deep neural network library interface as the second operator unified interface; using the manufacturer's operator adapter to connect the second operator unified interface with the interface of the operator library.
[0095] In implementation, Figure 2 As shown, an interface consistent with or similar to the CUDA Deep Neural Network library (CuDNN) is created as the second operator unified interface, including interface definition, return information, input parameters, etc., in order to keep the user's usage and habits unchanged and facilitate the use of users or manufacturers. The second operator unified interface can be the operator unified interface of a manufacturer with artificial intelligence chips. When the operator library is connected, the manufacturer's adapter can be used to design a unified interface for the operator libraries of various manufacturers.
[0096] It should be noted that since the parameter names and parameter numbers of the operator library interfaces provided by various artificial intelligence chip manufacturers are often inconsistent, the present invention defines the unified interface of the manufacturer's operators as the target interface class to unify the data type and operator library interface. The present invention can make the adapter class inherit the target interface class, which facilitates data type conversion and eliminates a lot of development adaptation work.
[0097] Figure 3 Schematic diagram of operator library encapsulation provided by an embodiment of the present invention. Figure 3 As shown, the present invention encapsulates the second operator unified interface with the interface of the manufacturer's operator adapter to obtain the operator library encapsulation. In this way, the third-party hardware operator library only needs to adapt the interface after the operator library encapsulation. Through the standardization of the interface, the automatic generation of code for the adaptation process is realized. At this time, the manufacturer's operator adapter can directly connect to the interface of each artificial intelligence chip, such as Figure 3 The interface of the first artificial intelligence chip, the interface of the second artificial intelligence chip, and the interface of the third artificial intelligence chip, etc. are shown.
[0098] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in the embodiment of the present invention, after executing step S103 to import the basic operator information into the operator library, it can also include: performing dynamic analysis on the corresponding operator in a separate thread by inserting events, and separately counting the CPU time and device time of the executed operators; outputting the analysis results and / or statistical results to a display interface or document.
[0099] In practice, the present invention can perform dynamic performance analysis (Profiling) at the backend, which is applicable to operator-level performance testing and statistics of all docked chips, so that computing performance bottlenecks can be quickly counted and identified, and operator-level performance optimization can be assisted. Specifically, a dynamic analysis function is added to the backend operator call, and by inserting events, the CPU time and device time of the executed operators are counted separately in a separate thread; the information such as the number of operator calls, maximum time consumption, minimum time consumption, etc. can be counted, and the operator computing performance can also be tested, such as operator addition, subtraction, multiplication, division, matrix multiplication, matrix transposition, matrix transformation, etc.; model training efficiency, model reasoning efficiency, etc. of complex operators (model algorithms). After the execution is completed, the data is output to the screen and document.
[0100] Furthermore, in the specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in the embodiment of the present invention, after executing step S104 to adapt and uniformly access the multi-heterogeneous artificial intelligence chips, it can also include: according to the target deep learning framework and the accessed multi-heterogeneous artificial intelligence chips, the deep learning model is post-pretrained (PostPretrain), supervised fine-tuning (Supervised fine-tuning, SFT) and parameter fine-tuning (Low-Rank Adaptation, LoRA). In this way, under the premise of ensuring the accuracy alignment of the model, it can help users to conveniently and efficiently complete the post-pretraining of the deep learning model based on the PaddlePaddle framework and multi-heterogeneous chips, and build the capabilities of supervised fine-tuning and parameter fine-tuning.
[0101] In implementation, the process of supervised fine-tuning of deep learning models may specifically include: using sharding strategy or using tensor parallel distributed training or using tensor parallel and pipeline parallel distributed training to supervise fine-tune deep learning models. In addition, the process of fine-tuning parameters of large models may specifically include: fine-tuning parameters of deep learning models using single card training or using tensor parallel distributed training.
[0102] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation method provided in the embodiment of the present invention, after executing step S104 to adapt and uniformly access the multi-heterogeneous artificial intelligence chips, it can also include: obtaining the computing resource information of the multi-heterogeneous artificial intelligence chips; and uniformly managing the computing resource information of the multi-heterogeneous artificial intelligence chips.
[0103] In implementation, computing resource information may include information such as the number of chips and chip status. The present invention can extract the common public part, that is, the computing resource information of multiple heterogeneous artificial intelligence chips, and uniformly manage the back-end artificial intelligence chip resource cache, providing efficient memory application, release and synchronous management and optimization capabilities of computing resources, thereby achieving support for all chips, reducing duplicate development, and improving efficiency. In addition, the present invention can evaluate the actual performance of domestic chip business around benchmark algorithms, model performance tuning solutions and practical cases.
[0104] Furthermore, in the specific implementation, the above steps perform unified management of the computing resource information of the multiple heterogeneous artificial intelligence chips, which may specifically include: memory caching and / or memory synchronization of the computing resource information of the multiple heterogeneous artificial intelligence chips; wherein, during memory caching, the memory application is forwarded to different memory allocators according to the requested memory size, and the corresponding target memory allocator is determined to release the memory according to the memory pointer passed into the memory release function.
[0105] In implementation, the present invention can use a resource management module to uniformly manage the computing resource information of a multi-heterogeneous artificial intelligence chip. The main functions of the resource management module include: resource caching, resource synchronization, resource memory overflow (Out Of Memory, OOM) prevention, and resource usage reporting. For resource caching, different memory caching schemes can be used according to different size blocks of memory to further improve the performance of memory application and release. The resource management module may include a memory application and release forwarder and a memory allocator; wherein the memory application and release forwarder can forward the current memory application to different memory allocators according to the size of the memory applied; accordingly, the memory application and release forwarder will determine which memory allocator will release the memory according to the memory pointer passed into the memory release function; the memory allocator is responsible for specific memory application and release operations. Different memory allocators can adopt different strategies for applications of different sizes.
[0106] It should be noted that the resource management module supports three working modes, and users can choose according to the model characteristics and requirements: the first is the default mode, which performs both memory caching and memory synchronization operations; the second is the memory caching mode, which only performs memory caching operations and does not perform memory synchronization operations; the third is the memory synchronization mode, which only performs memory synchronization operations and does not perform memory caching operations.
[0107] The resource management module of the present invention is scalable, supports device memory, host memory, etc., and can add other types as needed. For operators that consume more time, the core program of the operator can be integrated and optimized to improve the overall execution performance.
[0108] In practical applications, the multi-heterogeneous computing power adaptation method of the present invention can be widely promoted in the market through joint solution construction and productization strategies with domestic servers, chip manufacturers, platform manufacturers, framework suppliers, and integrators. During the promotion process, technology upgrades and capability optimization can be carried out based on feedback from end customers, integrators, and partners on large-model business development and framework technology evolution.
[0109] In the above embodiments, the multi-heterogeneous computing power adaptation method is described in detail, and the present invention also provides embodiments corresponding to the multi-heterogeneous computing power adaptation device and the multi-heterogeneous computing power adaptation equipment. It should be noted that the present invention describes the embodiments of the device part from two perspectives, one is based on the functional module perspective, and the other is based on the hardware perspective.
[0110] Figure 4 A schematic diagram of the structure of a multi-heterogeneous computing power adaptation device provided in an embodiment of the present invention. Based on the perspective of functional modules, the device includes:
[0111] The framework docking module 10 is used to dock with the calling interface of the target deep learning framework using the framework unified interface;
[0112] The operator processing module 11 is used to register the operators related to the deep learning model using the target deep learning framework, and use the first operator unified interface to base the operators, and transmit the basicized operator information to the second operator unified interface;
[0113] The operator library docking module 12 is used to use the second operator unified interface to dock with the interface of the operator library, and import the basic operator information into the operator library;
[0114] The chip adaptation module 13 is used to adapt and uniformly access multiple heterogeneous artificial intelligence chips based on the operator information in the operator library.
[0115] In the above-mentioned multi-heterogeneous computing power adaptation device provided in an embodiment of the present invention, through the interaction of the above-mentioned four modules, the framework can be firstly docked, and the framework unified interface is used to dock the calling interface of the target deep learning framework, and the target deep learning framework is used to register the operator, and then the operator is basicized, and the operator unified interface is used to dock the interface of the operator library, and finally, based on the docked operator library, the multi-heterogeneous artificial intelligence chip is adapted and uniformly accessed. In this way, the vertical connection between the framework and the computing power can be realized, and then the rapid adaptation and unified access of multiple different artificial intelligence chips can be realized, which improves the compatibility of the target deep learning framework on different artificial intelligence chips. The operator supports the target deep learning framework without the support of the manufacturer, which saves labor costs, reduces the difficulty of migration, and can better complete the deep learning model training and reasoning code migration based on the target deep learning framework.
[0116] Since the embodiments of the device part correspond to the embodiments of the method part, the embodiments of the device part refer to the description of the embodiments of the method part, which will not be described here. And it has the same beneficial effects as the multi-heterogeneous computing power adaptation method mentioned above.
[0117] Furthermore, in a specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation device provided in an embodiment of the present invention, the operator processing module 11 may specifically include:
[0118] The operator registration unit is used to register operators related to the deep learning model using the decoupled plug-in method of the target deep learning framework itself;
[0119] The operator basicization unit is used to decouple the target deep learning framework from the registered operator basicization by using the first operator unified interface, build a virtual device and register it in the target deep learning framework; at the same time, reuse and convert the parameters corresponding to the target deep learning framework to unify the parameters.
[0120] Among them, the operator basicization unit can be used to construct a tree structure for representing a composite operator according to the text information in the configuration file; the nodes of the tree structure contain basic operators and operators; the tree structure is parsed, the output value shape information of each node is automatically derived and a temporary tensor storage area is created to obtain the basicized operator information.
[0121] Furthermore, in specific implementation, in the above-mentioned multi-heterogeneous computing power adaptation device provided in the embodiment of the present invention, the operator library docking module 12 can be specifically used to create an interface that is consistent with or similar to the deep neural network library interface as a second operator unified interface; and use the manufacturer's operator adapter to dock the second operator unified interface with the interface of the operator library.
[0122] Furthermore, in a specific implementation, the multi-heterogeneous computing power adaptation device provided in the embodiment of the present invention may further include:
[0123] The dynamic analysis module is used to perform dynamic analysis on the corresponding operator in a separate thread by inserting events, and to count the CPU time and device time of the executed operators respectively; and to output the analysis results and / or statistical results to a display interface or document.
[0124] Furthermore, in a specific implementation, the multi-heterogeneous computing power adaptation device provided in the embodiment of the present invention may further include:
[0125] The model training module is used to perform post-training, supervised fine-tuning and parameter fine-tuning of the deep learning model based on the target deep learning framework and the connected multi-heterogeneous artificial intelligence chips.
[0126] Furthermore, in a specific implementation, the multi-heterogeneous computing power adaptation device provided in the embodiment of the present invention may further include:
[0127] The resource management module is used to obtain the computing resource information of multiple heterogeneous artificial intelligence chips; and to uniformly manage the computing resource information of multiple heterogeneous artificial intelligence chips.
[0128] The resource management module may specifically include:
[0129] A memory processing unit is used to perform memory caching and / or memory synchronization on the computing resource information of a multi-heterogeneous artificial intelligence chip; wherein, during memory caching, the memory request is forwarded to different memory allocators according to the requested memory size, and the corresponding target memory allocator is determined to release the memory according to the memory pointer passed into the memory release function.
[0130] Figure 5 This is a schematic diagram of the structure of a multi-heterogeneous computing power adaptation device provided in an embodiment of the present invention. This embodiment is based on the hardware perspective, such as Figure 5 As shown in the figure, the multi-heterogeneous computing power adaptation equipment includes:
[0131] A memory 20, used for storing computer programs;
[0132] The processor 21 is used to implement the steps of the multi-heterogeneous computing power adaptation method mentioned in the above embodiment when executing a computer program.
[0133] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 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 CPU; the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 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 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0134] The memory 20 may include one or more non-volatile storage media, which may be non-transitory. The memory 20 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 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, the relevant steps of the multi-heterogeneous computing power adaptation method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. Data 203 may include, but is not limited to, the data involved in the multi-heterogeneous computing power adaptation method mentioned above.
[0135] In some embodiments, the multi-heterogeneous computing power adaptation device may further include a display screen 22, an input and output interface 23, a communication interface 24, a power supply 25, and a communication bus 26. Those skilled in the art will appreciate that Figure 5 The structure shown in does not constitute a limitation on the multi-heterogeneous computing power adaptation device, and may include more or fewer components than shown in the figure. The multi-heterogeneous computing power adaptation 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 following method: the multi-heterogeneous computing power adaptation method has the same effect as above.
[0136] Finally, the present invention also provides an embodiment corresponding to a non-volatile storage medium. The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0137] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc. Various media that can store program codes. The non-volatile storage medium provided by the present invention can realize the above-mentioned multi-heterogeneous computing power adaptation method, and the effect is the same as above.
[0138] Finally, the present invention also provides an embodiment corresponding to a computer program product. The computer program product includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps described in the above-mentioned multi-heterogeneous computing power adaptation method embodiment are implemented. The computer program product provided by the present invention can implement the above-mentioned multi-heterogeneous computing power adaptation method, and the effect is the same as above.
[0139] 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.
[0140] The above is a detailed introduction to the multi-heterogeneous computing power adaptation method, device, equipment, medium and 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 embodiments can refer to each other. For the device disclosed in the embodiment, since it corresponds 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, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A multi-heterogeneous computing power adaptation method, characterized in that: The method comprises: Use the framework unified interface to connect to the calling interface of the target deep learning framework; Register operators related to the deep learning model using the target deep learning framework, and use the first operator unified interface to base the operators, and transmit the base-based operator information to the second operator unified interface; The second operator unified interface is used to connect to the interface of the operator library, and the basic operator information is imported into the operator library; According to the operator information in the operator library, multiple heterogeneous artificial intelligence chips are adapted and uniformly accessed.
2. The multi-heterogeneous computing power adaptation method according to claim 1, characterized in that: The target deep learning framework is used to register operators related to the deep learning model, and the first operator unified interface is used to base the operators, including: Register operators related to the deep learning model using the decoupled plug-in method of the target deep learning framework itself; Decoupling the target deep learning framework from the registered operator base using a first operator unified interface, building a virtual device and registering it in the target deep learning framework; At the same time, the parameters corresponding to the target deep learning framework are reused and converted to unify the parameters.
3. The multi-heterogeneous computing power adaptation method according to claim 2, characterized in that: In the process of basicizing operators, we include: According to the text information in the configuration file, a tree structure for representing the composite operator is constructed; the nodes of the tree structure include basic operators and operators; The tree structure is parsed, the output value shape information of each node is automatically derived and a temporary tensor storage area is created to obtain basic operator information.
4. The multi-heterogeneous computing power adaptation method according to claim 3, characterized in that: Parse the tree structure, automatically derive the output value shape information of each node and create a temporary tensor storage area, including: Traversing and parsing each node in the tree structure; Operate on the current node, automatically derive the output value shape information of the current node and create a temporary tensor storage area for the current node; Execute the basic operators in all nodes, recursively, until all calculations are completed and the basic operator information is obtained.
5. The multi-heterogeneous computing power adaptation method according to claim 4, characterized in that: Perform operations on the current node, including: Operate the current node through the function used for matrix operation; And / or, the current node is operated by a corresponding activation function.
6. The multi-heterogeneous computing power adaptation method according to claim 1, characterized in that: The interface of the operator library is connected using the second operator unified interface, including: Create an interface that is consistent with or similar to the deep neural network library interface as the second operator unified interface; The second operator unified interface is connected to the interface of the operator library by using the manufacturer's operator adapter.
7. The multi-heterogeneous computing power adaptation method according to claim 1, characterized in that: After the basic operator information is imported into the operator library, the following steps are also included: Use the event insertion method to perform dynamic analysis on the corresponding operator in a separate thread, and count the CPU time and device time of the executed operator respectively; Output the analysis results and / or statistical results to a display interface or document.
8. The multi-heterogeneous computing power adaptation method according to claim 1, characterized in that: After adapting and unifying the multiple heterogeneous AI chips, it also includes: According to the target deep learning framework and the connected multi-heterogeneous artificial intelligence chip, the deep learning model is post-pre-trained, supervised fine-tuned and parameter fine-tuned.
9. The multi-heterogeneous computing power adaptation method according to claim 8, characterized in that: The process of supervised fine-tuning the deep learning model includes: Performing supervised fine-tuning on the deep learning model using a sharding strategy or using a tensor parallel distributed training approach or using both tensor parallel and pipeline parallel distributed training approaches; The process of fine-tuning parameters of a large model includes: The parameters of the deep learning model are fine-tuned by using a single-card training method or a tensor parallel distributed training method.
10. The multi-heterogeneous computing power adaptation method according to claim 1, characterized in that: After adapting and unifying the multiple heterogeneous AI chips, it also includes: Obtaining computing resource information of the multi-heterogeneous artificial intelligence chip; The computing resource information of the multi-heterogeneous artificial intelligence chips is managed in a unified manner.
11. The multi-heterogeneous computing power adaptation method according to claim 10, characterized in that: The computing resource information of the multi-heterogeneous artificial intelligence chip is managed in a unified manner, including: Performing memory caching and / or memory synchronization on the computing resource information of the multi-heterogeneous artificial intelligence chip; When caching memory, the memory request is forwarded to different memory allocators according to the requested memory size, and the corresponding target memory allocator is determined to release the memory according to the memory pointer passed into the memory release function.
12. A multi-heterogeneous computing power adaptation device, characterized in that: The device comprises: The framework docking module is used to dock with the calling interface of the target deep learning framework using the framework unified interface; An operator processing module, used to register operators related to the deep learning model using the target deep learning framework, and use the first operator unified interface to base the operators, and transmit the base operator information to the second operator unified interface; An operator library docking module, used to use the second operator unified interface to dock with the interface of the operator library, and import the basic operator information into the operator library; The chip adaptation module is used to adapt and uniformly access multiple heterogeneous artificial intelligence chips according to the operator information in the operator library.
13. A multi-heterogeneous computing power adaptation device, characterized in that: The device comprises: Memory for storing computer programs; A processor, used to implement the steps of the multi-heterogeneous computing power adaptation method as described in any one of claims 1 to 11 when executing the computer program.
14. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, which, when executed by a processor, implements the steps of the multi-heterogeneous computing power adaptation method as described in any one of claims 1 to 11.
15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by the processor, the steps of the multi-heterogeneous computing power adaptation method as described in any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Domestic platform artificial intelligence environment adaptation method and compatibility test method
CN113076143A
Model training method and device, storage medium and electronic equipment
CN116304704A
Multi-element heterogeneous computing power equipment scheduling method, device and equipment and storage medium
CN116700934A
Universal operator generation method and device based on binary tree
CN117112843A
Operator analysis method and device based on lexical and grammatical analysis, equipment and medium
CN117971236A
Cited By
Intelligent AI operator adaptation and optimization method oriented to heterogeneous computing power compatibility
CN118885306A
Communication method, device, storage medium and program product
CN119226193A
Automatic operator arrangement method and system based on large model
CN119473597A
Memory allocation method and device for model in heterogeneous system, medium and product
CN119621356A
Interface access method and electronic equipment
CN122507518A
