Global optimization method and device for deep learning model reversibility, equipment and medium
Through dynamic programming and node traversal of abstract syntax trees, the optimal reversible strategy of the deep learning model is automatically determined, solving the problem of low manual operation efficiency in the existing technology, achieving full optimization of the model and improvement of computing efficiency.
Patent Information
- Application Number
- CN202410793018.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-19
AI Technical Summary
The reversible processing of deep learning models in the existing technology relies on manual operations and cannot effectively search for the optimal reversible strategy. This results in low resource utilization efficiency and long time consumption, and cannot fully optimize the model.
By obtaining the abstract syntax tree of the deep learning model, the globally optimal reversible strategy is dynamically planned, the node traversal and cost model are used to optimize the reversible process, and the optimal reversible strategy is automatically determined.
It greatly reduces labor costs, fully optimizes the deep learning model, improves the efficiency of backpropagation calculations, and avoids the limitations of manual operations.
Smart Images

Figure CN118657187A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a global optimization method, device, equipment and medium for reversible deep learning models. Background Art
[0002] The reversibility technology of deep learning models is a technical solution that can effectively optimize the utilization efficiency of computing, bandwidth and storage resources during model training. The specific implementation method is to convert certain local structures (also called reversible structures) in the deep learning model into specific reversible modes.
[0003] In the prior art, the above reversibility process is mainly completed manually by developers with rich knowledge and experience. However, the same reversible structure can often be reversibly converted using multiple types of reversible modes. Figure 1 As shown in the figure, a typical residual block structure can be reversibly converted into three practically usable reversible modes: additive reversible mode, affine reversible mode, and momentum reversible mode. However, when developers actually perform reversible processing, they often only use a single type of reversible mode to reversibly convert each reversible structure included in the deep learning model.
[0004] In the process of implementing the present invention, the inventors found that the manual reversibility implementation method of selecting a single reversibility mode in the prior art often cannot truly search for the optimal reversibility strategy. It not only consumes a lot of manpower and time costs, but also cannot effectively achieve full optimization of the deep learning model. Summary of the invention
[0005] The present invention provides a global optimization method, device, equipment and medium for the reversibility of a deep learning model, so as to provide an implementation method for automatically determining the optimal reversibility strategy for a deep learning model.
[0006] According to one aspect of an embodiment of the present invention, a global optimization method for reversibility of a deep learning model is provided, comprising:
[0007] Obtain each target reversible structure that can be actually measured by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure;
[0008] Get the abstract syntax tree corresponding to the target deep learning model;
[0009] Traverse the nodes according to the tree structure of the abstract syntax tree, and dynamically plan the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process;
[0010] Among them, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, the target reversible structure is a branchless structure containing at least one node, and each target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy adapted to the target deep learning model.
[0011] According to another aspect of an embodiment of the present invention, a global optimization device for reversible deep learning model is also provided, including:
[0012] A target reversible transformation pattern set acquisition module is used to acquire each target reversible structure that can be actually measured by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure;
[0013] An abstract syntax tree acquisition module, used to obtain an abstract syntax tree corresponding to a target deep learning model;
[0014] The target reversible strategy planning module is used to traverse the nodes according to the tree structure of the abstract syntax tree, and dynamically plan the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process;
[0015] Among them, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, the target reversible structure is a branchless structure containing at least one node, and each target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy adapted to the target deep learning model.
[0016] According to another aspect of an embodiment of the present invention, an electronic device is provided, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the global optimization method for reversibility of the deep learning model described in any embodiment of the present invention.
[0020] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the global optimization method for reversibility of the deep learning model described in any embodiment of the present invention when executed.
[0021] The technical solution of the embodiment of the present invention obtains each target reversible structure that can be actually measured and used in the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure; obtains an abstract syntax tree corresponding to the target deep learning model; traverses nodes according to the tree structure of the abstract syntax tree, and dynamically plans the implementation method of the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process. An innovative tree-structured dynamic programming scheme is proposed to search for the implementation method of the globally optimal target reversible strategy. The entire search process does not require the participation of developers, which greatly reduces labor costs. At the same time, by using the globally optimal target reversible strategy to reversibly process the target deep learning model, the target deep learning model can be fully optimized, thereby maximizing the efficiency of back-propagation calculations.
[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 It is a schematic diagram of multiple reversible modes of reversible conversion of the same reversible structure provided by the prior art;
[0025] Figure 2 is a flowchart of a global optimization method for reversible deep learning models provided in Embodiment 1 of the present invention;
[0026] Figure 3 is a flowchart of another global optimization method for reversible deep learning models provided in Embodiment 2 of the present invention;
[0027] Figure 4 A flowchart of a method for obtaining a first cost value corresponding to an optimal reversible strategy for a current node applicable to an embodiment of the present invention;
[0028] Figure 5 It is a schematic diagram of a specific application scenario to which the technical solution of the embodiment of the present invention is applicable;
[0029] Figure 6is a schematic diagram of the structure of a global optimization device for reversible deep learning models provided in Embodiment 3 of the present invention;
[0030] Figure 7 It is a structural schematic diagram of an electronic device for implementing the global optimization method for reversible deep learning model of an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] Embodiment 1
[0034] Figure 2 This is a flowchart of a global optimization method for reversibility of a deep learning model provided in the first embodiment of the present invention. This embodiment can be applied to the case where a global optimal target reversibility strategy is dynamically planned among all the measured and available reversible structures corresponding to a specific deep learning model and the reversible modes corresponding to each reversible structure. This method can be executed by a global optimization device for reversibility of a deep learning model, which can be implemented in the form of hardware and / or software and can generally be configured in an electronic device with data processing functions. Figure 2 As shown, the method includes:
[0035] S210, obtaining each target reversible structure that can be actually measured and used by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure.
[0036] In this embodiment, the target deep learning model refers to a machine learning model that needs to use one or more reversible modes to replace the set local structure in order to efficiently perform back propagation calculations. Among them, the above-mentioned replacement process is called reversible transformation. The reversible mode refers to a specific subnet architecture that can use the gradient tensor of the output position and the accompanying tensor transmitted through its own structure to synthesize the gradient to eliminate the accumulated storage activation. At present, reversible modes of various network structures have been developed, such as additive reversible mode, affine reversible mode, or momentum reversible mode, etc., which are not limited in this embodiment.
[0037] Specifically, in the target deep learning model, the local structure that is used to be reversibly transformed by the reversible mode of the set structure is called a reversible structure.
[0038] Among them, a target reversible structure corresponds to a target reversible transformation pattern set. The target reversible structure can be understood as a reversible structure that is available for actual measurement by the backend system among all the reversible candidate structures identified in the target deep learning model. The target reversible transformation pattern set contains one or more target reversible candidate patterns.
[0039] Specifically, assuming that the target reversible transformation mode set corresponding to the target reversible structure A is {target reversible transformation mode 1, target reversible transformation mode 2}, it means that after the target reversible structure A in the target deep learning model is reversibly converted into the target reversible transformation mode 1, a reversible reconstruction model is obtained, which is actually available when the trial run is carried out in the back-end system. At the same time, after the target reversible structure A in the target deep learning model is reversibly converted into the target reversible transformation mode 2, a reversible reconstruction model is obtained, which is also actually available when the trial run is carried out in the back-end system.
[0040] Among them, the target reversible structures that can be actually measured and used by the target deep learning model and the target reversible transformation pattern set corresponding to the target reversible structures can be obtained in various ways, for example, from a manual processing platform, or by setting an automatic recognition algorithm, etc. This embodiment does not limit this.
[0041] In an optional implementation of this embodiment, obtaining each target reversible structure that is actually available for the target deep learning model and a target reversible conversion pattern set corresponding to the target reversible structure may include:
[0042] An abstract syntax tree corresponding to the target deep learning model is obtained, and a directed acyclic graph is generated based on the abstract syntax tree, wherein the nodes in the abstract syntax tree correspond to the operators in the target deep learning model; a structural analysis is performed on the directed acyclic graph to determine the dependency relationship between the nodes, and based on the dependency relationship, a reversible candidate structure corresponding to each node is determined; wherein the reversible candidate structure is a branchless structure containing at least one node; among all the reversible candidate structures, reversible candidate structures that do not meet the legality detection conditions are filtered out to obtain legal reversible candidate structures, and a reversible transformation pattern set corresponding to each legal reversible candidate structure is determined based on a black and white list; based on the reversible transformation pattern set corresponding to each legal reversible candidate structure, a plurality of reversible reconstruction models corresponding to the target deep learning model are constructed; each reversible reconstruction model is loaded into a back-end system for trial operation, and based on the trial operation results, each target reversible structure that is actually available and a target reversible transformation pattern set corresponding to the target reversible structure are screened out.
[0043] The Abstract Syntax Tree (AST) is a tree representation of the abstract syntax structure of the source code, and each node on the tree represents a structure in the source code. In the field of machine learning, we can use AST to represent the structure of the machine learning model, and then build or parse the machine learning model by traversing the AST. When using AST to represent the target deep learning model, each node in the AST represents each operator in the target deep learning model.
[0044] Accordingly, after obtaining the abstract syntax tree corresponding to the target deep learning model, a directed acyclic graph (DAG) corresponding to the target deep learning model can be generated based on the abstract syntax tree. A directed acyclic graph refers to a graph in which there are edge links (directed edges) with a certain direction between the nodes, and there are no multiple edges linked to form a ring in the form of a cycle.
[0045] Among them, the directed acyclic graph contains multiple nodes, and each node is connected by a directed edge. Each node in the directed acyclic graph also corresponds to each operator in the target deep learning model.
[0046] The edge links connecting two nodes in a directed acyclic graph are directional, that is, two nodes are connected by a directed edge with an arrow, where the node in the direction where the arrow ends depends on the node in the direction where the arrow starts. For example, if in the target deep learning model, a convolution calculation is first performed on the input data x and y to obtain the calculation result z, and then the calculation result z is normalized to obtain the calculation result k. It can be seen that the execution of the normalization operator depends on the execution result of the convolution operator. Therefore, in the directed acyclic graph corresponding to the target deep learning model, in the directed edge composed of node A corresponding to the convolution operator and node B corresponding to the normalization operator, the arrow points from node A to node B.
[0047] Correspondingly, after obtaining the directed acyclic graph corresponding to the target deep learning model, the dependency relationship between the nodes can be determined by analyzing the directionality of each directed edge between the nodes in the directed acyclic graph.
[0048] The inventors have found through research that if a local structure in the target deep learning model can be used as a reversible structure, then the subgraph corresponding to this local structure in the directed acyclic graph should be a branchless structure from the perspective of data topology. That is, this local structure contains multiple nodes, and after taking this local structure as a whole, this local structure has no directed edges flowing into the local structure or out of the local structure except the initial input edge (which may be one or more) and the final output edge (which may be one or more), that is, the local structure as a whole is a branchless structure.
[0049] It is understandable that a branchless structure is a necessary condition for a local structure to be a final reversible structure. Therefore, firstly, based on the dependency relationship between the nodes defined in the directed acyclic graph, all candidate structures that can be used as the final reversible structure corresponding to the target deep learning model, that is, reversible candidate structures, can be determined.
[0050] The inventors further discovered that the reversible structure that can be reversibly converted using the reversible mode also needs to meet certain necessary conditions in terms of data capacity, data size or mathematical properties. Accordingly, in the embodiments of the invention, corresponding legality detection conditions can be constructed based on one or more of the necessary conditions that need to be met.
[0051] Furthermore, all reversible candidate structures can be screened once based on the above-mentioned legality detection conditions to obtain legal reversible candidate structures that meet each legality detection condition.
[0052] The reversible conversion mode set includes one or more reversible conversion modes, and one reversible conversion mode set corresponds to one legal reversible candidate structure. The reversible conversion mode can be understood as a reversible mode that can reversibly convert the adapted legal reversible candidate structure.
[0053] In this embodiment, the black and white list can be a pre-established reversible conversion mode white list and a pre-established reversible conversion mode black list. In the reversible conversion mode white list, all reversible modes corresponding to each reversible structure under the broadest conditions are defined, that is, all reversible modes that can be used to reversibly convert a reversible structure without considering other limiting conditions; in the reversible conversion mode black list, invalid reversible modes that cannot be effectively reversibly converted under each algorithm model scenario are defined.
[0054] Specifically, the algorithm model scenario may include: a Transformers model scenario, a TorchVision model scenario, or a Pytorch model scenario, etc., which is not limited in this embodiment.
[0055] By combining the target algorithm model scenario using the target deep learning model, and the black and white lists, it is possible to determine the reversible transformation pattern set corresponding to each legal reversible candidate structure under the target algorithm model scenario, that is, to determine all reversible transformation patterns that can theoretically reversibly transform the legal reversible candidate structures.
[0056] It can be understood that the reversible transformation pattern set corresponding to each legal reversible candidate structure determined by the above operation is a set of theoretically available reversible transformation patterns, but the availability of such reversible transformation cannot be guaranteed in the actual operation of the model. Therefore, in an embodiment of the present invention, a reversible reconstruction model after the target deep learning model is reversibly transformed can be constructed according to the reversible transformation pattern set corresponding to each legal reversible candidate structure. By trial running these reversible reconstruction models, the target reversible structures that are actually available can be screened out, as well as one or more target reversible transformation patterns corresponding to each target reversible structure.
[0057] In a specific example, after determining a legal reversible candidate structure A and a reversible transformation pattern set {reversible transformation pattern B1, reversible transformation pattern B2} corresponding to the legal reversible candidate structure A, the reversible candidate structure A in the target deep learning model can be reversibly transformed using the reversible transformation pattern B1 to obtain a reversible reconstruction model C1. At the same time, the reversible candidate structure A in the target deep learning model can also be reversibly transformed using the reversible transformation pattern B2 to obtain a reversible reconstruction model C2. It can be understood that the total number of reversible reconstruction models finally constructed is the cumulative sum of the number of reversible transformation patterns contained in each reversible transformation pattern set corresponding to each legal reversible candidate structure.
[0058] In this embodiment, after obtaining a specific legal reversible candidate structure and a specific reversible transformation pattern corresponding to the specific legal reversible candidate structure, an invasive transformation method can be used to construct a corresponding reversible reconstruction model, or a non-invasive transformation method can be used to construct the reversible reconstruction model. This embodiment does not limit this.
[0059] Specifically, the intrusive conversion method can be understood as a method of modifying the source code of the target deep learning model to achieve the construction of the reversible reconstruction model, while the non-intrusive conversion method can be understood as the need to modify the source code of the target deep learning model. By using compiler technology, the corresponding reversible reconstruction model is automatically generated after the source code of the target deep learning model is input.
[0060] Among them, the backend system can be understood as a physical execution device for loading and executing the set machine learning model. The trial run can be understood as loading the set reversible reconstruction model to the actual execution device, and controlling the execution device to execute the set time (for example, 10 minutes, 20 minutes or 1 hour, etc.) or controlling the execution device to reach the set calculation target (for example, one round of model training). At the same time, it is necessary to detect whether the set reversible reconstruction model can be executed normally during the execution process based on the set time or the set calculation target. For example, check whether there are abnormal errors during the test run.
[0061] Specifically, the trial operation result may be normal operation or abnormal operation. Assuming that the trial operation result of the reversible reconstruction model A is abnormal operation, after extracting the legal reversible candidate structure a1 and the corresponding reversible transformation mode a2 corresponding to the reversible reconstruction model A, the reversible transformation mode a2 is deleted from the reversible transformation mode set corresponding to the legal reversible candidate structure a1. When the reversible transformation mode set corresponding to a legal reversible candidate structure X does not contain any reversible transformation mode, the legal reversible candidate structure X can be directly filtered out accordingly.
[0062] After completing the trial run of the reversible reconstruction model, the legal reversible candidate structures remaining after screening based on the trial run results can be determined as target reversible structures, and the reversible conversion modes remaining after screening of each target reversible structure can be combined and added to the matching target reversible conversion mode set.
[0063] Further, the directed acyclic graph is structurally analyzed to determine the dependency relationship between the nodes, and based on the dependency relationship, the reversible candidate structures corresponding to the nodes are determined, which may include:
[0064] Perform structural analysis on the directed acyclic graph to generate a dominator tree corresponding to the directed acyclic graph, and generate a post-dominator tree corresponding to the directed acyclic graph based on the dominator tree; perform a pre-order traversal on the directed acyclic graph to obtain a sorted node list; sequentially obtain a node in the sorted node list as the current processing node; query the post-dominator tree to obtain all subgraphs with the current processing node as the starting point and the post-dominator node of the current processing node as the end point, as the reversible candidate structure corresponding to the current processing node; return to execute the operation of sequentially obtaining a node in the sorted node list as the current processing node, until the reversible candidate structure corresponding to each node is obtained.
[0065] Furthermore, filtering out reversible candidate structures that do not meet the legality detection conditions from among all reversible candidate structures may include:
[0066] Identify the in-degree and out-degree of the currently processed reversible candidate structure; if it is determined that any one of the in-degree and the out-degree is greater than 2, determine that the currently processed reversible candidate structure is a reversible candidate structure that does not meet the legality detection condition, and filter out the currently processed reversible candidate structure.
[0067] Furthermore, filtering out reversible candidate structures that do not meet the legality detection conditions from among all reversible candidate structures may include:
[0068] Identify the total number of elements in the two input tensors and the two output tensors of the currently processed reversible candidate structure; if it is determined that the total number of elements in the two input tensors or the two output tensors are inconsistent, determine that the currently processed reversible candidate structure is a reversible candidate structure that does not meet the legality detection conditions, and filter out the currently processed reversible candidate structure.
[0069] Furthermore, filtering out reversible candidate structures that do not meet the legality detection conditions from among all reversible candidate structures may include:
[0070] Obtain a transfer function matrix corresponding to the currently processed reversible candidate structure; and calculate the determinant of the transfer function matrix; if it is determined that the determinant is less than or equal to zero, determine that the currently processed reversible candidate structure is a reversible candidate structure that does not meet the legality detection conditions, and filter out the currently processed reversible candidate structure.
[0071] Furthermore, determining the reversible conversion pattern set corresponding to each legal reversible candidate structure according to the black and white lists may include:
[0072] By querying a pre-established reversible conversion pattern whitelist, a set of reversible conversion alternative patterns that match each legal reversible candidate structure is obtained; a target algorithm model scenario that matches the target deep learning model is obtained, and by querying a pre-established reversible conversion pattern blacklist, at least one invalid reversible conversion pattern that matches the target algorithm model scenario is obtained; in each reversible conversion alternative pattern set, each invalid reversible conversion pattern is filtered out respectively to obtain a reversible conversion pattern set corresponding to each legal reversible candidate structure.
[0073] S220, obtaining an abstract syntax tree corresponding to the target deep learning model;
[0074] S230, traversing nodes according to the tree structure of the abstract syntax tree, and dynamically planning a target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process.
[0075] Among them, each target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy for target deep learning model adaptation.
[0076] It can be understood that by using each target reversible structure and a target reversible conversion mode set corresponding to the target reversible structure, a plurality of reversibility strategies can be formed. In one reversibility strategy, a single target reversible structure and a unique target reversible conversion mode corresponding to the single target reversible structure can be defined. In one reversibility strategy, multiple target reversible structures that do not affect each other and unique target reversible conversion modes corresponding to each of the above target reversible structures can also be defined.
[0077] The term "non-influence" means that after a target reversible structure is reversibly transformed using a matching target reversible transformation mode, it will not affect other target reversible structures that are reversibly transformed using a matching target reversible transformation mode. In other words, the target reversible structures that do not influence each other do not have any identical (overlapping) nodes.
[0078] In a specific example, if the target deep learning model has two target reversible structures, where the target reversible transformation mode set corresponding to the target reversible structure A is {target reversible transformation mode 1, target reversible transformation mode 2}, and the target reversible transformation mode set corresponding to the target reversible structure B is {target reversible transformation mode 3}, and the target reversible structure A and the target reversible structure B do not affect each other, then the reversibility strategy corresponding to the target deep learning model may include:
[0079] Reversible strategy 1 for reversibly converting the target reversible structure A using only the target reversible conversion mode 1, reversible strategy 2 for reversibly converting the target reversible structure A using only the target reversible conversion mode 2, reversible strategy 3 for reversibly converting the target reversible structure B using only the target reversible conversion mode 3, reversible strategy 4 for reversibly converting the target reversible structure B using the target reversible conversion mode 3 while reversibly converting the target reversible structure A using the target reversible conversion mode 1, and reversible strategy 5 for reversibly converting the target reversible structure B using the target reversible conversion mode 3 while reversibly converting the target reversible structure A using the target reversible conversion mode 2.
[0080] It can be understood that after determining multiple reversible strategies based on the target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure, the cost value of each reversible strategy can be calculated based on a preset cost model, and the target reversible strategy corresponding to the minimum cost value can be selected.
[0081] In this embodiment, in order to further improve the efficiency of determining the target reversible strategy, a dynamic programming algorithm can be applied to the abstract syntax tree of the target deep learning model to efficiently obtain the final required target reversible strategy.
[0082] The input of the cost model is one or more model performance measurement parameters, and the output is the cost value. In a simple example, the cost model can be a simple linear calculation formula. For example, the model performance measurement parameters can be the calculation time and memory usage, and the linear calculation formula can be: C = AX + BY.
[0083] Among them, C is the cost value, A and B are preset proportional coefficients, X is the calculation time, and Y is the memory usage. Specifically, A and B can be preset fixed empirical values, or variable values dynamically updated as the cost model is used, and this embodiment does not limit this.
[0084] Accordingly, in an optional implementation of this embodiment, node traversal is performed according to the tree structure of the abstract syntax tree, and a target reversible strategy corresponding to the target deep learning model is dynamically planned in each reversible strategy based on the cost model during the traversal process, which may include:
[0085] Obtain the current processing node in the abstract syntax tree in a post-order traversal manner; determine the local optimal reversible strategy corresponding to the current processing node among all reversible strategies associated with the current processing node based on a preset cost model; wherein the reversible strategies associated with the current processing node include: a strategy for reversibly converting the current processing node, and a strategy for not reversibly converting the current processing node; return to execute the operation of obtaining the current processing node in the abstract syntax tree in a post-order traversal manner until the local optimal reversible strategy corresponding to the root node of the abstract syntax tree is traversed; determine the local optimal reversible strategy corresponding to the root node of the abstract syntax tree as the target reversible strategy.
[0086] In this optional implementation, the local optimal reversible strategy corresponding to each tree node in the abstract syntax tree is determined step by step by post-order traversal, wherein the local optimal reversible strategy may include a reversible strategy for performing a reversible transformation on the tree node, and may also include a reversible strategy for not performing a reversible transformation on the tree node. Furthermore, when the local optimal reversible strategy corresponding to the root node of the abstract syntax tree is traversed, it is equivalent to traversing the target reversible strategy corresponding to the target deep learning model.
[0087] The technical solution of the embodiment of the present invention obtains each target reversible structure that can be actually measured and used in the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure; obtains an abstract syntax tree corresponding to the target deep learning model; traverses nodes according to the tree structure of the abstract syntax tree, and dynamically plans the implementation method of the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process. An innovative tree-structured dynamic programming scheme is proposed to search for the implementation method of the globally optimal target reversible strategy. The entire search process does not require the participation of developers, which greatly reduces labor costs. At the same time, by using the globally optimal target reversible strategy to reversibly process the target deep learning model, the target deep learning model can be fully optimized, thereby maximizing the efficiency of back-propagation calculations.
[0088] On the basis of the above embodiments, after dynamically planning the target reversible strategy corresponding to the target deep learning model, the following may also be included:
[0089] According to the target reversible strategy, a target reversible reconstruction model corresponding to the target deep learning model is constructed; the target reversible reconstruction model is loaded into the back-end system for actual operation to perform model training operations.
[0090] It can be understood that the target reversible reconstruction model can be understood as the final model obtained after reconstructing the target deep learning model using the target reversible strategy. By running the target reversible reconstruction model for actual model training, the back propagation calculation in the model training process can be effectively optimized.
[0091] It can be understood that the above-mentioned target deep learning model can be a machine learning model applied in various fields such as computer vision (for example, image classification, target detection or face recognition, etc.), natural language processing (for example, text classification, sentiment analysis, machine translation, speech recognition or speech-to-text, etc.), medical field or autonomous driving field.
[0092] Among them, first, based on the abstract syntax tree of the target deep learning model and the target reversibility strategy, an updated abstract syntax tree can be generated by an intrusive modification method or a non-intrusive modification method. Then, an intermediate representation of a computational graph corresponding to the updated abstract syntax tree is generated by a deep learning compiler, and an intermediate computational graph hierarchy corresponding to the intermediate representation of the computational graph is determined by an optimization pipeline inside the deep learning compiler. Then, an executable machine code or bytecode is generated for the intermediate representation of the computational graph and the intermediate computational graph hierarchy as the target reversible reconstruction model through the deep learning encoder backend.
[0093] Embodiment 2
[0094] Figure 3 A flowchart of another global optimization method for reversibility of a deep learning model provided in Embodiment 2 of the present invention, which is a technical refinement of the above embodiments. In this embodiment, the operation of "traversing nodes according to the tree structure of the abstract syntax tree, and dynamically planning a target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process" is concretized.
[0095] Correspondingly, such as Figure 3 As shown, the method may include:
[0096] S310, obtaining each target reversible structure that can be used in actual measurement of the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure.
[0097] S320. Obtain an abstract syntax tree corresponding to the target deep learning model.
[0098] S330 , obtaining the current processing node in the abstract syntax tree in a post-order traversal manner.
[0099] In a specific example, assuming that the abstract syntax tree includes a root node A, first-level tree nodes B and C pointed to by the root node A, and a second-level tree node D pointed to by the first-level tree node B, the corresponding post-order traversal order can be: {D, B, C, A}.
[0100] S340: In the abstract syntax tree, obtain a current subtree structure with the current processing node as the root node, and identify, among all reversibility strategies, each candidate reversibility strategy that only includes each node in the current subtree structure.
[0101] S350 . From among the candidate reversible strategies, obtain a current node candidate reversible strategy that includes reversible conversion of the current processing node.
[0102] In this embodiment, the core principle of the dynamic programming algorithm is to determine the local optimal reversible strategy corresponding to each tree node in the abstract syntax tree from the bottom up. It can be understood that the local optimal reversible strategy of a tree node may include not only a strategy for performing a corresponding reversible transformation (that is, a reversible transformation) on the tree node, but also a strategy for not performing a reversible transformation on the tree node, but performing a reversible transformation on all child nodes under the tree node using the local optimal reversible strategy of the child nodes.
[0103] Accordingly, in this embodiment, an optimal reversible implementation method is found under these two possible strategies.
[0104] Accordingly, we first need to obtain the alternative reversible strategies that only include the nodes in the current subtree structure. Such alternative reversible strategies may or may not include strategies for reversible transformation of the current processing node. We must first select an optimal strategy from the strategies that include reversible transformation of the current processing node (that is, the alternative reversible strategies for the current node) as the optimal strategy for reversible transformation of the current processing node.
[0105] S360. Identify the optimal reversible strategy for the current node from among the candidate reversible strategies for the current node using a preset cost model, and obtain a first-generation value corresponding to the optimal reversible strategy for the current node.
[0106] Specifically, in Figure 4 , a specific implementation method is shown in which a preset cost model is used to identify the optimal reversible strategy of the current node among the alternative reversible strategies of the current node, and obtain the first-generation value corresponding to the optimal reversible strategy of the current node.
[0107] Correspondingly, such as Figure 4 As shown, the calculation method of the first cost value includes:
[0108] S4100. Reconstruct the target deep learning model according to the alternative reversible strategies of each current node to obtain the reversible reconstruction models corresponding to the alternative reversible strategies of each current node.
[0109] In an optional implementation of this embodiment, the target deep learning model is reconstructed according to the alternative reversible strategies of each current node to obtain the reversible reconstruction models corresponding to the alternative reversible strategies of each current node, which may include:
[0110] Reversible transformation forms defined in the alternative reversible transformation strategies for each current node are identified respectively; wherein the reversible transformation forms include: at least one target reversible structure, and a unique target reversible transformation pattern corresponding to each target reversible structure; the abstract syntax tree of the target deep learning model and each reversible transformation form are input into the non-intrusive reversible converter respectively; the updated abstract syntax trees obtained by reversibly transforming the target deep learning model according to each reversible transformation form are outputted through the non-intrusive reversible converter respectively; and the reversible reconstruction models corresponding to the alternative reversible transformation strategies for each current node are obtained according to each updated abstract syntax tree.
[0111] Among them, the reversible transformation form is similar to the definition of the reversibility strategy, which is used to describe which one or several target reversible transformation modes need to be used to reversibly transform the target reversible structure matching in the target deep learning model.
[0112] For example, assuming a reversible transformation form is: target reversible structure A and target reversible transformation mode B1, it means that the target reversible transformation mode B1 is used to perform a reversible transformation on the target reversible structure A in the target deep learning model.
[0113] In this embodiment, a pre-built non-intrusive reversible converter can be used. Based on the abstract syntax tree of the target deep learning model and each reversible transformation form, an updated abstract syntax tree corresponding to each reversible transformation form can be generated, and then a reversible reconstruction model corresponding to each reversible transformation form can be generated according to each updated abstract syntax tree.
[0114] S4200, loading each reversible reconstruction model into a backend system for trial operation, and obtaining operation performance parameters corresponding to each reversible reconstruction model.
[0115] Optionally, the operating performance parameters may include: calculation time information, and / or memory usage information during the calculation process.
[0116] In this optional implementation, during the process of executing each reversible reconstruction model by the backend system, the operation performance description information corresponding to each reversible reconstruction model may be recorded accordingly, wherein the operation performance description information includes: one or more of the calculation time information or the memory usage information during the calculation process.
[0117] The computation time information can be understood as the time required to complete the set computation target (for example, one round of back-propagation computation), and the memory usage information can be understood as the average amount of memory used by the back-end system during model operation.
[0118] Obviously, the smaller the values of the computation time information and memory usage information of a reversible reconstruction model are, the better the reconstruction effect of the reversible reconstruction model is.
[0119] S4300: Input the operating performance parameters corresponding to each reversible reconstruction model into the cost model to obtain the cost values corresponding to each current node candidate reversible strategy.
[0120] In an optional implementation of this embodiment, inputting the operating performance parameters corresponding to each reversible reconstruction model into the cost model to obtain the cost values corresponding to each current node candidate reversible strategy may include:
[0121] The current operating performance parameters corresponding to the current reversible reconstruction model are input into the cost model; through the cost model, the cost value corresponding to the current reversible reconstruction model is calculated based on the historically stored historical operating performance parameters and current operating performance parameters that match the current reversible reconstruction model, and the current operating performance parameters are used to update the historical operating performance parameters that match the current reversible reconstruction model.
[0122] S4400. Determine the current node alternative reversible strategy corresponding to the minimum cost value as the current node optimal reversible strategy, and use the minimum cost value as the first cost value.
[0123] S370. In the current subtree structure, obtain all child nodes corresponding to the current processing node, and obtain the subnode local optimal reversible strategy corresponding to each child node, and the second generation value corresponding to the local optimal reversible strategy of each child node.
[0124] S380. Accumulate and sum the second-generation values to obtain the third-generation value when the current processing node is not processed and all child nodes are reversibly processed according to the local optimal reversibility strategy for the child nodes.
[0125] S390. Determine the local optimal reversibility strategy corresponding to the current processing node based on the first-generation value and the third-generation value.
[0126] Specifically, if the first-generation value is less than the third-generation value, the optimal reversible strategy of the current node is determined as the local optimal reversible strategy corresponding to the current processing node; if the first-generation value is greater than or equal to the third-generation value, the combination of the local optimal reversible strategies of the sub-nodes corresponding to all the sub-nodes corresponding to the current processing node is determined as the local optimal reversible strategy corresponding to the current processing node.
[0127] S3100, determine whether the local optimal reversible strategy corresponding to the root node of the abstract syntax tree is traversed: if so, execute S3110; otherwise, return to execute S330.
[0128] S3110. Determine the local optimal reversibility strategy corresponding to the root node of the abstract syntax tree as the target reversibility strategy.
[0129] The technical solution of the embodiment of the present invention obtains each target reversible structure that can be actually measured and used in the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure; obtains an abstract syntax tree corresponding to the target deep learning model; traverses nodes according to the tree structure of the abstract syntax tree, and dynamically plans the implementation method of the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process. An innovative tree-structured dynamic programming scheme is proposed to search for the implementation method of the globally optimal target reversible strategy. The entire search process does not require the participation of developers, which greatly reduces labor costs. At the same time, by using the globally optimal target reversible strategy to reversibly process the target deep learning model, the target deep learning model can be fully optimized, thereby maximizing the efficiency of back-propagation calculations.
[0130] Specific application scenarios
[0131] Figure 5 A schematic diagram showing a specific application scenario to which the technical solution of an embodiment of the present invention is applicable. Figure 5 As shown in the figure, there are four main implementation steps in the global optimization process to achieve the reversibility of the deep learning model.
[0132] Step 1: Post-order traversal of the abstract syntax tree and start dynamic programming based on the tree structure. The reason for using post-order traversal here is that when you need to select the optimal reversible strategy for any node (or subtree), you need to obtain the optimal reversible strategy for the subtree corresponding to its child node in advance. And select the best solution from the following two solution branches.
[0133] Solution 1: Only perform reversible transformation on each child node of the current node, while the current node is not reversible transformed;
[0134] Solution 2: The entire subtree with the current node as the root node (the subtree containing all the child nodes of the current node) is reversibly converted as a whole. These two solutions conflict with each other, so it is necessary to select a more optimized solution overall.
[0135] Step 2: Call the non-intrusive reversible converter to obtain the corresponding reversible reconstruction model for each specific replacement form in the dynamic programming process, and then call the cost model to estimate the cost after execution through the back-end system. The cost model will store the collected data to avoid repeated sampling of the same cost.
[0136] Step 3: Find the optimal cost when performing a reversible transformation on each child node of the current node instead of directly transforming the subtree corresponding to the current node (step 3.1). At the same time, find the optimal cost when performing a reversible transformation on the entire tree with the current node as the root node (step 3.2).
[0137] Step 4: Among the two types of optimal costs mentioned above, select the reversible conversion scheme with the minimum cost value as the optimal reversible strategy corresponding to the current node. In addition, the condition for the termination of the entire dynamic programming is that the root node of the global model is processed and the global optimal target reversible strategy is obtained. And it is output to the subsequent compilation and execution process.
[0138] Embodiment 3
[0139] Figure 6 This is a schematic diagram of the structure of a global optimization device for reversible deep learning models provided in the third embodiment of the present invention. Figure 6 As shown, the device includes: a target reversible conversion pattern set acquisition module 610, an abstract syntax tree acquisition module 620 and a target reversible strategy planning module 630, wherein:
[0140] A target reversible transformation pattern set acquisition module 610 is used to acquire each target reversible structure that can be actually measured and used by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure;
[0141] An abstract syntax tree acquisition module 620 is used to acquire an abstract syntax tree corresponding to a target deep learning model;
[0142] A target reversible strategy planning module 630 is used to perform node traversal according to the tree structure of the abstract syntax tree, and dynamically plan a target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process;
[0143] Among them, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, the target reversible structure is a branchless structure containing at least one node, and each target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy adapted to the target deep learning model.
[0144] The technical solution of the embodiment of the present invention obtains each target reversible structure that can be actually measured and used in the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure; obtains an abstract syntax tree corresponding to the target deep learning model; traverses nodes according to the tree structure of the abstract syntax tree, and dynamically plans the implementation method of the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process. An innovative tree-structured dynamic programming scheme is proposed to search for the implementation method of the globally optimal target reversible strategy. The entire search process does not require the participation of developers, which greatly reduces labor costs. At the same time, by using the globally optimal target reversible strategy to reversibly process the target deep learning model, the target deep learning model can be fully optimized, thereby maximizing the efficiency of back-propagation calculations.
[0145] Based on the above embodiments, the target reversibility strategy planning module 630 may include:
[0146] A current processing node acquisition unit, used to acquire a current processing node in the abstract syntax tree in a post-order traversal manner;
[0147] A local optimal reversible strategy determination unit, configured to determine, based on a preset cost model, a local optimal reversible strategy corresponding to the current processing node from among all reversible strategies associated with the current processing node;
[0148] The reversibility strategy associated with the current processing node includes: a strategy for performing a reversible conversion on the current processing node, and a strategy for not performing a reversible conversion on the current processing node;
[0149] A return execution unit is used to return to execute the operation of obtaining the current processing node in the abstract syntax tree by post-order traversal until the local optimal reversible strategy corresponding to the root node of the abstract syntax tree is traversed;
[0150] The target reversibility strategy determination unit is used to determine the local optimal reversibility strategy corresponding to the root node of the abstract syntax tree as the target reversibility strategy.
[0151] On the basis of the above embodiments, the local optimal reversible strategy determination unit may specifically include:
[0152] The candidate reversible strategy identification subunit is used to obtain the current subtree structure with the current processing node as the root node in the abstract syntax tree, and identify the candidate reversible strategies that only include the nodes in the current subtree structure from all the reversible strategies;
[0153] A current node candidate reversible strategy acquisition subunit is used to acquire, from among the candidate reversible strategies, a current node candidate reversible strategy that includes a reversible transformation of the current processing node;
[0154] The first-generation value acquisition subunit is used to identify the optimal reversible strategy of the current node among the candidate reversible strategies of each current node through a preset cost model, and to obtain the first-generation value corresponding to the optimal reversible strategy of the current node;
[0155] The second-generation value acquisition subunit is used to acquire all child nodes corresponding to the current processing node in the current subtree structure, and acquire the child node local optimal reversible strategy corresponding to each child node, and the second-generation value corresponding to the local optimal reversible strategy of each child node;
[0156] The third-generation value acquisition subunit is used to accumulate and sum the second-generation values to obtain the third-generation value when the current processing node is not processed and all child nodes are reversibly processed according to the local optimal reversibility strategy of the child nodes;
[0157] The local optimal reversible strategy determination subunit is used to determine the local optimal reversible strategy corresponding to the current processing node according to the first generation value and the third generation value.
[0158] Based on the above embodiments, the first generation value acquisition subunit can be specifically used for:
[0159] Reconstruct the target deep learning model according to the alternative reversible strategies of each current node, and obtain the reversible reconstruction models corresponding to the alternative reversible strategies of each current node;
[0160] Load each reversible reconstruction model into the back-end system for trial operation to obtain the operation performance parameters corresponding to each reversible reconstruction model;
[0161] Inputting the operating performance parameters corresponding to each reversible reconstruction model into the cost model, and obtaining the cost values corresponding to the alternative reversible strategies of each current node;
[0162] The current node alternative reversible strategy corresponding to the minimum cost value is determined as the optimal reversible strategy for the current node, and the minimum cost value is used as the first generation value.
[0163] Based on the above embodiments, the operating performance parameters may include: calculation time information, and / or memory usage information during the calculation process.
[0164] Based on the above embodiments, the first-generation value acquisition subunit can be further used for:
[0165] Inputting the current operating performance parameters corresponding to the current reversible reconstruction model into the cost model;
[0166] Through the cost model, the cost value corresponding to the current reversible reconstruction model is calculated based on the historical operating performance parameters and current operating performance parameters that are historically stored and match the current reversible reconstruction model, and the current operating performance parameters are used to update the historical operating performance parameters that match the current reversible reconstruction model.
[0167] Based on the above embodiments, the first-generation value acquisition subunit can be further used for:
[0168] Identify the reversible transformation forms defined in the alternative reversibility strategy for each current node respectively;
[0169] The reversible conversion form includes: at least one target reversible structure, and a unique target reversible conversion mode corresponding to each target reversible structure;
[0170] Inputting the abstract syntax tree of the target deep learning model and each reversible transformation form into the non-intrusive reversible transformer respectively;
[0171] Outputting updated abstract syntax trees obtained by reversibly transforming the target deep learning model according to each reversible transformation form through a non-intrusive reversible transformer;
[0172] According to each updated abstract syntax tree, the reversible reconstruction models corresponding to each current node candidate reversible strategy are obtained.
[0173] On the basis of the above embodiments, an actual execution module may also be included, which is used to:
[0174] After dynamically planning a target reversible strategy corresponding to the target deep learning model, a target reversible reconstruction model corresponding to the target deep learning model is constructed according to the target reversible strategy;
[0175] The target reversible reconstruction model is loaded into the backend system for actual operation to perform model training operations.
[0176] The reversible global optimization device for deep learning models provided in an embodiment of the present invention can execute the reversible global optimization method for deep learning models provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0177] Embodiment 4
[0178] Figure 7 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention 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 can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0179] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0180] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0181] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as executing the global optimization method for reversibility of the deep learning model as described in any embodiment of the present invention.
[0182] That is: obtaining each target reversible structure that can be actually measured by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure;
[0183] Obtain an abstract syntax tree corresponding to the target deep learning model; perform node traversal according to the tree structure of the abstract syntax tree, and dynamically plan a target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process; wherein the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, the target reversible structure is a branchless structure containing at least one node, and each target reversible structure and a target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy adapted to the target deep learning model.
[0184] In some embodiments, the global optimization method for reversible deep learning models as described in any embodiment of the present invention may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the global optimization method for reversible deep learning models as described in any embodiment of the present invention described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the global optimization method for reversible deep learning models as described in any embodiment of the present invention by any other appropriate means (e.g., by means of firmware).
[0185] Various implementations 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 chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0186] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0187] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0188] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0189] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0190] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0191] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0192] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A global optimization method for reversibility of deep learning models, characterized in that: include: Obtain each target reversible structure that can be actually measured by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure; Get the abstract syntax tree corresponding to the target deep learning model; Traverse the nodes according to the tree structure of the abstract syntax tree, and dynamically plan the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process; Among them, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, the target reversible structure is a branchless structure containing at least one node, and each target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy adapted to the target deep learning model.
2. The method according to claim 1, characterized in that According to the tree structure of the abstract syntax tree, nodes are traversed, and during the traversal process, a target reversible strategy corresponding to the target deep learning model is dynamically planned in each reversible strategy based on the cost model, including: Obtain the current processing node in the abstract syntax tree in a post-order traversal manner; Based on a preset cost model, determining a local optimal reversible strategy corresponding to the current processing node among all reversible strategies associated with the current processing node; The reversibility strategy associated with the current processing node includes: a strategy for performing a reversible conversion on the current processing node, and a strategy for not performing a reversible conversion on the current processing node; Return to execute the operation of obtaining the current processing node in the abstract syntax tree by post-order traversal until the local optimal reversible strategy corresponding to the root node of the abstract syntax tree is traversed; The local optimal reversibility strategy corresponding to the root node of the abstract syntax tree is determined as the target reversibility strategy.
3. The method according to claim 2, characterized in that Based on the preset cost model, a local optimal reversible strategy corresponding to the current processing node is determined among all reversible strategies associated with the current processing node, including: In the abstract syntax tree, a current subtree structure with the current processing node as the root node is obtained, and among all reversible strategies, each candidate reversible strategy that only includes each node in the current subtree structure is identified; Among the candidate reversible strategies, obtaining a current node candidate reversible strategy that includes reversible transformation of the current processing node; Through the preset cost model, the optimal reversible strategy of the current node is identified from the candidate reversible strategies of each current node, and the first-generation value corresponding to the optimal reversible strategy of the current node is obtained; In the current subtree structure, all child nodes corresponding to the current processing node are obtained, and the local optimal reversible strategy of the child nodes corresponding to each child node is obtained, as well as the second generation value corresponding to the local optimal reversible strategy of each child node; The second-generation values are accumulated and summed to obtain the third-generation value when the current processing node is not processed and all child nodes are reversibly processed according to the local optimal reversibility strategy of the child nodes; According to the first-generation value and the third-generation value, the local optimal reversibility strategy corresponding to the current processing node is determined.
4. The method according to claim 3, characterized in that Through the preset cost model, the optimal reversible strategy of the current node is identified among the candidate reversible strategies of each current node, and the first-generation value corresponding to the optimal reversible strategy of the current node is obtained, including: Reconstruct the target deep learning model according to the alternative reversible strategies of each current node, and obtain the reversible reconstruction models corresponding to the alternative reversible strategies of each current node; Load each reversible reconstruction model into the back-end system for trial operation to obtain the operation performance parameters corresponding to each reversible reconstruction model; Inputting the operating performance parameters corresponding to each reversible reconstruction model into the cost model, and obtaining the cost values corresponding to the alternative reversible strategies of each current node; The current node alternative reversible strategy corresponding to the minimum cost value is determined as the optimal reversible strategy for the current node, and the minimum cost value is used as the first generation value.
5. The method according to claim 4, characterized in that The operating performance parameters include: calculation time information, and / or memory usage information during the calculation process.
6. The method according to claim 4, characterized in that Input the operating performance parameters corresponding to each reversible reconstruction model into the cost model to obtain the cost values corresponding to the alternative reversible strategies of each current node, including: Inputting the current operating performance parameters corresponding to the current reversible reconstruction model into the cost model; Through the cost model, the cost value corresponding to the current reversible reconstruction model is calculated based on the historical operating performance parameters and current operating performance parameters that are historically stored and match the current reversible reconstruction model, and the current operating performance parameters are used to update the historical operating performance parameters that match the current reversible reconstruction model.
7. The method according to claim 4, characterized in that The target deep learning model is reconstructed according to the alternative reversible strategies of each current node, and the reversible reconstruction models corresponding to the alternative reversible strategies of each current node are obtained, including: Identify the reversible transformation forms defined in the alternative reversibility strategy for each current node respectively; The reversible conversion form includes: at least one target reversible structure, and a unique target reversible conversion mode corresponding to each target reversible structure; Inputting the abstract syntax tree of the target deep learning model and each reversible transformation form into the non-intrusive reversible transformer respectively; Outputting updated abstract syntax trees obtained by reversibly transforming the target deep learning model according to each reversible transformation form through a non-intrusive reversible transformer; According to each updated abstract syntax tree, the reversible reconstruction models corresponding to each current node candidate reversible strategy are obtained.
8. The method according to any one of claims 1 to 7, characterized in that: After dynamically planning the target reversibility strategy corresponding to the target deep learning model, it also includes: According to the target reversibility strategy, a target reversible reconstruction model corresponding to the target deep learning model is constructed; The target reversible reconstruction model is loaded into the backend system for actual operation to perform model training operations.
9. A global optimization device for reversible deep learning model, characterized in that: include: A target reversible transformation pattern set acquisition module is used to acquire each target reversible structure that can be actually measured by the target deep learning model and a target reversible transformation pattern set corresponding to the target reversible structure; An abstract syntax tree acquisition module, used to obtain an abstract syntax tree corresponding to a target deep learning model; The target reversible strategy planning module is used to traverse the nodes according to the tree structure of the abstract syntax tree, and dynamically plan the target reversible strategy corresponding to the target deep learning model in each reversible strategy based on the cost model during the traversal process; Among them, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, the target reversible structure is a branchless structure containing at least one node, and each target reversible structure and the target reversible transformation pattern set corresponding to the target reversible structure are used to constitute a reversible strategy adapted to the target deep learning model.
10. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the global optimization method for reversibility of the deep learning model described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the global optimization method for reversible deep learning models described in any one of claims 1 to 8 when executed.
Citation Information
Patent Citations
Generation method, optimization method and device of deep learning model, equipment and medium
CN113283613A
Strategy reinforcement learning method based on fuzzy rule and decision tree
CN115618924A
Deep learning enhanced code completion system
US20200249918A1
Generating Computer Models from Implicitly Relevant Feature Sets
US20210304891A1
Invertible depth network for image reconstruction and domain transfers
US20210365733A1
