Computing graph processing method, training method, compilation method, device, equipment and medium
Patent Information
- Application Number
- CN202610738198.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-26
- Publication Date
- 2026-08-18
Smart Images

Figure CN122596147A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, particularly to the fields of deep learning models and model operator analysis, and specifically to a computation graph processing method, model training method, compilation method, device, intelligent agent, electronic device, storage medium, and program product. Background Technology
[0002] With the exponential growth in the size of deep learning models, optimizing the computation graph through tensor compilers to improve hardware computation efficiency has become a key technical approach for deep learning systems. During compiler development and tuning, a large number of representative computational subgraphs are needed as test and evaluation samples. Summary of the Invention
[0003] This disclosure provides a computational graph processing method, a model training method, a compilation method, an apparatus, an intelligent agent, an electronic device, a storage medium, and a program product.
[0004] According to one aspect of this disclosure, a computation graph processing method is provided, comprising: performing convolutional hash fingerprint calculation on a sequence of operators to be processed to obtain hash fingerprint information of each subsequence in the sequence of operators to be processed, wherein the sequence of operators to be processed is generated based on multiple computation graphs, the computation graphs representing operators of a deep learning model and the data dependencies between operators; recursively folding repeated subsequences in the sequence of operators to be processed based on the hash fingerprint information to obtain multiple candidate operator sequences, wherein the repeated subsequences include multiple subsequences to be folded with the same hash fingerprint information; determining multiple splitting positions based on the multiple candidate operator sequences; and splitting the computation graph based on the multiple splitting positions to obtain multiple computation subgraphs.
[0005] According to another aspect of this disclosure, a model training method is provided, comprising: training a training compilation model to be trained using multiple computational subgraphs to obtain a target compilation model; wherein the multiple computational subgraphs are obtained by the method described above.
[0006] According to another aspect of this disclosure, a compilation method is provided, comprising inputting a computation graph to be processed into a target compilation model to obtain running code, wherein the target compilation model is trained by the method described above.
[0007] According to another aspect of this disclosure, a computation graph processing apparatus is provided, comprising: a computation module, configured to perform convolutional hash fingerprint calculation on a sequence of operators to be processed to obtain hash fingerprint information of each subsequence in the sequence of operators to be processed, wherein the sequence of operators to be processed is generated based on multiple computation graphs, the computation graphs representing operators of a deep learning model and data dependencies between operators; a recursive folding module, configured to recursively fold repeated subsequences in the sequence of operators to be processed based on the hash fingerprint information to obtain multiple candidate operator sequences, wherein the repeated subsequences include multiple subsequences to be folded that have the same hash fingerprint information; a determination module, configured to determine multiple splitting positions based on the multiple candidate operator sequences; and a splitting module, configured to decompose the computation graph based on the multiple splitting positions to obtain multiple computation subgraphs.
[0008] According to another aspect of this disclosure, a model training apparatus is provided, comprising: a training module for training a training compilation model to be trained using multiple computational subgraphs to obtain a target compilation model; wherein the multiple computational subgraphs are obtained by the method described above.
[0009] According to another aspect of this disclosure, a compilation apparatus is provided, comprising: a compilation module for inputting a computation graph to be processed into a target compilation model to obtain executable code; wherein the target compilation model is trained by the method described above.
[0010] According to another aspect of this disclosure, an intelligent agent is provided, comprising: an input module for receiving input information; a processing module for determining a target task based on the input information received by the input module, determining a large model based on the target task, and obtaining output information by calling the large model to execute the above method; and an output module for outputting the output information obtained by the processing module.
[0011] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the following operations: reading a sequence of operators to be processed from the memory; performing the above-described method on the sequence of operators to be processed to obtain a plurality of computational subgraphs; and storing the plurality of computational subgraphs into the memory.
[0012] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described above.
[0013] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described above.
[0014] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0015] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0016] Figure 1 This illustration schematically shows an exemplary system architecture to which computational graph processing methods and apparatus can be applied according to embodiments of the present disclosure;
[0017] Figure 2 A flowchart illustrating a computational graph processing method according to an embodiment of the present disclosure is shown schematically.
[0018] Figure 3A The illustration shows a schematic diagram of the processing of a deep learning model according to an embodiment of the present disclosure;
[0019] Figure 3B The illustration shows a schematic diagram of the processing of a deep learning model according to an embodiment of the present disclosure;
[0020] Figure 4 The diagram illustrates a process for constructing a sequence of operators to be processed according to an embodiment of the present disclosure.
[0021] Figure 5 A schematic diagram illustrating a recursive folding operation according to an embodiment of the present disclosure is shown.
[0022] Figure 6 A schematic diagram of an operator sequence according to an embodiment of the present disclosure is shown;
[0023] Figure 7 A flowchart illustrating the computational graph processing flow according to an embodiment of the present disclosure is shown schematically.
[0024] Figure 8 A flowchart illustrating a model training method according to an embodiment of the present disclosure is shown schematically.
[0025] Figure 9 A flowchart illustrating a compilation method according to an embodiment of the present disclosure is shown schematically;
[0026] Figure 10 A block diagram of a computational graph processing apparatus according to an embodiment of the present disclosure is shown schematically;
[0027] Figure 11 A block diagram of a model training apparatus according to an embodiment of the present disclosure is shown schematically;
[0028] Figure 12A block diagram of a compilation apparatus according to an embodiment of the present disclosure is shown schematically;
[0029] Figure 13 A schematic diagram illustrating the structure of an intelligent agent according to embodiments of the present disclosure is shown; and
[0030] Figure 14 A block diagram of an electronic device suitable for implementing a computational graph processing method according to an embodiment of the present disclosure is shown schematically. Detailed Implementation
[0031] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0032] In related technologies, computational subgraph extraction techniques mainly rely on manually predefined rules, making it difficult to automatically discover high-frequency computational patterns emerging in new models. Furthermore, efficiently identifying and deduplicating common subgraph patterns across models and tasks from computational graph data of a large number of models presents significant challenges in terms of computational complexity.
[0033] In view of this, embodiments of this disclosure provide a computation graph processing method, comprising: performing convolutional hash fingerprint calculation on a sequence of operators to be processed to obtain hash fingerprint information of each subsequence in the sequence of operators to be processed, wherein the sequence of operators to be processed is generated based on multiple computation graphs, the computation graphs representing operators of a deep learning model and the data dependencies between operators; recursively folding repeated subsequences in the sequence of operators to be processed based on the hash fingerprint information to obtain multiple candidate operator sequences, wherein the repeated subsequences include multiple subsequences to be folded with the same hash fingerprint information; determining multiple splitting positions based on the multiple candidate operator sequences; and splitting the computation graph based on the multiple splitting positions to obtain multiple computation subgraphs.
[0034] By converting the computation graph into a sequence of operators to be processed, treating this sequence as a formal language, and determining the hash fingerprint information of each subsequence within the sequence, we can efficiently detect frequently repeating subsequences based on the hash fingerprint information of each subsequence, since subsequences with identical content have the same hash fingerprint information. Furthermore, we recursively fold the repeating subsequences. Through this progressive approach, we can discover multi-level repeating structures from basic operator combinations to computational modules, overcoming the window length limitation of single detection and identifying higher-level combined operator patterns. This allows us to efficiently summarize frequently occurring structured subgraph patterns from a large number of models and generate splitting points, thus generating high-quality computational subgraphs based on the computation graph and reducing computational complexity.
[0035] Figure 1 The illustration schematically depicts an exemplary system architecture to which computational graph processing methods and apparatus can be applied according to embodiments of the present disclosure.
[0036] It is important to note that Figure 1 The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments, or scenarios. For example, in another embodiment, an exemplary system architecture to which the computational graph processing method and apparatus can be applied may include a terminal device, but the terminal device can implement the computational graph processing method and apparatus provided by the embodiments of this disclosure without interacting with the server.
[0037] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the terminal devices 101, 102, and 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0038] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various data processing applications can be installed on terminal devices 101, 102, and 103. Users can initiate computation graph processing requests based on these applications, allowing the server to process the computation graphs corresponding to multiple deep learning models, extracting computation subgraphs that can be applied to other deep learning models. Optionally, the deep learning model combined with the extracted computation subgraphs can also be applied to various communication client applications, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social media platforms (for example only).
[0039] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0040] Server 105 can be a server providing various services, such as a backend management server (for example only) that supports the content browsed by users using terminal devices 101, 102, and 103. After completing the computational subgraph extraction operation, the backend management server can organize and store the topology and subgraph information of the computational subgraph. Furthermore, upon receiving computational graph processing requests from other clients, the aforementioned backend management server can also distribute and deploy the relevant information of the computational subgraph.
[0041] It should be noted that the computational graph processing method provided in the embodiments of this disclosure can generally be executed by terminal devices 101, 102, or 103. Accordingly, the computational graph processing apparatus provided in the embodiments of this disclosure can also be disposed in terminal devices 101, 102, or 103.
[0042] Alternatively, the computational graph processing method provided in this embodiment can generally be executed by server 105. Correspondingly, the computational graph processing apparatus provided in this embodiment can generally be located in server 105. The computational graph processing method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the computational graph processing apparatus provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0043] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0044] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of any type of information, such as user personal information, comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and they do not violate public order and good morals.
[0045] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.
[0046] It should be noted that the sequence numbers of the operations in the following methods are for descriptive purposes only and should not be considered as indicating the execution order of the operations. Unless explicitly stated otherwise, the method does not need to be executed in the exact order shown.
[0047] Figure 2 A flowchart illustrating a computational graph processing method according to an embodiment of the present disclosure is shown schematically.
[0048] like Figure 2 As shown, the method includes operations S210~S230.
[0049] In operation S210, convolutional hash fingerprint calculation is performed on the operator sequence to be processed to obtain the hash fingerprint information of each subsequence in the operator sequence to be processed.
[0050] In operation S220, the repeated subsequences in the operator sequence to be processed are recursively folded based on the hash fingerprint information to obtain multiple candidate operator sequences.
[0051] In operation S230, multiple splitting positions are determined based on multiple candidate operator sequences.
[0052] In operation S240, the computation graph is split based on multiple splitting locations to obtain multiple computation subgraphs.
[0053] In this embodiment of the disclosure, the sequence of operators to be processed in the above operation can be generated based on multiple computation graphs, which represent the operators of the deep learning model and the data dependencies between the operators.
[0054] In other words, the sequence of operators to be processed in this embodiment can be obtained by preprocessing multiple deep learning models. Specifically, multiple deep learning models can be preprocessed sequentially to obtain corresponding operator sequences, and the multiple operator sequences can be concatenated to obtain the above-mentioned sequence of operators to be processed.
[0055] Understandably, a deep learning model can include multiple sequentially connected operators. The data dependencies between different operators can be used to characterize the input-output relationship during the data processing process of the deep learning model. For example, a deep learning model may include sequentially connected Conv (convolution operator), ReLU (linear operator), and BN (batch normalization operator). If the data dependency is represented as [Conv, ReLU, BN], it indicates that the data in the aforementioned deep learning model can be processed sequentially by the Conv operator, ReLU operator, and BN operator.
[0056] Furthermore, based on the data dependencies between different operators in the deep learning model, a computational graph can be obtained from the deep learning model through a first preprocessing step. This computational graph can be a directed graph, including multiple nodes and at least one edge. Nodes represent operators in the deep learning model, and directed edges can represent the data dependencies between two connected nodes.
[0057] Next, having obtained the computational graph representing the deep learning model, a second preprocessing step can be performed on the computational graph to obtain the operator sequence corresponding to the deep learning model. Specifically, the computational graph can be topologically sorted, thereby arranging the nodes in the computational graph into a linear total order sequence while maintaining the data dependencies between different operators in the computational graph. In this embodiment, the above-mentioned topological sorting method may be implemented using, but is not limited to, a post-order traversal algorithm, priority topological sorting, etc., and the specific method of topological sorting is not limited here.
[0058] The following explains how to process a deep learning model into a corresponding sequence of operators.
[0059] like Figure 3A As shown, when the first deep learning model includes operators A, B, and C, the first deep model can be processed into a first computation graph including nodes A, B, and C through the first preprocessing. Then, the first computation graph is subjected to a second preprocessing, namely, topological sorting of the first computation graph to obtain the first operator sequence [A, B, C].
[0060] like Figure 3B As shown, in the second deep learning model, there are operators A, B, and C. The output of operator A is used as the input to three parallel operators B, and the outputs of the three parallel operators B converge as the input to operator C. Therefore, the second deep model can be processed into a second computation graph containing nodes A, B, and C through a first preprocessing step. A second preprocessing step is then performed on the second computation graph, namely, topological sorting. Since the second computation graph indicates that the data dependencies of the three operators are of equal importance, the three operators can be sequentially sorted in the sequence to obtain the second operator sequence [A, B, B, B, C].
[0061] The above method of processing deep learning models into operator sequences is merely an illustrative example and does not limit the specific preprocessing methods of deep learning models in the embodiments of this disclosure.
[0062] Furthermore, if an operator sequence corresponding to a deep learning model is determined according to the above implementation method, the operator sequences corresponding to multiple deep learning models can be concatenated to obtain the above-mentioned operator sequence to be processed.
[0063] It should be noted that the above-mentioned convolutional hash fingerprint calculation can be a method based on convolution operations to map each subsequence in the operator sequence to its corresponding hash fingerprint information, which is used to efficiently characterize the local perceptual features in the operator sequence. Through the above-mentioned convolutional hash fingerprint calculation, adjacent or specifically spaced subsets of operators in the operator sequence can be mapped to hash values of fixed length, thereby capturing the structural and semantic features of each subsequence in the operator sequence.
[0064] It is understandable that since subsequences with the same content have the same hash fingerprint information, high-frequency repeating subsequences can be efficiently detected based on the hash fingerprint information of each subsequence.
[0065] In the embodiments described above, the repeating subsequence may include multiple subsequences to be folded that have the same hash fingerprint information. In particular, the repeating subsequence may be multiple operator sequences with the same hash fingerprint information identified after hash fingerprint comparison in the operator sequences to be processed, used to characterize recurring local computation patterns in the deep learning model.
[0066] It is understandable that the repeated subsequences appear more than or equal to 2 times in the operator sequence to be processed. Furthermore, since the operator sequence to be processed includes operator sequences corresponding to multiple deep learning models, the repeated subsequences can represent the local computational patterns that exist between the multiple deep learning models.
[0067] Taking the operator sequence to be processed as an example, which is obtained by concatenating the operator sequences corresponding to the three deep learning models respectively, the three operator sequences are [A, B, C, D, E], [A, C, D, E, F], and [A, E, F, G].
[0068] The above-described implementation method performs convolutional hash fingerprint calculation on the operator sequences to be processed, thereby obtaining hash fingerprint information corresponding to each different subsequence. Based on the comparison of each hash fingerprint, it can be determined that in the above operator sequences to be processed, subsequence [C, D] appears twice, subsequence [D, E] appears twice, and subsequence [E, F] appears twice, indicating that at least three local computation modes are included in the three different deep learning models.
[0069] The following provides a further explanation of the recursive folding process described above. It can be understood that the recursive folding operation can be a bottom-up or iterative sequence transformation operation. By describing the detected repeating subsequences as single abstract nodes or composite operators, the sequence structure of the operator sequence to be processed is gradually compressed to discover higher-level computational patterns.
[0070] In the above recursive folding process, the first round can fold at least one repeating subsequence in the operator sequence to be processed based on the hash fingerprint information.
[0071] Next, in the subsequent processing, the object processed in each round is the candidate operator sequence obtained from the previous round of folding. At least one repeated subsequence included in the candidate operator sequence obtained from the previous round of folding is further folded to obtain the candidate operator sequence corresponding to the current round.
[0072] Furthermore, based on the folding process of multiple rounds, candidate operator sequences corresponding to each round can be obtained, namely, the multiple candidate operator sequences in the above implementation.
[0073] When multiple candidate operator sequences are obtained, each candidate operator sequence carries the folding information of the corresponding repeating subsequence, since each candidate operator sequence is the product of the previous round of folding operation on the candidate operator sequence.
[0074] Furthermore, multiple splitting positions can be determined based on the sequence boundary information of multiple repeating subsequences, and subgraph splitting operations can be performed on the corresponding computation graph based on the splitting positions to obtain multiple computation subgraphs.
[0075] It is understandable that the above computational subgraph is a part of the computational graph corresponding to the deep learning model. It is an intermediate granularity test unit with semantic integrity that is automatically extracted from massive models between the whole network and a single operator. In this way, the computational subgraph can represent the model functional block composed of multiple operators in the deep learning model.
[0076] By converting the computation graph into a sequence of operators to be processed, treating this sequence as a formal language, and determining the hash fingerprint information of each subsequence within the sequence, we can efficiently detect frequently repeating subsequences based on the hash fingerprint information of each subsequence, since subsequences with identical content have the same hash fingerprint information. Furthermore, we recursively fold the repeating subsequences. Through this progressive approach, we can discover multi-level repeating structures from basic operator combinations to computational modules, overcoming the window length limitation of single detection and enabling higher-level combination operator patterns. This allows us to efficiently summarize frequently occurring structured subgraph patterns from a large number of models and generate splitting points, thus generating high-quality computational subgraphs based on the computation graph and reducing computational complexity.
[0077] In a relevant example, in the compiler of a deep learning model, predefined operator combination patterns can be pre-built in, and then accurate pattern matching can be performed on the computation graph to identify the matched operator combinations as fusionable subgraphs.
[0078] However, rule-based methods can identify fixed patterns predefined by domain experts. When new computational patterns emerge, their structure needs to be manually analyzed and new matching rules need to be written to include them in the extraction scope, a process that is time-consuming and difficult to scale.
[0079] In another related example, the computation graph of a deep learning model is treated as a general graph structure. A graph partitioning algorithm is used to divide the computation graph into several subgraphs with the optimization objective of minimizing the number of edge cuts (i.e., data communication volume) between subgraphs.
[0080] However, deep learning models are inherently hierarchical, and the graph-based partitioning methods mentioned above, which aim to minimize communication overhead, typically produce partitions that lack semantic meaning and cannot accurately describe deep learning models.
[0081] Through the above-described embodiments of this disclosure, on the one hand, in the process of analyzing newly emerging deep learning models and their computational models, there is no need to predefine operator combination rules. Instead, processing and analysis can be performed directly based on the sequences of operators to be processed corresponding to a large number of deep learning models, efficiently identifying the newly added computational patterns contained therein. On the other hand, the above-described recursive folding operation can be folded according to the recurrence of repeated subsequences. Thus, the semantic structure in the deep learning model can be represented by the folding and referencing relationships between repeated subsequences in different rounds, achieving an accurate representation of the hierarchical relationships such as functional blocks in the deep learning model.
[0082] The following further describes the method for determining the sequence of operators to be processed in the embodiments of this disclosure. According to the embodiments of this disclosure, determining the above-mentioned sequence of operators to be processed may include: encoding multiple operators extracted from multiple computation graphs to obtain encoding results, wherein the subsequence to be folded includes the encoding results of multiple operators. The encoding results are then concatenated to obtain the sequence of operators to be processed.
[0083] In the above embodiments of this disclosure, the sequence of operators to be processed can be further characterized as the concatenation result of the encoding results of multiple operators.
[0084] It is understandable that before performing subgraph analysis on a large number of deep learning models, each deep learning model may include a variety of different operators. In order to distinguish and represent these different types of operators, each operator is encoded separately, which facilitates subsequent implementations in determining the unique representation result of the operator and performing subsequent processing operations based on the encoding result.
[0085] For example, after determining the encoding results of each of the above operators, the encoding results can be concatenated based on the topological sorting results among the operators in the deep learning model, thereby obtaining the encoding result sequence corresponding to the deep learning model.
[0086] Furthermore, the encoding result sequences corresponding to each deep learning model can be concatenated to obtain the above-mentioned sequence of operators to be processed.
[0087] Through the above-described embodiments of this disclosure, operators can be uniquely represented based on the encoding results of each operator, and then the above-described sequence of operators to be processed can be spliced together to ensure accurate representation of operators and data dependencies in each deep learning model, thereby improving the accuracy of subsequent recursive folding operations.
[0088] According to some embodiments of this disclosure, the above-described encoding of multiple operators extracted from multiple computation graphs includes: determining the operator identifier of each operator from a pre-stored operator vocabulary based on the operator type of each operator among the multiple operators, and using it as the encoding result of the operator.
[0089] In the above embodiments of this disclosure, the operator identifier of each operator can be determined by pre-stored operator vocabulary, and then the encoding result of the operator can be determined.
[0090] It is understandable that the above operator vocabulary indicates the mapping relationship between multiple candidate operator types and operator identifiers.
[0091] The operator type indicates the operational function of the operator. For example, the Conv2D operator type can be used to indicate a two-dimensional convolution operation, the BN (BatchNorm) operator type can be used to indicate a batch normalization operation, and the ReLU operator type can be used to indicate an activation operation. The above operator types are merely illustrative examples and do not limit the specific operators and operator types involved in the embodiments of this disclosure.
[0092] In some optional implementations, before each execution of the computation graph processing flow, the above operator vocabulary can be updated based on multiple deep learning models in the current batch.
[0093] For example, it is possible to iterate through multiple operators included in multiple deep learning models in the current batch and perform a query operation in the operator vocabulary based on the operator type of each operator. If an operator type not included in the operator vocabulary is detected, a corresponding candidate operator type and operator identifier are created in the operator vocabulary based on that operator type, and then the above operator encoding operation is performed based on the updated operator vocabulary.
[0094] Through the above embodiments of this disclosure, the operator identifiers corresponding to each of the multiple operators included in multiple deep learning models can be quickly determined based on a dynamically updated operator vocabulary. Then, based on the concatenation result of the operator identifiers, the sequence of operators to be processed corresponding to multiple deep learning models can be quickly determined, thereby improving coding efficiency.
[0095] In some alternative implementations, during the process of determining the sequence of operators to be processed, separators can be added between the various computation graphs to clarify the division range of the computation subgraphs.
[0096] Optionally, concatenating the encoded results may include: concatenating the operator identifiers of operators in each computation graph based on the data dependencies between operators in each computation graph, resulting in multiple sequences of operator identifiers; generating delimiters for each computation graph, the delimiters indicating the positions of operators belonging to each computation graph in the sequence of operators to be processed; and concatenating the multiple sequences of operator identifiers using the multiple delimiters to obtain the sequence of operators to be processed.
[0097] It is understood that in the embodiments of this disclosure, each computation graph corresponds to a deep learning model, and correspondingly, the computation subgraph determined by the above embodiments also represents a combination of operators or operator patterns within a deep learning model.
[0098] Therefore, in the above embodiments of this disclosure, in order to avoid erroneously detecting computational subgraphs across adjacent computational graphs, during the construction of the operator sequence to be processed, a separator can be added between the operator identifier sequences corresponding to each deep learning model to characterize the independent relationship between each operator identifier sequence, thereby more accurately positioning the analysis scope of the computational subgraph to the interior of each computational graph.
[0099] In some alternative implementations, the separators between the sequences of operator identifiers may use the same symbol to characterize the independent positional relationship between the sequences of operator identifiers.
[0100] In some alternative implementations, the separators between the sequences of operator identifiers may be identified by an incrementing symbol to distinguish the sequences of operator identifiers while also representing their order.
[0101] In the embodiments of this disclosure, the delimiter can be distinguished from the operator identifier. Besides the distinction based on identifier content, it can also be distinguished based on the object of the recursive folding operation. In other words, during the recursive folding operation, the object of the folding operation can be the operator identifier or other identifiers that reference the operator identifier, while the delimiter may not be an object of the folding operation. That is, the delimiter can be an independent symbol that is not folded during the recursive folding process, but does not interfere with the operator folding within each deep learning model.
[0102] The following combination Figure 4 The construction process of a sequence of operators to be processed is described.
[0103] In the embodiments of this disclosure, the operator memory included in multiple deep learning models can be normalized first, and then the operator information in multiple deep learning models can be converted into a one-dimensional symbol sequence suitable for operator analysis.
[0104] First, the computation graphs corresponding to multiple deep learning models can be topologically sorted to obtain the operator type sequence for each deep learning model. .
[0105] like Figure 4 As shown, the first computation graph G1 corresponding to the first deep learning model can be transformed into a sequence of operator types through a topological sorting operation. The second computation graph G2 corresponding to the second deep learning model can be converted into an operator type sequence through topological sorting. The third computation graph G3 corresponding to the third deep learning model can be converted into an operator type sequence through topological sorting. .
[0106] Next, based on the pre-constructed operator lexicon, the above operator type sequences are converted into their corresponding operator identifier sequences. In this embodiment, the operator lexicon traverses all operator types appearing in the input model, assigning a unique incrementing integer identifier to each operator type to form a mapping. This mapping ensures that operators with the same function in different models have consistent numerical representations, providing a unified basis for subsequent hash calculations and pattern comparisons.
[0107] After encoding, the operator sequence of each model is converted from the operator type sequence into the operator identifier sequence. .
[0108] like Figure 4 As shown, taking uppercase English characters to represent incrementing integer identifiers as an example, based on a pre-built operator lexicon, we can... Convert to the corresponding operator identifier sequence ,Will Convert to the corresponding operator identifier sequence ,Will Convert to the corresponding operator identifier sequence .
[0109] Furthermore, the encoding sequences of multiple models can be concatenated into a global sequence as the sequence of operators to be processed.
[0110] During concatenation, special delimiters are inserted between the operator identifier sequences corresponding to adjacent models. In this embodiment, a unique delimiter can be assigned to each model to ensure that subsequent pattern matching does not cross the boundaries of different models. If the input consists of M computation graphs corresponding to each model, containing a total of N operators, then the length of the unified encoded token sequence is L = N + M - 1.
[0111] like Figure 4 As shown, after determining the operator identifier sequences corresponding to the three models, the sequence of operators to be processed can be obtained by concatenation. The separators between the operator identifier sequences can be different identifiers to represent the positions of the operator identifier sequences corresponding to each model.
[0112] Through the above-described embodiments of this disclosure, the operator identifier sequences corresponding to multiple deep learning models are concatenated, so that a single pattern mining can cover multiple models, thereby achieving efficient discovery of high-frequency computing patterns across models and tasks, and improving the efficiency of splitting and recognizing computing subgraphs.
[0113] The following provides a further explanation of the process of calculating convolutional hash fingerprints in the embodiments of this disclosure.
[0114] In some optional implementations, performing convolutional hash fingerprint calculation on the operator sequence to be processed to obtain the hash fingerprint information of each subsequence in the operator sequence to be processed may include: mapping each operator identifier in the operator sequence to be processed to a random feature space to obtain the random features of each operator identifier; performing sliding window convolution operation on the random features to generate the convolution result of each subsequence in the operator sequence to be processed; and determining the hash fingerprint information of each subsequence based on the convolution result of each subsequence.
[0115] In the embodiments of this disclosure, when the sequence of operators to be processed is obtained through the aforementioned embodiments, in order to avoid directly performing matching operations on discrete operator identifiers, each operator identifier in the sequence of operators to be processed can be mapped to a random feature space first, and then the subsequent convolutional hash fingerprint operation can be performed based on the random features obtained after mapping.
[0116] Specifically, this can be achieved by constructing an embedding matrix. Implement random mapping of operator identifiers, where S is the operator vocabulary size and D is the random feature dimension.
[0117] For an input operator identifier sequence T, it is mapped to a D-dimensional embedded feature vector through index lookup. ,get This transforms discrete operator identifiers into continuous numerical representations, providing a numerical basis for subsequent convolutional hash fingerprint calculations.
[0118] It should be noted that the embedding dimension D serves to provide a distinguishable numerical identifier for different operator identifiers. In some alternative implementations, fingerprint distinguishability can be guaranteed by the randomness of the convolution kernel, thus D can be chosen with a small value (e.g., D=2) to achieve an extremely low collision probability.
[0119] In some alternative implementations, the above-described embedding matrix It can be created through uniform random initialization. Specifically, the matrix elements can be generated from a uniform distribution. We sampled from the middle and used a fixed random seed to ensure that the results were reproducible.
[0120] In some alternative implementations, the above-described embedding matrix Pre-training initialization based on historical data is possible. For example, a large amount of existing model operator sequence data can be used to pre-train the embedding matrix through contextual co-occurrence relationships, enabling it to capture the actual semantic associations between operators. Through this implementation, frequently co-occurring operator combinations (such as Conv2d and BatchNorm2d) have more similar representations in the embedding space. This implementation also allows pre-trained embeddings to generate more similar convolutional fingerprint values for semantically similar subsequences, improving the sensitivity of subsequent pattern discovery to structured patterns.
[0121] In embodiments of this disclosure, performing sliding window convolution on random features to generate convolution results for each subsequence may include: performing sliding window convolution on random features using one-dimensional convolution to generate convolution results for each subsequence. The length of each subsequence is greater than or equal to 1 and less than or equal to the length of the sliding window, and the weight matrix used for the one-dimensional convolution is an upper triangular random matrix.
[0122] The above method of determining the hash fingerprint information of each subsequence based on the convolution results of each subsequence may include: converting the convolution results of each subsequence into integers as the hash fingerprint information of each subsequence.
[0123] In embodiments of this disclosure, based on the embedded sequence composed of random features determined through the above embodiments, a hash fingerprint value can be further calculated for each position and each candidate length of the subsequence. Subsequences with identical content can generate the same fingerprint.
[0124] In the embodiments of this disclosure, an upper triangular convolution kernel can be used to simultaneously complete the detection window of length 1 to the maximum detection window in a single one-dimensional convolution operation. Calculate the hash fingerprint of all subsequences.
[0125] In particular, one-dimensional convolution can be used to perform sliding window aggregation on random feature sequences to generate hash fingerprints of subsequences of different lengths.
[0126] To ensure that subsequent convolution calculations can generate lengths of [length value] at all positions. Window hashing can be achieved by first padding the random feature sequence with zeros to obtain... Then, the input dimension is transformed into a tensor variable. Batch size Number of input channels Sequence length .
[0127] In this embodiment of the disclosure, the convolution weights can be defined as follows: ,Right now , , The above convolution weight tensor It can be constructed in two steps:
[0128] S1, construct a size of A random matrix is generated, and a lower triangular random matrix is formed by preserving the lower triangular region;
[0129] S2, copy the lower triangular weight matrix along the feature dimension. Next, we obtain the convolution weight tensor. .
[0130] In embodiments of this disclosure, the convolution operation can be defined as follows: , get output Among them, the output Indicated by position For the starting point and length The sliding window hash value of the operator identifier subsequence. Its calculation process can be described as follows:
[0131]
[0132] Due to the convolution weight matrix Using an upper triangular structure, the first Line only for the first The position has a non-zero weight, therefore the position has a non-zero weight. Each output channel can aggregate length The prefix pattern allows for the simultaneous generation of hash fingerprints for subsequences of different lengths in a single convolution operation. By linearly combining local window features with random weights, the same token pattern can produce consistent hash results, while different patterns have a low probability of hash collisions, thus achieving efficient detection of high-frequency repeating subsequences.
[0133] In this embodiment of the disclosure, the result of the sliding window convolution operation can be output as a 64-bit floating-point number, and its binary representation can be directly reinterpreted as a 64-bit integer as the final fingerprint value. This transforms the subsequence matching problem into an efficient integer equality determination problem, eliminating the need for additional hash function calculations and improving the matching efficiency in the subsequent recursive folding operation.
[0134] Through the above-described embodiments of this disclosure, discrete operator identifiers are mapped to a continuous vector space by random embedding, and then an upper triangular one-dimensional convolution kernel is used to generate hash fingerprint information of subsequences of various lengths in parallel in a single convolution operation. This transforms the subsequence pattern matching problem into an integer equality determination and frequency statistics problem, thereby achieving efficient repeating pattern detection.
[0135] The recursive folding process in the embodiments of this disclosure will be further described below.
[0136] In this embodiment of the disclosure, the above-mentioned recursive folding of repeated subsequences in the operator sequence to be processed based on hash fingerprint information to obtain multiple candidate operator sequences may include: assigning a sequence identifier to the subsequence to be folded to obtain the candidate operator sequence.
[0137] In embodiments of this disclosure, when a subsequence to be folded is identified, a sequence identifier can be assigned to the subsequence to be folded, and then the subsequence can participate in the next round of folding operations based on the sequence identifier.
[0138] It should be noted that, in the embodiments of this disclosure, the object of the first round of folding operation is the sequence of operators to be processed. Then, when the sequence identifier assigned to the sequence of operators to be processed is obtained, the multiple operator identifiers corresponding to the sequence of operators to be processed can be characterized by the above sequence identifier, thereby forming a candidate operator sequence corresponding to the first round of folding operation.
[0139] In the second round of folding operations, and in subsequent folding operations, the operation object is the candidate operator sequence obtained from the previous round of folding operations. This sequence can include not only operator identifiers but also sequence identifiers. Then, in subsequent folding operations, upon obtaining the sequence identifiers assigned to the operator sequence to be processed, the multiple operator identifiers and / or combinations of sequence identifiers corresponding to the operator sequence to be processed are characterized using these sequence identifiers, thereby forming the candidate operator sequence corresponding to the subsequent rounds of folding operations.
[0140] By assigning sequence identifiers to the identified subsequences to be folded, the nesting relationships of multi-level operator combinations and functional block combinations in the operator sequence to be processed can be efficiently discovered, thereby improving the efficiency of discovery and identification of computational subgraphs.
[0141] The following provides a further explanation of the specific process of recursive folding in the embodiments of this disclosure. Assigning the sequence identifier to the subsequence to be folded to obtain the candidate operator sequence can include the following operations.
[0142] During the first round of folding operations, a first sequence identifier can be assigned to the subsequence to be folded in the sequence of operators to be processed, and the first sequence identifier is assigned to the subsequence to be folded in the sequence of operators to be processed, thus obtaining the first candidate operator sequence.
[0143] During the second round of folding operations, a second sequence identifier can be assigned to the subsequence to be folded in the first candidate operator sequence, and the second sequence identifier can be assigned to the subsequence to be folded in the first candidate operator sequence to obtain the second candidate operator sequence.
[0144] Similarly, in the (n+1)th round of folding operation, the (n+1)th sequence identifier is assigned to the subsequence to be folded in the nth candidate operator sequence, and the (n+1)th sequence identifier is assigned to the subsequence to be folded in the nth candidate operator sequence to obtain the (n+1)th candidate operator sequence.
[0145] If there are no more repeated subsequences appearing more than twice in the current candidate operator sequence, then the preset maximum number of folding rounds can be determined.
[0146] In some optional implementations, after obtaining the candidate operator sequence for each round through the aforementioned folding operations, the convolutional hash fingerprint information corresponding to the current round can be further obtained based on the convolutional hash fingerprint operation described in the previous implementations. Then, the subsequence to be folded in the candidate operator sequence is determined based on the convolutional hash fingerprint information, and the next round of folding operations is performed. The following combines... Figure 5 An optional two-round folding operation procedure is described.
[0147] like Figure 5 In the process of performing preprocessing operations on three deep learning models to obtain a sequence of operators to be processed 500, the first subsequence to be folded, [B, C, D], can be identified from the sequence of operators to be processed 500 based on its hash fingerprint information. Here, B serves as an operator identifier to represent the Conc2d operator, C serves as an operator identifier to represent the BatchNorm operator, and D serves as an operator identifier to represent the ReLU operator.
[0148] Then, the first subsequence to be folded 502 can be assigned a sequence identifier S1, and the first subsequence to be folded 502 can be characterized based on S1 to complete the first round of folding and obtain the first candidate operator sequence 504.
[0149] Next, based on the hash fingerprint information of the first candidate operator sequence 504, the second subsequence to be folded, 506, namely [S1, E], can be identified from the first candidate operator sequence 504. Here, S1, as a sequence identifier, can be used to represent the aforementioned first subsequence to be folded 502, and E, as an operator identifier, can be used to represent the Add operator.
[0150] Then, the second subsequence to be folded 506 can be assigned a sequence identifier S2, and the second subsequence to be folded 506 can be characterized based on S2 to complete the second round of folding and obtain the second candidate operator sequence 508.
[0151] It is understood that the above recursive folding operation process is only an illustrative example. In practical applications, the number of deep learning models involved, as well as the scale of the types of operators included in the deep learning models, are usually very large. In order to further improve the analysis efficiency, the subsequence to be folded can be determined from the repeating subsequence according to certain principles.
[0152] In some optional implementations, each round of the recursive folding operation can fold each identified repeating subsequence, or it can fold repeating subsequences that meet certain conditions. These conditions may include, but are not limited to, one or more of the following: the number of repetitions, the number of operators included in the repeating subsequence, and the type of operator.
[0153] When the above condition is a repetition count condition, the above repetitive subsequence can be determined as the operation object for the current round of folding operation if the number of times it appears in the operator sequence to be processed or the candidate operator sequence is greater than or equal to the quantity threshold.
[0154] Optionally, when the above quantity threshold is a fixed value, the above quantity threshold can be a value matched according to the length of the operator sequence to be processed. In particular, the above quantity threshold and the length of the operator sequence to be processed can have a positive correlation, that is, the longer the length of the operator sequence to be processed, the larger the value of the above quantity threshold.
[0155] In other words, when processing a large number of operator sequences corresponding to deep learning models, the number threshold is increased to prioritize the processing of a large number of repetitive subsequences.
[0156] In the above embodiments, the length of the operator sequence to be processed can be determined based on the number of operators included in the operator sequence to be processed, or it can be determined based on the number of deep learning models corresponding to the operator sequence to be processed.
[0157] Optionally, when the aforementioned quantity threshold is a variable value, the quantity threshold can be determined based on the current round of the recursive folding operation. That is, before each round of folding operations, the aforementioned quantity condition needs to be determined based on the value of the current round. In particular, there is a negative correlation between the aforementioned quantity threshold and the value of the aforementioned round; that is, the larger the value of the current round of the recursive folding operation, the smaller the value of the aforementioned quantity threshold.
[0158] Optionally, when the aforementioned quantity threshold is a variable value, it can be determined based on the length of the candidate operator sequence to be processed in the current round. That is, before each folding operation, the quantity condition can be determined based on the length of the candidate operator sequence obtained in the previous round, i.e., the candidate operator sequence to be processed in the current round. Specifically, there is a positive correlation between the aforementioned quantity threshold and the length of the candidate operator sequence to be processed in the current round. Since the recursive folding operation gradually reduces the length of the candidate operator sequence, the value of the aforementioned quantity threshold decreases accordingly.
[0159] In other words, during the recursive folding process of the operator sequence to be processed, a larger quantity threshold is set in the first few recursive rounds to prioritize the processing of repetitive subsequences with a large number of repetitions; as the number of recursive rounds increases, the quantity threshold is reduced accordingly to improve the detection sensitivity of higher-level computational patterns.
[0160] Optionally, when the above quantity threshold is a variable value, the above quantity threshold can be determined based on the operation round of the current recursive folding operation, and the initial value of the above quantity threshold can be determined based on the length of the operator sequence to be processed.
[0161] That is, before performing recursive folding, the initial number threshold of the first round of folding operations is determined based on the length of the operator sequence to be processed. The initial number threshold can be positively correlated with the length of the operator sequence to be processed.
[0162] Next, before each subsequent folding operation, the quantity condition corresponding to the current folding operation needs to be determined by combining the value of the current round and the aforementioned initial quantity threshold. In particular, there is a negative correlation between the aforementioned quantity threshold and the value of the operation round; that is, the larger the value of the operation round, the smaller the quantity threshold will be.
[0163] Through the above-described embodiments of this disclosure, on the one hand, during the folding operation of a large number of deep learning models corresponding to the operator sequences to be processed, the corresponding conditions of the folding operation can be flexibly configured according to the scale of the corresponding deep learning models; on the other hand, during the recursive folding operation, the corresponding conditions of each round of folding operation can be adaptively adjusted according to the recursion progress, thereby flexibly adjusting the detection sensitivity of repeated subsequences according to the scale of the operator sequences to be processed and the progress of recursive folding, improving the folding efficiency of repeated subsequences, and thus improving the detection efficiency of the computational mode.
[0164] In addition to determining the subsequence to be folded from the repeating subsequence according to the quantity constraints described in the previous embodiments, the subsequence to be folded can also be determined from repeating subsequences that satisfy multiple combinations of conditions before performing the folding operation.
[0165] Specifically, after obtaining the candidate operator sequence obtained from the previous round of folding processing, based on the convolutional hash fingerprint information described in the above implementation, i.e., after determining all the subsequence fingerprint information in the above candidate operator sequence, all fingerprints can be organized into (pattern length, fingerprint value) tuples and the frequency of occurrence of each tuple can be counted. If the fingerprints are the same, it means that the corresponding subsequence content is the same. If they appear multiple times, they form a repeating pattern, i.e., the subsequence to be folded.
[0166] In some alternative implementations, the goal can be to maximize compression in each round, taking into account both the length of the subsequence to be folded and its frequency of occurrence, and prioritizing the repetitive subsequence with the largest total shortening of the replaced sequence as the subsequence to be folded.
[0167] In some alternative implementations, a longest-first strategy can be adopted, which prioritizes the longest subsequence among all repeating subsequences as the subsequence to be folded, thereby discovering repeating patterns at a larger granularity.
[0168] The above-described embodiments of this disclosure overcome the window length limitation of single-round detection. In the above embodiments, single-round convolutional hash fingerprinting can detect repeating subsequences within a maximum window k. Recursive folding compresses the discovered repeating subsequences into a single symbol, and the originally longer repeating subsequences that exceed the window become detectable short sequences in subsequent rounds. For example, when the window size k=3, the pattern [A,B,C,D] of length 4 cannot be discovered in a single round, but after folding [A, B,C] into symbol S1 in the first round, the equivalent representation [S1,D] can be discovered in the second round.
[0169] Furthermore, in the above embodiments, each round of replacing and shortening the sequence may cause previously separated elements to become adjacent, thereby forming new foldable patterns in subsequent rounds. For example, in Figure 5In the illustrated implementation, after the first round discovers [Conv2d,BatchNorm2d,ReLU] and replaces it with S1, the second round may discover a larger-granularity composite structure such as [S1, Add] and [S1, Add, S1]. Through this progressive approach, multi-level repetitive structures, from basic operator combinations to conformal computation modules, can be detected from the bottom up.
[0170] The following provides a further explanation of the method for determining multiple splitting positions based on multiple candidate operator sequences in the embodiments of this disclosure.
[0171] In this embodiment of the disclosure, when multiple candidate operator sequences are obtained according to the relevant embodiments, since each candidate operator sequence can be composed of multiple operator identifiers and sequence identifiers, the positions between various identifiers, including the aforementioned operator identifiers and sequence identifiers, can be used as splitting positions.
[0172] It is understandable that the above splitting positions can include the following situations.
[0173] Case 1: The positions between adjacent operator identifiers in the candidate operator sequence represent the data dependency between two model operators. Splitting at these positions allows the two model operators to be extracted separately as independent computing nodes for deployment and execution.
[0174] Scenario 2: The positions between adjacent operator identifiers and sequence identifiers in the candidate operator sequence represent the data dependency relationship between a model operator and a functional module. The model module includes multiple combined model operators. By splitting at this position, the model operator and the functional module can be extracted separately as independent execution units for deployment and execution.
[0175] Case 3: The positions between adjacent sequence identifiers in the candidate operator sequence represent the data dependency between two functional modules. Splitting at these positions allows the two model functional modules to be extracted as separate functional units.
[0176] In some alternative implementations, the splitting position can be determined based on multiple candidate operator sequences. The following uses... Figure 5 The method for determining the splitting position is illustrated by taking the first candidate operator sequence 504 and the second candidate operator sequence 508 obtained from the two rounds of folding operations shown in the figure.
[0177] In this embodiment of the disclosure, multiple splitting positions can be determined simultaneously based on the first candidate operator sequence 504 and the second candidate operator sequence 508.
[0178] For example, the position between the three identifiers A, S1, and E in the first candidate operator sequence 504 can be determined as the splitting position, thereby obtaining the sequence identifier S1, and the combination of operator identifiers [B,C,D] indicated by the sequence identifier S1 can be deployed and described as an independent functional unit.
[0179] Meanwhile, the position between operator identifier A and sequence identifier S2 in the second candidate operator sequence 508 can be determined as the splitting position, thereby obtaining the sequence identifier S2, and deploying and describing the operator identifier combination [B,C,D,E] indicated by the sequence identifier S2 as an independent functional unit.
[0180] In some alternative implementations, the splitting position can be determined based on the target operator sequence determined from multiple candidate operator sequences.
[0181] Optionally, the above method of determining multiple splitting positions based on multiple candidate operator sequences may include: determining a target operator sequence from multiple candidate operator sequences according to the operator quantity constraint of the computational subgraph; splitting the target operator sequence using delimiters in the target operator sequence to obtain target subsequences for each computational graph, wherein the delimiters are used to indicate the positions of operators belonging to each computational graph in the operator sequence to be processed; and using the start and end positions of the sequence identifiers in the target subsequences as the splitting positions of the corresponding computational graphs.
[0182] In the embodiments of this disclosure, a target operator sequence that meets the conditions can be determined from multiple candidate operator sequences, and the parts of the target operator sequence belonging to different computation graphs can be determined based on the delimiter, and the corresponding splitting position can be determined based on each computation graph.
[0183] It is understood that, in the embodiments of this disclosure, the aforementioned delimiter may be an identifier pre-inserted during the encoding of the sequence of operators to be processed, used to characterize the respective boundary positions of the computational graphs of each deep learning model. This identifier may not participate in the hash fingerprint calculation and recursive folding process, but is only used to identify boundary information.
[0184] Furthermore, given the target operator sequence, each computation graph can be determined based on the boundary information indicated by the aforementioned separators, and each target subsequence can be determined within the computation graph.
[0185] Continue with Figure 5The method for determining the splitting position described above will be explained using an example. In this embodiment, the second candidate operator sequence 508 can be used as the target operator sequence, and the start and end positions of the sequence identifiers in the target operator sequence can be used as the splitting positions to obtain identifiers S2 and S1. Therefore, the operator identifier combination [B,C,D] indicated by sequence identifier S1 and the operator identifier combination [B,C,D,E] indicated by S2 can be deployed and described as independent functional units.
[0186] In some alternative implementations, the splitting position can be determined according to certain conditions.
[0187] For example, selection can be based on the number of nodes. That is, multiple candidate splitting positions can be determined through the relevant embodiments of this disclosure. For example, the positions between all identifiers in multiple candidate operator sequences can be determined as candidate splitting positions. Or, the positions between all identifiers in the target operator sequence determined based on multiple candidate operator sequences can be determined as candidate splitting positions, and then the target splitting position can be determined based on the number of operators included in the split subsequence.
[0188] It is understood that the multiple candidate operator sequences obtained through the recursive folding operation in the embodiments of this disclosure differ significantly in granularity of their hierarchical patterns. The sequence identifiers in the lower-level candidate operator sequences may only represent 2 to 3 operators, while the sequence identifiers in the higher-level candidate operator sequences may represent dozens of operators.
[0189] In this embodiment of the disclosure, an operator number constraint can be introduced to determine the subsequence whose number of included operators meets the number threshold range as the target subsequence, that is, to determine the final split position.
[0190] By using the above-mentioned quantity constraint method, large subgraph intervals exceeding the upper limit can be adaptively divided along the data flow direction to obtain sub-intervals of moderate size and improve the efficiency of subgraph representation.
[0191] In embodiments of this disclosure, the above-mentioned splitting of the computation graph based on multiple splitting positions to obtain multiple computation subgraphs may further include: extracting multiple non-overlapping regions from the computation graph based on the splitting positions as multiple computation subgraphs.
[0192] In embodiments of this disclosure, the overlap between subgraphs can also be used as a constraint condition for the splitting position. That is, a set of non-overlapping operators can be selected as the final segmentation result to ensure that each operator belongs to a subgraph interval, avoiding repetition or omission.
[0193] It is understandable that the above constraint methods can be combined to achieve the desired result. That is, among the splitting methods that satisfy the node constraints, a set of non-overlapping operators can be further selected to determine the extracted computational subgraph.
[0194] The following continues to combine Figure 5 The method for determining the splitting position and calculating the subgraph based on the above two constraint methods will be further explained.
[0195] In this embodiment of the disclosure, when the second candidate operator sequence 508 is used as the target operator sequence, the start and end positions of the sequence identifiers in the target operator sequence can be used as candidate splitting positions, and identifiers S2 and S1 can be obtained by splitting.
[0196] In this embodiment, the quantity constraint is that the number of operators is greater than 3 and less than or equal to 20. Based on this, the number of operators included in the operator identifier combination [B,C,D] indicated by sequence identifier S1 does not meet the quantity constraint, while the number of operators included in the operator identifier combination [B,C,D,E] indicated by S2 meets the quantity constraint.
[0197] Further, the overlap between the computational subgraph corresponding to the operator identifier combination [B,C,D,E] indicated by S2 and other subgraphs is examined. Since the current splitting method only yields one computational subgraph, it can be directly determined that the operator identifier combination [B,C,D,E] indicated by S2 satisfies the condition of non-overlapping.
[0198] In other cases, suppose we further split to obtain sequence identifier S3 ( Figure 5 (not shown in the image), and then it can be further detected whether there is an overlap between the computational subgraph corresponding to S3 and the computational subgraph corresponding to S2. If there is no overlap, the corresponding candidate split positions can be identified, and then the subgraphs corresponding to S2 and S3 can be determined as computational subgraphs that meet the conditions.
[0199] Through the above-described embodiments of this disclosure, when candidate splitting positions are determined, the target splitting position can be determined based on node number constraints and non-overlapping constraints, thereby obtaining the split computational subgraph to ensure the expressive efficiency of each extracted computational subgraph.
[0200] In some alternative implementations, after extracting the subgraphs in the manner described above, the following operations may be further performed: deduplicating the multiple computational subgraphs, assigning index identifiers to each subgraph in the deduplicated multiple subgraphs, and storing the multiple computational subgraphs based on the index identifiers.
[0201] The following combination Figure 6The above operations are explained in Table 1.
[0202] like Figure 6 As shown, after processing the original operator sequence through the above implementation method to obtain the target operator sequence [S4,S4,S1], and determining the subgraph corresponding to S4 as the extracted computational subgraph, it is possible to... Figure 6 The nested relationship shown is that sequence identifier S4 indicates the combination of sequence identifiers S1 and S2. Further, sequence identifier S1 indicates the combination of three operators: Conv2d, BatchNorm, and ReLU, and sequence identifier S2 indicates the combination of three operators: Linear and ReLU. This is recorded in the data form shown in Table 1 below.
[0203] Table 1 shows the symbols generated in each round of folding and their corresponding subsequence contents.
[0204] In this embodiment, after recursive folding operations, the output consists of two parts: a symbol definition list and a compressed main sequence. Table 1 above records the symbols generated in each round of folding and their corresponding subsequence contents; the main sequence is the final sequence after all rounds of replacement. Since the definitions of higher-level symbols can reference lower-level symbols, this representation naturally implies hierarchical referencing relationships, reflecting the nested structure between layers, functional blocks, and operator combinations in the deep learning model.
[0205] Furthermore, a unique identifier (uid) can be generated for each sequence based on the computational subgraph corresponding to Table 1, and the basic information can be recorded in the database for use by downstream tasks.
[0206] Through the above-described embodiments of this disclosure, by assigning corresponding index identifiers and corresponding reference relationship information to the computational subgraph, hierarchical reference relationships can be accurately represented, and the nested structure between layers, functional blocks, and operator combinations in the deep learning model can be accurately described, thereby extracting computational subgraphs that are more suitable for downstream use.
[0207] The following combination Figure 7 A complete computational graph processing flow of this disclosure is described.
[0208] like Figure 7 As shown, the computation graph processing flow 700 may include the following operations S710~S750.
[0209] Using the S710, obtain a set of deep learning models.
[0210] In the current step, the acquired deep learning models can be preprocessed into their respective computation graphs based on their respective computational modules and the data dependencies between them.
[0211] When operating the S720, operator sequences are extracted based on a set of deep learning models.
[0212] Traverse the computation graph of all input models, extract the operator identifier sequence of each model by topological sorting, and make the operator identifier sequence consistent with the data flow direction, so as to serve as the input for subsequent computation subgraph analysis.
[0213] In operation S730, the repeating subsequence is determined.
[0214] In the above steps, based on random projection convolutional hash fingerprints and recursive folding steps, the operator identifier sequences of multiple models can be concatenated and analyzed together to discover high-frequency repetitive subsequences shared across models.
[0215] When operating S740, extract the computation subgraph.
[0216] In the above steps, the target subsequences included in each model can be determined based on the hierarchical structure of the repeating subsequences and the constraints on the number of nodes, thereby determining the subgraph segmentation interval.
[0217] When operating the S750, standardize the deduplication process and store the deduplication data in the database.
[0218] In the steps described above, variables can be uniformly renamed according to the topological sorting of each computational subgraph, a standardized model code string can be constructed, and the SHA256 hash value can be calculated to achieve accurate deduplication of subgraphs with the same structure. Next, a unique identifier (uid) is generated for each subgraph sample, and the basic information is recorded in the database for use by downstream tasks.
[0219] The computational subgraph obtained through the above-described embodiments of this disclosure can be further applied to deep learning compilers, model optimization systems, and large-scale model data production platforms.
[0220] For example, a deep learning compiler test dataset with real workload characteristics can be constructed based on the extracted computational subgraph, which can be used for the correctness and performance verification of compiler optimization passes, and the verification of compatibility with new hardware backends.
[0221] For example, based on the above implementation methods, high-frequency operator combination patterns in real models can be automatically discovered and applied to the operator fusion benefit analysis and rule design of deep learning compilers.
[0222] For example, based on the extracted computational subgraphs, high-quality mid-training and post-training computational graphs and their optimized code datasets can be generated for training large models.
[0223] In one alternative implementation, the extracted computational subgraphs can be packaged into a subgraph dataset, which can then be used as fine-grained test cases for the compiler. These tests can be input into various deep learning compilers for performance and correctness evaluation, helping developers quickly pinpoint optimization bottlenecks in specific operator combinations.
[0224] Furthermore, the aforementioned computational subgraphs can also serve as input for fusionable subgraph analysis, further extracting subgraph structures with fusion potential to generate fusionable subgraph datasets, providing high-quality training and evaluation data for the operator fusion strategy learning of AI compiler agents.
[0225] In the above embodiments of this disclosure, by introducing convolutional hash fingerprints, the subsequence pattern matching problem is transformed into an integer equality determination and frequency statistics problem, thereby improving the detection efficiency of repeating subsequences. Furthermore, a recursive folding process is employed in the detection of repeating subsequences, gradually replacing high-frequency repeating subsequences with new sequence identifiers through multiple iterations, ultimately generating a hierarchical compressed representation. Finally, the compressed result is split back into each model based on the delimiter. Since the folding process is jointly executed on the concatenated sequence, repeating subsequences or operator combinations with the same structure in different models will be identified as the same symbol, thus providing a basis for pattern reuse across models.
[0226] Figure 8 A flowchart illustrating a model training method according to an embodiment of the present disclosure is shown schematically.
[0227] like Figure 8 As shown, the method includes operation S810.
[0228] When operating the S810, multiple computational subgraphs are used to train the compiler model to be trained, and the target compiler model is obtained.
[0229] In the above steps, the above-mentioned multiple computational subgraphs can be generated by the relevant methods provided in the embodiments of this disclosure.
[0230] Multiple computational subgraphs can be used as samples to input into the compilation model, and the sample computational subgraphs can be fused and compiled to obtain sample code.
[0231] Based on the sample code and sample computation subgraph, compilation analysis is performed to obtain sample analysis results.
[0232] Using the labels as reference answers, analyze the difference between the sample analysis results and the labels to obtain the loss value. Tune the compiled model based on the loss value. Repeat the above steps until the loss value converges. Use the model with converged loss value as the trained model.
[0233] In this disclosure, the model structure of the compiled model is not limited; for example, it may include a multimodal large model, a codec, or a graph convolutional network. Any structure suitable for fusion compilation is acceptable.
[0234] According to embodiments of this disclosure, when multiple computational subgraphs are extracted using the methods provided in these embodiments, further training the compiled model using the above methods can improve the efficiency and effectiveness of determining the gap between sample analysis results and labels, thereby improving model training efficiency.
[0235] Figure 9 A flowchart illustrating a compilation method according to an embodiment of the present disclosure is shown schematically.
[0236] like Figure 9 As shown, the method includes operation S910.
[0237] When operating the S910, the computation graph to be processed is input into the target compilation model to obtain the running code.
[0238] The target model is trained using the model training method provided in this embodiment.
[0239] By utilizing the compilation method provided in this embodiment, a target model with high compilation accuracy and effectiveness can be obtained through the above model training method, thereby making the compiled running code highly efficient and resource-efficient.
[0240] Figure 10 A block diagram of a computational graph processing apparatus according to an embodiment of the present disclosure is shown schematically.
[0241] like Figure 10 As shown, the computational graph processing device 1000 includes: a computation module 1010, a recursive folding module 1020, a determination module 1030, and a splitting module 1040.
[0242] The computation module 1010 is used to perform convolutional hash fingerprint calculation on the operator sequence to be processed, so as to obtain the hash fingerprint information of each subsequence in the operator sequence to be processed. The operator sequence to be processed is generated based on multiple computation graphs, which represent the operators of the deep learning model and the data dependencies between the operators.
[0243] The recursive folding module 1020 is used to recursively fold the repeated subsequences in the operator sequence to be processed based on the hash fingerprint information to obtain multiple candidate operator sequences. The repeated subsequences include multiple subsequences to be folded that have the same hash fingerprint information.
[0244] The determination module 1030 is used to determine multiple splitting positions based on multiple candidate operator sequences.
[0245] The splitting module 1040 is used to decompose the computation graph based on multiple splitting positions to obtain multiple computation subgraphs.
[0246] According to embodiments of this disclosure, the computation graph processing apparatus 1000 may further include: a preprocessing module, configured to encode multiple operators extracted from multiple computation graphs to obtain encoding results, wherein the subsequence to be folded includes the encoding results of multiple operators; and to concatenate the encoding results to obtain a sequence of operators to be processed.
[0247] According to embodiments of this disclosure, the preprocessing module may include: a mapping submodule, used to determine the operator identifier of each operator from a pre-stored operator vocabulary based on the operator type of each operator among multiple operators, as the encoding result of the operator, wherein the operator vocabulary indicates the mapping relationship between multiple candidate operator types and operator identifiers, and the operator type indicates the operation function of the operator.
[0248] According to embodiments of this disclosure, the preprocessing module includes: a splicing submodule, configured to splice the operator identifiers of operators in each computation graph based on the data dependencies between operators in each computation graph to obtain multiple operator identifier sequences, wherein the order of the multiple operators in the operator identifier sequence is the same as the operator execution order indicated by the computation graph; generate delimiters for each computation graph, the delimiters indicating the positions of operators belonging to each computation graph in the operator sequence to be processed, the delimiters being distinct from the operator identifiers; and splice the multiple operator identifier sequences using the multiple delimiters to obtain the operator sequence to be processed.
[0249] According to embodiments of this disclosure, the above-mentioned calculation module 1010 may include: a random mapping submodule, used to map each operator identifier in the operator sequence to be processed to a random feature space to obtain random features of each operator identifier, wherein the operator identifier indicates the operator type of the operator; a sliding window convolution submodule, used to perform sliding window convolution operation on the random features to generate the convolution result of each subsequence in the operator sequence to be processed; and a subsequence convolution submodule, used to determine the hash fingerprint information of each subsequence based on the convolution result of each subsequence respectively.
[0250] According to embodiments of this disclosure, the above-mentioned convolution submodule can be used to: perform sliding window convolution operation on random features using one-dimensional convolution to generate convolution results for each subsequence, wherein the length of the subsequence is greater than or equal to 1 and less than or equal to the length of the sliding window, and the weight matrix used in the one-dimensional convolution is an upper triangular random matrix; the above-mentioned subsequence convolution submodule is used to: convert the convolution results of each subsequence into integers respectively, as hash fingerprint information of each subsequence.
[0251] According to embodiments of this disclosure, the recursive folding module 1020 may include: an identifier allocation submodule, used to assign a sequence identifier to the subsequence to be folded to obtain a candidate operator sequence.
[0252] According to embodiments of this disclosure, the recursive folding module 1020 may include: a recursive processing submodule, configured to assign a first sequence identifier to a subsequence to be folded in a sequence of operators to be processed; assign the first sequence identifier to the subsequence to be folded in the sequence of operators to be processed, to obtain a first candidate operator sequence; assign a second sequence identifier to a subsequence to be folded in the first candidate operator sequence; assign the second sequence identifier to the subsequence to be folded in the first candidate operator sequence, to obtain a second candidate operator sequence; and so on; assign an (n+1)th sequence identifier to a subsequence to be folded in the nth candidate operator sequence; assign the (n+1)th sequence identifier to the subsequence to be folded in the nth candidate operator sequence, to obtain the (n+1)th candidate operator sequence; wherein n is an integer greater than or equal to 1.
[0253] According to an embodiment of this disclosure, the determination module 1030 may include: a constraint submodule, configured to determine a target operator sequence from multiple candidate operator sequences based on operator quantity constraints of the computation subgraph; split the target operator sequence using delimiters in the target operator sequence to obtain target subsequences for each computation graph, wherein the delimiters are used to indicate the positions of operators belonging to each computation graph in the operator sequence to be processed; and use the start and end positions of the sequence identifiers in the target subsequence as the splitting positions of the corresponding computation graphs.
[0254] According to embodiments of this disclosure, the aforementioned constraint submodule is used to extract multiple non-overlapping regions from the computation graph based on the splitting position, as multiple computation subgraphs.
[0255] According to embodiments of this disclosure, the computational graph processing apparatus 1000 may further include: a storage submodule, configured to deduplicate multiple computational subgraphs; assign an index identifier to each subgraph in the deduplicated multiple subgraphs; and store multiple computational subgraphs based on the index identifier.
[0256] Figure 11 A block diagram of a model training apparatus according to an embodiment of the present disclosure is shown schematically.
[0257] like Figure 11 As shown, the model training device 1100 includes: a training module 1110.
[0258] The training module 1110 is used to train the compilation model to be trained using multiple computational subgraphs to obtain the target compilation model; wherein the multiple computational subgraphs are obtained by the method of the above-described embodiments of this disclosure.
[0259] Figure 12 A block diagram of a compilation apparatus according to an embodiment of the present disclosure is shown schematically.
[0260] like Figure 12 As shown, the compilation device 1200 includes: a compilation module 1210.
[0261] The compilation module 1210 is used to input the computation graph to be processed into the target compilation model to obtain the running code; wherein, the target compilation model is trained by the method described above in this disclosure.
[0262] Figure 13 A schematic block diagram of a smart agent according to an embodiment of the present disclosure is shown.
[0263] In embodiments of this disclosure, such as Figure 13 As shown, the intelligent agent 1300 may include an input module 1310, a processing module 1320, and an output module 1330.
[0264] Input module 1310 is used to receive input information.
[0265] The processing module 1320 is used to determine the target task based on the input information received by the input module, determine the large model based on the target task, and obtain output information by calling the large model to execute the computation graph processing method provided in the embodiments of this disclosure, or by calling the large model to execute the sample generation method, model training method and compilation method provided in the embodiments of this disclosure.
[0266] Output module 1330 is used to output the output information obtained by the processing module.
[0267] According to embodiments of this disclosure, the input module 1310 is responsible for receiving or sensing information such as queries, requests, instructions, signals, or data from the outside world (e.g., users or the external environment), and converting it into a format that the intelligent agent 1300 can understand and process. The input module 1310 is the primary link for the intelligent agent 1300 to interact with the outside world, enabling the intelligent agent 1300 to efficiently and accurately obtain necessary "sensory" information from the outside world and respond to this information.
[0268] In the example, input module 1310 can input the deep learning model, labels, compiled model, computation graph to be processed, etc., as described above.
[0269] In the example, processing module 1320 is the core support for the ability of agent 1300 to handle complex tasks. Processing module 1320 can execute the computation graph processing methods, sample generation methods, model training methods, and compilation methods described above.
[0270] In the example, the performance of processing module 1320 can be closely related to the large model on which agent 1300 is based. To fully leverage the capabilities of the large model, the internal structure of processing module 1320 can be designed to be highly configurable and scalable to handle various types of tasks and requirements in real-world scenarios.
[0271] In the example, after the agent 1300 acquires the deep learning model, the processing module 1320 can use large model processing to extract subgraphs from the computation graph used to represent the deep learning model, obtain multiple computation subgraphs, fuse and compile the multiple computation subgraphs respectively to obtain multiple codes; and obtain analysis results based on the number of kernel functions in each code and the number of operators in each computation subgraph, and pass the analysis results to the output module 1330.
[0272] Understandably, while large models possess excellent language understanding and generation capabilities, like humans, their ability to solve tasks is limited without the aid of any tools. When Agent 1300 is given the ability to invoke tools, it can perform tasks such as using a calculator to perform mathematical calculations, using Python to perform data analysis, and using a search engine to create weather forecasts.
[0273] In the example, output module 1330 can output analysis results, target samples, training models, and running code.
[0274] The intelligent agent 1300 according to the embodiments of this disclosure can simply and effectively improve the level of intelligence, and enhance flexibility and versatility.
[0275] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0276] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method described above.
[0277] According to embodiments of the present disclosure, a non-transitory computer-readable storage medium stores computer instructions, wherein the computer instructions are used to cause a computer to perform the method described above.
[0278] According to an embodiment of this disclosure, a computer program product includes a computer program that, when executed by a processor, implements the method described above.
[0279] Figure 14A schematic block diagram of an example electronic device 1400 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0280] like Figure 14 As shown, device 1400 includes a computing unit 1401, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1402 or a computer program loaded from storage unit 1408 into random access memory (RAM) 1403. The RAM 1403 may also store various programs and data required for the operation of device 1400. The computing unit 1401, ROM 1402, and RAM 1403 are interconnected via bus 1404. Input / output (I / O) interface 1405 is also connected to bus 1404.
[0281] Multiple components in device 1400 are connected to input / output (I / O) interface 1405, including: input unit 1406, such as a keyboard, mouse, etc.; output unit 1407, such as various types of displays, speakers, etc.; storage unit 1408, such as a disk, optical disk, etc.; and communication unit 1409, such as a network card, modem, wireless transceiver, etc. Communication unit 1409 allows device 1400 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0282] The computing unit 1401 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1401 performs the various methods and processes described above, such as computational graph processing methods. For example, in some embodiments, the computational graph processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1408. In some embodiments, part or all of the computer program may be loaded and / or installed on device 1400 via ROM 1402 and / or communication unit 1409. When the computer program is loaded into RAM 1403 and executed by the computing unit 1401, one or more steps of the computational graph processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1401 may be configured to perform a computation graph processing method by any other suitable means (e.g., by means of firmware).
[0283] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0284] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0285] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0286] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0287] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0288] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, distributed system servers, or servers incorporating blockchain technology.
[0289] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0290] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A computational graph processing method, comprising: Convolutional hash fingerprint calculation is performed on the operator sequence to be processed to obtain the hash fingerprint information of each subsequence in the operator sequence to be processed. The operator sequence to be processed is generated based on multiple computation graphs, which represent the operators of the deep learning model and the data dependencies between the operators. Based on the hash fingerprint information, the repeated subsequences in the operator sequence to be processed are recursively folded to obtain multiple candidate operator sequences, wherein the repeated subsequences include multiple subsequences to be folded that have the same hash fingerprint information; Multiple splitting positions are determined based on multiple candidate operator sequences; and The computation graph is split based on the multiple splitting locations to obtain multiple computation subgraphs.
2. The method according to claim 1, further comprising: Encode multiple operators extracted from multiple computation graphs to obtain encoding results, wherein the subsequence to be folded includes the encoding results of multiple operators; as well as The encoded results are concatenated to obtain the sequence of operators to be processed.
3. The method according to claim 2, wherein, The encoding of multiple operators extracted from multiple computation graphs includes: Based on the operator type of each of the plurality of operators, the operator identifier of each operator is determined from a pre-stored operator vocabulary and used as the encoding result of the operator. The operator vocabulary indicates the mapping relationship between multiple candidate operator types and operator identifiers, and the operator type indicates the operation function of the operator.
4. The method according to claim 3, wherein, The concatenation of the encoded results includes: Based on the data dependencies between operators in each computation graph, the operator identifiers of the operators in each computation graph are concatenated to obtain multiple operator identifier sequences, wherein the order of the multiple operators in the operator identifier sequence is the same as the operator execution order indicated by the computation graph; Generate separators for each computation graph, the separators indicating the positions of operators belonging to each computation graph within the sequence of operators to be processed, the separators being distinct from the operator identifiers; and The sequence of multiple operator identifiers is concatenated using multiple delimiters to obtain the sequence of operators to be processed.
5. The method according to claim 1, wherein, The step of performing convolutional hash fingerprint calculation on the operator sequence to be processed to obtain the hash fingerprint information of each subsequence in the operator sequence to be processed includes: Each operator identifier in the sequence of operators to be processed is mapped to a random feature space to obtain the random features of each operator identifier, wherein the operator identifier indicates the operator type of the operator; Perform sliding window convolution operations on the random features to generate the convolution results of each subsequence in the operator sequence to be processed; and The hash fingerprint information of each subsequence is determined based on the convolution result of each subsequence.
6. The method according to claim 5, wherein, The step of performing a sliding window convolution operation on the random features to generate the convolution results of each subsequence includes: One-dimensional convolution is used to perform sliding window convolution operation on the random features to generate convolution results for each subsequence, wherein the length of the subsequence is greater than or equal to 1 and less than or equal to the length of the sliding window, and the weight matrix used in the one-dimensional convolution is an upper triangular random matrix. The process of determining the hash fingerprint information of each sub-sequence based on the convolution results of each sub-sequence includes: The convolution results of each subsequence are converted into integers and used as the hash fingerprint information of each subsequence.
7. The method according to claim 1, wherein, The recursive folding of repeated subsequences in the operator sequence to be processed based on the hash fingerprint information yields multiple candidate operator sequences, including: The sequence identifier assigned to the subsequence to be folded is given to the subsequence to be folded to obtain the candidate operator sequence.
8. The method according to claim 7, wherein, The step of assigning a sequence identifier to the subsequence to be folded to obtain the candidate operator sequence includes: Assign a first sequence identifier to the subsequence to be folded in the sequence of operators to be processed; The first sequence identifier is assigned to the folded subsequence in the operator sequence to be processed to obtain the first candidate operator sequence; Assign a second sequence identifier to the subsequence to be folded in the first candidate operator sequence; The second sequence identifier is assigned to the subsequence to be folded in the first candidate operator sequence to obtain the second candidate operator sequence; And so on; Assign an (n+1)th sequence identifier to the subsequence to be folded in the nth candidate operator sequence; Assign the (n+1)th sequence identifier to the subsequence to be folded in the nth candidate operator sequence to obtain the (n+1)th candidate operator sequence; Where n is an integer greater than or equal to 1.
9. The method according to claim 7, wherein, The determination of multiple splitting positions based on multiple candidate operator sequences includes: The target operator sequence is determined from multiple candidate operator sequences based on the operator number constraint of the computation subgraph; The target operator sequence is split using delimiters to obtain target subsequences for each computation graph. The delimiters indicate the positions of operators belonging to each computation graph within the sequence of operators to be processed. The start and end positions of the sequence identifiers in the target subsequence are used as the split positions of the corresponding computation graph.
10. The method according to claim 9, wherein, The computation graph is split based on the multiple splitting locations to obtain multiple computation subgraphs, including: Based on the splitting position, multiple non-overlapping regions are extracted from the computation graph to form the multiple computation subgraphs.
11. The method according to any one of claims 1 to 10, further comprising: The multiple computational subgraphs are deduplicated; Assign an index identifier to each subgraph in the deduplicated subgraphs; as well as The plurality of computational subgraphs are stored based on the index identifier.
12. A model training method, comprising: The target compilation model is obtained by training the training model using multiple computational subgraphs. The plurality of computational subgraphs are obtained by the method described in any one of claims 1 to 11.
13. A compilation method, comprising: The computation graph to be processed is input into the target compilation model to obtain the running code; The target compilation model is obtained by training using the method described in claim 12.
14. A computational graph processing apparatus, comprising: The computation module is used to perform convolutional hash fingerprint calculation on the operator sequence to be processed, and obtain the hash fingerprint information of each subsequence in the operator sequence to be processed. The operator sequence to be processed is generated based on multiple computation graphs, and the computation graphs represent the operators of the deep learning model and the data dependencies between the operators. A recursive folding module is used to recursively fold the repeated subsequences in the operator sequence to be processed based on the hash fingerprint information to obtain multiple candidate operator sequences, wherein the repeated subsequences include multiple subsequences to be folded that have the same hash fingerprint information; The determination module is used to determine multiple splitting positions based on multiple candidate operator sequences; and The splitting module is used to decompose the computation graph based on the multiple splitting positions to obtain multiple computation subgraphs.
15. A model training device, comprising: The training module is used to train the compilation model to be trained using multiple computational subgraphs to obtain the target compilation model; The plurality of computational subgraphs are obtained by the method described in any one of claims 1 to 11.
16. A compilation apparatus, comprising: The compilation module is used to input the computation graph to be processed into the target compilation model and obtain the running code; The target compilation model is obtained by training using the method described in claim 12.
17. An intelligent agent, comprising: The input module is used to receive input information; The processing module is configured to determine a target task based on the input information received by the input module, determine a large model based on the target task, and execute the method of any one of claims 1 to 13 by calling the large model to obtain output information; An output module is used to output the output information obtained by the processing module.
18. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the following operations: Read the sequence of operators to be processed from the memory; Perform the method as described in any one of claims 1 to 11 on the sequence of operators to be processed to obtain a plurality of computational subgraphs, and The plurality of computational subgraphs are stored in the memory.
19. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 13.
20. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 13.