Data processing method, electronic equipment and computer readable storage medium
By adjusting the execution plan of the deep neural network model and optimizing its resource occupation needs, the problems of low optimization performance, long time and poor availability in the existing technology are solved, and more efficient model training and resource use are achieved.
Patent Information
- Application Number
- CN202311237615.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
AI Technical Summary
The prior art has low performance, long time and poor availability when optimizing the video memory usage of deep neural network models, especially in large models and complex optimizer scenarios.
By obtaining the preset data structure of the initial machine learning model, adjusting its execution plan, including the execution order of the computing unit and the variable storage method, to optimize resource occupancy requirements and train the model based on the target adjustment results.
It improves the training efficiency of machine learning models, reduces resource occupation needs and overhead, and ensures the effectiveness, efficiency and scalability of the optimization process.
Smart Images

Figure CN119692492A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of large model technology and computer technology, and more specifically, to a data processing method, an electronic device and a computer-readable storage medium. Background Art
[0002] As the scale of deep neural networks (DNNs) continues to grow, more hardware resources are needed to train neural networks. Since video memory is one of the factors that limit the model scale and training batch data size, a method is proposed to optimize the model execution plan to reduce the model's own video memory requirements. The model execution plan includes two aspects: operator execution order and tensor storage plan.
[0003] Currently, the MODeL framework is used to convert the problem of optimizing the execution order of operators into the problem of optimizing the life cycle of tensors. The constraint solving method is used to optimize the life cycle and address of tensors, thereby reducing the memory overhead. However, when this method is applied to large models or using more complex optimizers, the performance is significantly impaired, resulting in long optimization time, low usability and effectiveness.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a data processing method, an electronic device, and a computer-readable storage medium to at least solve the technical problems in the related art of the method for optimizing the execution sequence of operators, such as low performance, long optimization time, and poor usability.
[0006] According to one aspect of an embodiment of the present application, a data processing method is provided, including: obtaining a preset data structure corresponding to an initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model; adjusting the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupancy requirement of the initial machine learning model; according to the target adjustment result, training the initial machine learning model to obtain a target machine learning model.
[0007] According to another aspect of an embodiment of the present application, a data processing method is also provided, including: obtaining a preset data structure corresponding to an initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model; under a video memory optimization framework, adjusting the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupancy requirements of the initial machine learning model.
[0008] According to another aspect of an embodiment of the present application, a data processing method is also provided, including: obtaining a preset data structure corresponding to an initial e-commerce service model, wherein the preset data structure is used to represent a calculation process of the initial e-commerce service model; adjusting an execution plan of the initial e-commerce service model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine an execution order of calculation units in the preset data structure and a variable storage method corresponding to the calculation units, and the target adjustment result is used to determine resource occupation requirements of the initial e-commerce service model; training the initial e-commerce service model according to the target adjustment result to obtain a target e-commerce service model.
[0009] According to another aspect of an embodiment of the present application, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein when the program is running, any one of the above-mentioned data processing methods is executed.
[0010] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned data processing methods.
[0011] In an embodiment of the present application, by obtaining a preset data structure corresponding to an initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure, a target adjustment result for determining the resource occupancy requirement of the initial machine learning model is obtained, and finally, the initial machine learning model is trained based on the target adjustment result to obtain a target machine learning model. Through the above method, the purpose of optimizing the training process of the machine learning model and improving the training efficiency of the machine learning model is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource occupancy requirement and resource overhead of the model without introducing modifications to the model training steps and other overheads, and ensuring the effectiveness, efficiency and scalability of the optimization process, thereby solving the technical problems of low performance, long optimization time and poor usability of the method for optimizing the execution order of operators in related technologies.
[0012] It is easy to notice that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0014] Figure 1 This is a schematic diagram of an application scenario of a data processing method according to Embodiment 1 of the present application;
[0015] Figure 2 is a flow chart of a data processing method according to Embodiment 1 of the present application;
[0016] Figure 3 is a schematic diagram of the architecture of a graph-based video memory optimization framework according to Embodiment 1 of the present application;
[0017] Figure 4 is a schematic diagram of a calculation graph structure of an optimizer according to Example 1 of the present application;
[0018] Figure 5 is a schematic diagram of a subgraph tree according to Embodiment 1 of the present application;
[0019] Figure 6 is a schematic diagram of a variable storage plan according to Example 1 of the present application;
[0020] Figure 7 is a schematic diagram of a variable life cycle relationship according to Example 1 of the present application;
[0021] Figure 8 is a schematic diagram of a leaf node fusion process according to Embodiment 1 of the present application;
[0022] Fig. 9 is a flow chart of a data processing method according to Embodiment 2 of the present application;
[0023] Fig.10 is a flow chart of a data processing method according to Embodiment 3 of the present application;
[0024] Fig.11 is a structural schematic diagram of a data processing method and device according to Embodiment 4 of the present application;
[0025] Fig.12 is a structural schematic diagram of another data processing method and device according to Embodiment 4 of the present application;
[0026] Fig.13is a structural schematic diagram of another data processing method and device according to Embodiment 4 of the present application;
[0027] Fig.14 It is a structural block diagram of a computer terminal according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application 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 interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] The technical solution provided in this application is mainly implemented by large-scale model technology. The large model here refers to a deep learning model with large-scale model parameters, which can usually contain hundreds of millions, tens of billions, hundreds of billions, trillions or even more than 10 trillion model parameters. The large model can also be called a cornerstone model / foundation model (Foundation Model). The large model is pre-trained through large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as large-scale language model (Large Language Model, LLM), multi-modal pre-training model (multi-modal pre-training model), etc.
[0031] It should be noted that when the large model is actually applied, the pre-trained model can be fine-tuned through a small number of samples so that the large model can be applied to different tasks. For example, the large model can be widely used in natural language processing (NLP), computer vision, speech processing and other fields, specifically in computer vision tasks such as visual question answering (VQA), image caption (IC), image generation, etc. It can also be widely used in natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. Therefore, the main application scenarios of the large model include but are not limited to digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.
[0032] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0033] MODeL (Machine-learning Optimization for Dynamical Efficient Learning): A framework for optimizing the training of machine learning models.
[0034] Computational graph: A graphical representation of the computational process, consisting of a series of nodes and edges. Nodes represent operations or functions, and edges represent data flows. In a computational graph, each node represents a computational operation, such as addition, multiplication, convolution, etc. The edges between nodes represent data flows, that is, the output of one node serves as the input of another node. Through the combination of nodes and edges, the computational graph can clearly show the flow and dependencies of the entire computational process, making it easier to understand and optimize. In a neural network, by constructing a computational graph for the neural network, it is easy to perform the backpropagation algorithm, calculate gradients, and update network parameters.
[0035] Model execution plan: During the execution of a deep learning model, the system generates an execution plan based on the model's structure and parameters, which includes the operator execution order and tensor storage plan.
[0036] Operator execution order: refers to the order in which each operator in the model is executed. In the execution plan, operators are sorted according to dependencies to ensure that the input of each operator has been calculated before the operator is executed, so as to ensure that the model is calculated in the correct order and avoid data dependency issues. The execution order of operators in the model has a significant impact on the theoretical memory overhead. A reasonable operator execution order can enable large tensors to reuse memory, thereby reducing memory overhead.
[0037] Tensor storage plan: refers to the storage location and distribution of each tensor in the model during the calculation process. In the execution plan, the input and output tensors of the operator need to be stored in certain locations in the memory or device. A reasonable tensor storage plan can increase the reuse of video memory between tensors and avoid allocation failures caused by video memory fragmentation, thereby optimizing the computing performance of the model and reducing data transmission and storage overhead.
[0038] Lowest-peak memory layout: A memory management technique used to optimize memory usage and allocation. By storing data in memory at the lowest memory address, memory fragmentation and waste are reduced, memory utilization efficiency is improved, and memory access latency is reduced.
[0039] Resource reuse: refers to variables whose life cycles do not overlap and can share the same address space.
[0040] In related technologies, it is proposed to discard some variables in the forward training process through offloading and recomputation, and reacquire these variables in the backward process, or use quantization and compression technology to use fewer bits to express high-precision variables, thereby reducing model overhead. Although these methods can effectively alleviate the pressure on video memory, they usually introduce time and precision overhead.
[0041] In the related art, the memory overhead of the deep learning model is reduced by optimizing the execution plan of the model, but this method has the following defects.
[0042] Defect 1: The MODeL framework is used to convert the problem of optimizing the execution order of operators into the problem of optimizing the life cycle of tensors. The life cycle and address of tensors are optimized based on constraint solving methods. When the model scale becomes larger (such as large models such as BERT and GPT) or more complex optimizers are used, the optimization performance is significantly impaired and the optimization time is long, resulting in low usability and effectiveness.
[0043] Defect 2: A series of heuristic methods are used through XLA technology to optimize the execution order of the model, but these methods are difficult to handle the variability of tensor sizes in the computational graph, resulting in low usability and effectiveness.
[0044] With respect to the above-mentioned defects, no effective solution has been proposed before the present application.
[0045] In addition, proposing an optimization framework for optimizing model execution plans that is simultaneously effective, efficient, and scalable presents the following challenges:
[0046] Challenge 1: Neural Processing (NP) is a computationally difficult problem for optimization: Previous research has shown that optimal scheduling of operators and address arrangement optimization of tensors are both NP-hard problems, and it is difficult to find optimal solutions in linear time.
[0047] Challenge 2: Large computational graphs and high flexibility in operator execution in training scenarios: The computational graph in training scenarios includes three processes: forward propagation pass, backward propagation pass, and weight update pass. As the model size increases, the size of the model computational graph also increases. In addition, the execution of the weight update operation is highly flexible and can be executed at any time after the gradient is generated. These two features have greatly reduced the usability of some methods that were previously very useful in small models or reasoning scenarios (such as constraint solving and traversal);
[0048] Challenge 3: Rich video memory reuse scenarios: Some heuristic methods can effectively reduce model video memory. However, due to the diversity of the life cycle and size of tensors in the model, the address reuse between tensors is very complex, which brings significant challenges to heuristic methods.
[0049] Example 1
[0050] According to an embodiment of the present application, a data processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0051] Considering the huge amount of model parameters of the large model and the limited computing resources of the mobile terminal, the above data processing method provided in the embodiment of the present application can be applied to Figure 1 The application scenarios shown are not limited to these. Figure 1 In the application scenario shown, the large model is deployed in the server 10, and the server 10 can be connected to one or more client devices 20 through a local area network connection, a wide area network connection, an Internet connection, or other types of data networks. The client device 20 here may include but is not limited to: a smart phone, a tablet computer, a laptop computer, a PDA, a personal computer, a smart home device, a vehicle-mounted device, etc. The client device 20 can interact with the user through a graphical user interface to implement the call of the large model, thereby implementing the method provided in the embodiment of the present application.
[0052] In an embodiment of the present application, a system composed of a client device and a server can perform the following steps: the client device obtains a user's request for model training based on a graphical user interface, and sends the request to the server, and the server trains the model based on the request using the method provided in the embodiment of the present application, thereby improving the training efficiency of the model and reducing the resource occupancy and resource overhead of the model. It should be noted that the embodiment of the present application can be performed in the client device when the operating resources of the client device can meet the deployment and operation conditions of the large model.
[0053] Under the above operating environment, this application provides Figure 2 The data processing method shown. Figure 2 1 is a flow chart of a data processing method according to Embodiment 1 of the present application. Figure 2 As shown, the method may include the following steps:
[0054] Step S21, obtaining a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model;
[0055] Step S22, adjusting the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupation requirement of the initial machine learning model;
[0056] Step S23: train the initial machine learning model according to the target adjustment result to obtain the target machine learning model.
[0057] The preset data structure is used to represent the calculation process of the initial machine learning model. It can clearly display the flow and dependencies of the entire calculation process of the initial machine learning model, making it easier for users to understand and optimize the initial machine learning model.
[0058] The execution plan of the initial machine learning model includes two aspects: the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, where the variables can be scalars, vectors, tensors, etc.
[0059] The target adjustment result is used to determine the resource occupancy requirement of the initial machine learning model, which can be understood as being used to determine the resource occupancy of the initial machine learning model after adjusting the execution plan of the initial machine learning model based on a preset data structure.
[0060] When training the initial machine learning model, the embodiment of the present application takes into account that the preset data structure can clearly display the flow and dependencies of the entire calculation process of the initial machine learning model. Therefore, the embodiment of the present application optimizes the execution plan of the initial machine learning model from two aspects: the execution order of the computing units and the variable storage method corresponding to the computing units, thereby minimizing the resource occupancy of the initial machine learning model, such as storage resource occupancy, central processing unit (CPU) resource occupancy, etc., so as to better optimize the initial machine learning model training process, thereby improving the training efficiency of the initial machine learning model, and improving the performance and efficiency of the initial machine learning model.
[0061] In an embodiment of the present application, by obtaining a preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure, that is, optimizing and adjusting the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, the initial machine learning model training process is better optimized, and a target adjustment result for determining the resource occupancy requirement of the initial machine learning model is obtained. After obtaining the target adjustment result, the initial machine learning model is trained based on the target adjustment result, so that the machine learning model training process can be optimized, the model training efficiency can be improved, and the resource overhead of training the initial machine learning model can be reduced, and finally the target machine learning model can be obtained.
[0062] The above-mentioned data processing method provided in the embodiment of the present application can be applied to, but is not limited to, application scenarios involving computational graph processing in the fields of e-commerce services, educational services, legal services, medical services, conference services, social network services, financial product services, logistics services and navigation services, such as: scenarios for training e-commerce service models, scenarios for training educational service models, scenarios for training legal service models, scenarios for training medical service models, etc., which are not limited here.
[0063] According to the embodiment of the present application, by obtaining the preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure, a target adjustment result for determining the resource occupation demand of the initial machine learning model is obtained, and finally, the initial machine learning model is trained based on the target adjustment result to obtain a target machine learning model. Through the above method, the purpose of optimizing the training process of the machine learning model and improving the training efficiency of the machine learning model is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource occupation demand and resource overhead of the model, and ensuring the effectiveness, efficiency and scalability of the optimization process without introducing modifications to the model training steps and other overheads, thereby solving the technical problems of low performance, long optimization time and poor usability of the method of optimizing the execution order of operators in the related technology.
[0064] In an optional embodiment, the preset data structure includes: a calculation graph. In step S22, the execution plan of the initial machine learning model is adjusted based on the preset data structure to obtain a target adjustment result, including the following method steps:
[0065] Step S221, performing sub-graph segmentation on the computation graph to obtain a segmentation result, wherein the segmentation result is used to determine a division relationship between multiple sub-graphs obtained by segmenting the computation graph through a preset data structure;
[0066] Step S222: Adjust the execution plan of the initial machine learning model based on the segmentation result to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of operators in the calculation graph and the variable storage method corresponding to the operators.
[0067] In an embodiment of the present application, the preset data structure may be a computational graph, which is a computational graph of an initial machine learning model, that is, a computational graph of a model to be trained defined by a user. The computational graph may be understood as converting the intermediate layer of the initial machine learning model into a computational execution graph that graphically represents the computational process. The computational graph may clearly display the flow and dependencies of the entire computational process of the initial machine learning model, making it easier for users to understand and optimize the initial machine learning model. Optionally, the computational graph may be represented by a tree structure.
[0068] When training the initial machine learning model, considering that the computational graph can clearly display the flow and dependencies of the entire computational process of the initial machine learning model, the embodiment of the present application adopts a graph-based memory optimization framework (GEMO) to optimize the execution plan of the initial machine learning model from two aspects: the operator execution order and the variable storage method of the computational graph, so as to minimize the resource occupation of the initial machine learning model, such as storage resource occupation, CPU resource occupation, etc., so as to better optimize the initial machine learning model training process, improve the training efficiency of the initial machine learning model, and improve the performance and efficiency of the initial machine learning model.
[0069] Figure 3 is a schematic diagram of the architecture of a graphics memory optimization framework based on a graph according to Embodiment 1 of the present application, such as Figure 3As shown in the figure, the GEMO framework consists of three parts, namely the input, graph subdivision stage and solution stage. Among them, the input part is used to determine the computational graph (Graph), the nodes (Operators) and tensors (Tensors) of the computational graph. The graph subdivision stage is used to determine the memory-insensitive nodes (Memory-insensitiveOperators), weight update schedulers (Weight UpdateScheduler) and subgraph tree constructors (Subgraph Tree Constructor) in the computational graph. The solution stage is used to find a better operation order and tensor storage layout through operation order optimization (Operator Ordering Optimization), tensor memory layout optimization (Tensor Memory Layout Optimization) and integer linear programming optimizer (Integer Linear Program Optimizer, referred to as ILP optimizer) to maximize the computing efficiency and performance and reduce the model's video memory overhead. The specific operation process can be found in the description below.
[0070] Sub-graph segmentation of a computational graph can be understood as dividing the computational process of the computational graph into multiple sub-computation processes, thereby obtaining multiple sub-graphs. By segmenting the computational graph of a model, a computational graph with a complex structure can be simplified, reducing the complexity of the model's computational graph.
[0071] Since there are dependencies between multiple sub-computation processes in the computational graph, the multiple sub-graphs obtained by segmentation can also be represented by a tree structure, thereby obtaining a sub-graph tree, that is, the segmentation result. The segmentation result of the tree structure represents the division relationship between multiple sub-graphs.
[0072] The execution plan of the initial machine learning model includes two aspects: the operator execution order and the variable storage method. By understanding the execution plan of the initial machine learning model, the efficiency and performance of the initial machine learning model in actual operation can be evaluated and optimized, so as to better optimize the initial machine learning model training process, improve the training efficiency of the initial machine learning model, and thus improve the execution speed and accuracy of the initial machine learning model.
[0073] In an embodiment of the present application, adjusting the execution plan of the initial machine learning model based on the segmentation result can be understood as optimizing the operator execution sequence and variable storage method of the initial machine learning model based on the segmentation result. By reasonably adjusting the operator execution sequence and variable storage method of the initial machine learning model based on the segmentation result, the target adjustment result is obtained, thereby reducing the resource occupation demand of the initial machine learning model and improving resource reuse between variables, that is, improving the resource utilization efficiency of the model, thereby reducing the resource overhead of the initial machine learning model.
[0074] It can be seen that the data processing method provided in the embodiment of the present application obtains the calculation graph corresponding to the initial machine learning model and segments the calculation graph of the initial machine learning model, thereby reducing the complexity of the calculation graph of the initial machine learning model, and then converts the optimization problem of the large-scale and highly complex calculation graph into the optimization problem of multiple small-scale and low-complexity subgraphs, thereby reducing the complexity of the calculation graph optimization. Moreover, even if the scale of the calculation graph continues to increase, the complexity of the calculation graph still depends on the complexity of the largest sub-calculation process in the calculation graph, and the scale of the largest sub-calculation process is usually more controllable, thereby making the optimization process highly scalable. In addition, the data processing method provided in the embodiment of the present application can improve the memory usage efficiency of the model without introducing modifications to the model training steps and other overheads, reduce the resource occupation requirements and resource overhead of the model, and can effectively ensure the effectiveness, efficiency and scalability of the optimization process.
[0075] In an optional embodiment, the computation graph includes: a plurality of nodes and edges for connecting different nodes, the plurality of nodes are used to represent operators in the initial machine learning model, and the edges are used to represent variables corresponding to the operators. In step S221, the computation graph is segmented into subgraphs to obtain segmentation results, including the following method steps:
[0076] Step S2211, searching for some nodes from the computation graph and determining the scheduling position of the weight update operation from the computation graph, wherein some nodes have a fixed execution time;
[0077] Step S2212, split the computation graph into subgraphs based on some nodes and scheduling positions to obtain a split result.
[0078] The computation graph is a tree structure, including multiple nodes and edges for connecting different nodes, wherein multiple nodes are used to represent operators in the initial machine learning model, and edges are used to represent variables corresponding to the operators. In the embodiment of the present application, the variables can be scalars, vectors, tensors, etc.
[0079] When a node in a computational graph executes the computation process of the corresponding operator, there is a computation time, that is, the execution time of the node. Usually, the execution time of a node is estimated by the amount of computation required for the node and the speed of the computational resources. The amount of computation can be measured by indicators such as the number of node operations, input and output sizes. The speed of computational resources can be measured by hardware performance indicators (such as processor clock frequency, memory bandwidth, etc.).
[0080] In an embodiment of the present application, some nodes are nodes with fixed execution time in the calculation graph, which are called Memory-insensitive Operators, that is, nodes without memory sensitivity. It can be understood that the nodes with fixed execution time will not be affected by the input data, and no matter how the scale of the input data changes, the execution time of the nodes with fixed execution time will always remain unchanged. And the execution of nodes with fixed execution time does not depend on the output of other nodes, so it can be executed independently without waiting for the results of other nodes, so that it can be executed in parallel, improving computing efficiency. In addition, the calculation of nodes with fixed execution time does not require iteration, that is, each node only needs to be executed once to get the result. Compared with iterative calculation, the execution time of nodes with fixed execution time is easier to predict and optimize.
[0081] In the computation graph, an independent region can be separated between any two nodes, and the execution order of nodes in the independent region is diverse and uncertain. However, since the memory-insensitive operator has a fixed execution time, the execution order in the region separated between any memory-insensitive operators is clear, which facilitates subsequent optimization operations.
[0082] During model training, the gradient is calculated using the back-propagation algorithm. The back-propagation algorithm first calculates the gradient of the output layer based on the loss function, then passes the gradient to the previous layer based on the chain rule, and then uses the same method to calculate the gradient of the previous layer, and then passes it forward in sequence until the gradient of the input layer is calculated. In the calculation process of each layer, the gradient is calculated based on the output of the current layer and the gradient of the previous layer. For each parameter, the gradient can be calculated by multiplying the output of the current layer by the gradient of the previous layer.
[0083] Once the gradient of the parameters is obtained, optimization algorithms such as gradient descent can be used to update the parameters so that the value of the loss function gradually decreases, thereby optimizing the performance of the network. It can be understood that once the gradient is generated, the corresponding weight update operation meets the execution conditions. However, the execution time of the weight update operation has a significant impact on the model memory overhead. For some simple optimizers, such as SGD, the weight update operation can be executed immediately to consume the generated gradient, thereby reducing the memory pressure. However, for more complex optimizers, such as Adam, when executing the weight update operation, it also involves the calculation of variables such as momentum, and it is necessary to generate multiple temporary buffers during the weight update operation. The size of the temporary buffer is related to the weight size. If the weight update operation is executed immediately, the model itself will have a relatively large memory pressure at this time (for example, when the backward mode of back propagation has just begun, the activation value generated by the forward mode of back propagation accounts for a large proportion of the memory), which will further increase the model memory requirements. However, if all weight update operations are executed at the end of the entire backward mode, all gradients need to be saved for a long time, which will also increase the model memory requirements.
[0084] Taking into account the above-mentioned problem of weight update operation time selection, in the embodiment of the present application, the model's video memory overhead is reduced by postponing some low video memory overhead weight update operations.
[0085] In the embodiment of the present application, by determining the scheduling positions of some nodes with fixed execution time and some weight update operations with low video memory overhead that need to be postponed, the computation graph is segmented into subgraphs based on the nodes and the scheduling positions, thereby obtaining the segmentation results. By considering the structural characteristics of the model and the characteristics of video memory usage during training, the computation graph is reasonably divided, thereby reducing the complexity of the computation graph, facilitating the subsequent optimization process of the computation graph, and ensuring the reliability of the optimization results.
[0086] In an optional embodiment, in step S2211, searching for some nodes from the computation graph includes the following method steps:
[0087] Step S22111, determining a forward mode phase calculation graph and a backward mode phase calculation graph from the calculation graph;
[0088] Step S22112, obtaining the first execution time and the second execution time of each node in the forward mode phase calculation graph and the backward mode phase calculation graph, wherein the first execution time is the earliest execution time of each node, and the second execution time is the latest execution time corresponding to the first execution time;
[0089] Step S22113, based on the first execution time and the second execution time, search for some nodes in the calculation graph.
[0090] When searching for some nodes in the computation graph, it is not necessary to consider the computation graph of the model's weight update phase. It is only necessary to consider the computation graphs of the forward mode (forward pass) and the backward mode (backward pass) phases, and calculate the earliest executable time and the latest executable time of all nodes in the forward mode phase computation graph and the backward mode phase computation graph. Based on the earliest executable time and the latest executable time, some nodes can be searched from the computation graph to determine the nodes with fixed execution time.
[0091] Optionally, the earliest executable time of a node can be determined by calculating the number of all predecessor nodes of the current node. Correspondingly, the latest executable time of a node can be determined by calculating the number of all successor nodes of the current node. A node whose earliest executable time and latest executable time are equal is a memory-insensitive operator.
[0092] In an optional embodiment, in step S2211, determining the scheduling position of the weight update operation from the computation graph includes the following method steps:
[0093] Step S22114, using the forward activation values to be saved and the size of the variables generated in the forward mode stage, calculate the resource usage peak of the initial machine learning model;
[0094] Step S22115, at the time of executing the weight update operation, the resource occupation requirement of the weight update operation is calculated by using the forward activation value that has not been released and the video memory consumption of the temporary buffer;
[0095] Step S22116, based on the resource occupancy peak and the resource occupancy requirement of the weight update operation, determine the scheduling position of the weight update operation from the calculation graph.
[0096] When determining the scheduling position of the weight update operation from the computational graph, all forward activation values that need to be saved to the backward phase are considered. The peak resource usage of the initial machine learning model can be calculated using the forward activation values to be saved and the size of the variables generated in the forward mode phase.
[0097] Exemplarily, the resource occupancy peak esti_pm may be calculated based on formula (1).
[0098]
[0099] Among them, e represents a variable, E atvs Refers to the set of all long life cycle activation values, size e Represents the size of the variable e.
[0100] For each weight update operation, it is necessary to estimate the memory requirements of executing the weight update operation immediately when the gradient is generated. The memory requirements consist of two parts, including the forward activation values that have not been released and the memory consumption of the temporary buffer in the weight update operation. Therefore, at the time of executing the weight update operation, the memory occupancy requirements of the weight update operation can be calculated by the forward activation values that have not been released and the memory consumption of the temporary buffer.
[0101] For example, the memory usage requirement mem_used for the weight update operation can be calculated based on formulas (2) and (3): t .
[0102]
[0103] mem_used t =mem_atvs t +α·size grad (3)
[0104] Among them, is_alive e,t Indicates whether the variable e is saved in the video memory at time t. A value of 1 indicates existence, and a value of 0 indicates non-existence. mem_atvs t Indicates the sum of the sizes of all unreleased activation values at time t. grad represents the size of the gradient corresponding to the weight update operation. The parameter α represents the number of temporary buffers in the weight update operation. For example, Figure 4 As shown, Figure 4 is a schematic diagram of a calculation graph structure of an optimizer according to Embodiment 1 of the present application, Figure 4 Taking the Adam optimizer as an example, the structure of Adam in the computational graph and the weight update process during back propagation are shown. It can be seen that the temporary buffer required for Adam's weight update operation uses the lowest peak memory layout and requires three layers of layout, so α = 3.
[0105] According to the resource occupancy peak and the resource occupancy requirement of the weight update operation, the scheduling position of the weight update operation can be reasonably determined from the calculation graph, and some low-resource-overhead weight update operations that are postponed can be reasonably determined. The weight update operations with low resource overhead can be scheduled, thereby reducing the resource overhead of the model.
[0106] Optionally, a resource occupancy peak threshold m and a ratio r of the gradient size corresponding to the weight update operation to the average value of all variable sizes in the calculation graph may be predefined. When the resource occupancy peak when any weight update operation is immediately executed is greater than the predefined resource occupancy peak threshold m, and the ratio of the gradient size corresponding to the weight update operation to the average value of all variable sizes in the calculation graph is greater than the predefined ratio r, it can be determined that the weight update operation needs to be postponed. Exemplarily, the ratio r defaults to 1, and the strength of postponing the weight update operation can be controlled by adjusting the size of r.
[0107] In an optional embodiment, in step S2212, the computation graph is segmented into subgraphs based on some nodes and scheduling positions to obtain segmentation results, including the following method steps:
[0108] Step S22121, splitting the computation graph into subgraphs based on some nodes and scheduling positions to obtain multiple first subgraphs, wherein the multiple first subgraphs are independent subgraphs for creating and releasing variables in the same subgraph;
[0109] Step S22122, performing subgraph segmentation on at least part of the plurality of first subgraphs to obtain a plurality of second subgraphs, wherein the plurality of second subgraphs are non-independent subgraphs in which variables are created and released respectively in different subgraphs;
[0110] Step S22123, taking the computation graph as the root node, using multiple first subgraphs and multiple second subgraphs to construct a subgraph tree to obtain a segmentation result.
[0111] The first subgraph can be understood as an independent subgraph, which means that all variables are created and released within this subgraph. The second subgraph can be understood as a non-independent subgraph, which allows variables to be created and released in different subgraphs.
[0112] Considering the structural characteristics of the computational graph, in order to ensure that a single subgraph can express the complete life cycle of all variables as much as possible, when traversing the computational graph, we first look for multiple first subgraphs that can form independent subgraphs for segmentation from the inside to the outside. Afterwards, in order to ensure that each subgraph can be efficiently applied to some precise but complex methods, it is necessary to further split the overly large independent subgraphs into multiple non-independent subgraphs of sufficiently small size, that is, to split multiple first subgraphs into multiple second subgraphs.
[0113] After the segmentation obtains the independent subgraphs and the dependent subgraphs, the complete computational graph is used as the root node, and a subgraph tree is constructed according to the dependency relationship between the multiple first subgraphs and the multiple second subgraphs, thereby obtaining the segmentation result. For example, Figure 5 As shown, Figure 5 This is a schematic diagram of a subgraph tree according to Example 1 of the present application. Figure 5The height of the subgraph tree in is 3. The nodes in the subgraph tree represent subgraphs, and the edges represent partitioning relationships. The first-level root node represents the complete computational graph, the second-level nodes represent independent subgraphs obtained by partitioning the complete computational graph, and the third-level nodes represent non-independent subgraphs obtained by partitioning the independent subgraphs of the upper level.
[0114] It can be understood that in a tree structure, a leaf node is a node without child nodes, which can also be understood as the end node of the tree. A non-leaf node is an intermediate node of the tree, which refers to a node with one or more child nodes. Figure 5 In the subgraph tree shown, non-leaf nodes can represent independent subgraphs, and leaf nodes can represent non-independent subgraphs and partially independent subgraphs.
[0115] Later, in the GEMO solution phase, the operator execution order can be optimized by traversing the subgraph tree, performing optimization on each leaf node in a multi-process manner, and recursively reducing the sub-division results for non-leaf nodes.
[0116] In an optional embodiment, in step S222, the execution plan of the initial machine learning model is adjusted based on the segmentation result to obtain a target adjustment result, including the following method steps:
[0117] Step S221, adjusting the execution order of operators of the computation graph based on the segmentation result to obtain a first adjustment result;
[0118] Step S222, adjusting the variable storage plan of the computation graph based on the segmentation result to obtain a second adjustment result;
[0119] Step S223, determining a target adjustment result through the first adjustment result and the second adjustment result.
[0120] When adjusting and optimizing the execution plan of the initial machine learning model based on the segmentation results, it is necessary to perform adjustments and optimizations from two aspects: the operator execution order and the variable storage plan. Thus, based on the first adjustment result of the operator execution order and the second adjustment result of the variable storage plan, the target adjustment result of the computational graph is jointly determined, thereby achieving the technical effect of reducing the model's video memory overhead.
[0121] In an optional embodiment, in step S221, adjusting the execution order of operators of the computation graph based on the segmentation result to obtain a first adjustment result includes the following method steps:
[0122] Step S2211, determining multiple operator execution sequences of the initial machine learning model based on the segmentation result, and determining multiple independent regions in the calculation graph based on some nodes found in the calculation graph;
[0123] Step S2212, obtaining first resource occupancy peak values of multiple independent regions under multiple operator execution sequences, wherein the first resource occupancy peak value is a theoretical peak value determined by the multiple independent regions;
[0124] Step S2213: Adjust the execution order of operators in the computation graph according to the first resource occupancy peak value to obtain a first adjustment result.
[0125] When adjusting and optimizing the operator execution order of the computation graph based on the segmentation results, considering that Memory-insensitive Operators can divide the computation graph into multiple independent states (IS), the theoretical resource demand peak of the entire computation graph is determined by multiple independent states. Therefore, the operator execution order can be adjusted and optimized by determining the resource occupancy peaks of multiple independent states.
[0126] First, it is necessary to determine the multiple operator execution sequences in the initial machine learning model, that is, the set of all possible operator execution sequences in the calculation graph of the initial machine learning model, and determine the multiple independent regions IS composed of memory-insensitive operators. Then determine the first resource occupancy peak of multiple independent regions IS under multiple operator execution sequences, so as to determine the theoretical resource demand peak of the entire calculation graph.
[0127] Exemplarily, the first resource occupancy peaks of the multiple independent areas may be determined by formula (4).
[0128]
[0129] Where S represents the set of all possible operator execution sequences in the computation graph G. Tp(G,s) represents the theoretical resource usage peak of the computation graph G under sequence s. Similarly, Tp(IS i ,s i ) represents the computational graph IS i In sequence s i The theoretical resource usage peak value under .
[0130] Afterwards, each leaf node is adjusted and optimized based on the first resource occupancy peak value, so that the theoretical resource occupancy peak values of the current multiple subgraphs are minimized, that is, the theoretical resource demand peak value of the entire computational graph is minimized, thereby obtaining the first adjustment result.
[0131] Exemplarily, each leaf node may be adjusted and optimized using formula (5) to obtain a first adjustment result.
[0132]
[0133] In an optional embodiment, in step S2213, adjusting the execution order of operators of the computation graph according to the first resource occupancy peak value to obtain a first adjustment result includes the following method steps:
[0134] Step S22131, determining a first variable and a second variable according to the first resource occupancy peak value, wherein the first variable is used to determine whether to create the variable, and the second variable is used to determine whether to save the variable in the video memory;
[0135] Step S22132, adjusting the variable life cycle based on the first variable and the second variable to obtain an adjusted life cycle;
[0136] Step S22133: Use the adjusted life cycle to adjust the execution order of operators in the computation graph to obtain a first adjustment result.
[0137] When adjusting the execution order of operators of the computational graph according to the first resource occupancy peak value, in order to ensure the effectiveness of the optimization solution, a constraint solving method may be used to optimize each subgraph.
[0138] Based on the GEMO framework, the optimization problem of the operator execution order is transformed into the problem of variable life cycle optimization. By adding the first variable C and the second variable P to the variable, it is described whether the variable is created and whether it is saved in the video memory. A series of constraints are added to the first variable C and the second variable P to ensure the correctness of the derived operator execution order. For example, constraints such as the creation time of homologous variables must be the same and a variable can only be created when all the previous order variables are saved in the video memory can be added, which are not limited here.
[0139] In an embodiment of the present application, after determining the first variable C and the second variable P based on the first resource occupancy peak value, the variable life cycle can be adjusted and optimized based on the first variable C and the second variable P to obtain an optimized variable life cycle, that is, an adjusted life cycle.
[0140] After optimizing the variable life cycle, the execution order of the operator is derived according to the optimized variable life cycle, that is, based on the optimized operator execution order of all subgraphs, the operator execution order of the non-leaf node is derived, thereby adjusting the operator execution order of the computation graph to obtain a first adjustment result. Exemplarily, the operator execution order of the non-leaf node can be expressed by formula (6).
[0141] s=[s0,s1,…,s n ] (6)
[0142] Therefore, by dividing a large-scale computational graph into smaller subgraphs and constraining the size of a single subgraph, the constraint solving method can be prevented from being constrained by the solving performance, thereby ensuring the effectiveness of the optimization solution while ensuring the efficiency of the optimization.
[0143] In an optional embodiment, in step S222, adjusting the variable storage plan of the computation graph based on the segmentation result to obtain a second adjustment result includes the following method steps:
[0144] Step S2221, respectively obtaining variable storage plans of multiple subgraphs based on the segmentation results, and classifying the variables based on the segmentation results to obtain classification results;
[0145] Step S2222, connecting the variable storage plans of the multiple subgraphs to determine a second resource occupancy peak value, wherein the second resource occupancy peak value is a resource occupancy peak value of the variable storage plan of the computation graph;
[0146] Step S2223, adjust the variable storage plan of the calculation graph according to the second resource occupancy peak value and the classification result to obtain a second adjustment result.
[0147] When adjusting and optimizing the variable storage plan of the computation graph, the variable storage plan of the entire computation graph can be derived from the multiple subgraph variable storage plans. Exemplarily, the relationship between the multiple subgraph variable storage plans and the variable storage plan of the entire computation graph can be expressed by formula (7).
[0148]
[0149] Among them G i Represents a subgraph of the computational graph G. M is the set of all possible variable storage plans of G. The operation "+" represents the connection operation of variable storage plans between subgraphs. Peak[m(G)] represents the resource usage peak of variable storage plan m(G). Storage plan m(G) contains the address offset (Offset) information of all variables in G.
[0150] In an embodiment of the present application, variable storage plans of multiple subgraphs are obtained respectively based on the segmentation results, and the variable storage plans of the multiple subgraphs are connected, so as to obtain the variable storage plan of the entire calculation graph, that is, the above formula (7), so as to determine the second resource occupancy peak.
[0151] During optimization, in order to ensure that the peak resource usage of the variable storage plan of the entire computational graph is minimized, it is necessary to ensure that the peak resource usage of each subgraph is minimized. Therefore, for each leaf node, the optimization goal is to minimize the peak resource usage of the variable storage plan, which can be expressed by formula (8).
[0152]
[0153] In addition, in order to ensure the validity of the join operation of the variable storage plan, some additional constraints need to be made on the subgraph.
[0154] Considering that for a subgraph, there is usually more than one variable storage plan that can achieve the lowest resource usage peak. Figure 6 As shown, Figure 6 It is a schematic diagram of a variable storage plan according to Example 1 of the present application. Figure 6 The squares represent variables, the horizontal axis represents the variable life cycle, and the vertical axis represents the address space where the variables are stored. Since some storage plans may contain some long-term resource fragments, the overall resource usage peak increases when the variables are spliced. At this time, it is necessary to use the LLAF (Long-lived activations first) algorithm for scheduling and adopt another variable storage plan to achieve the lowest resource usage peak. In other words, when optimizing a single subgraph, it is necessary to constrain the location distribution of activation values with a long life cycle to ensure that they are continuously distributed at low addresses to avoid the situation of containing long-term resource fragments.
[0155] However, since the training calculation graph is usually complex, it is difficult to ensure that all variables are created and released in the same subgraph. If each subgraph is optimized, there will be a situation where one variable corresponds to multiple addresses, thereby increasing the difficulty of connecting operations between storage plans. Therefore, the embodiment of the present application takes into account the characteristics of resource usage during training and allocates each variable to a suitable subgraph according to the following strategy to perform optimization.
[0156] In the embodiment of the present application, the variables are classified based on the segmentation results to obtain classification results. The classification results classify the variables based on each subtask perspective, and the following four categories can be obtained:
[0157] The first category: CIFI, Created Inside but Freed Inside the subgraph, indicates variables created inside the subgraph and released inside the subgraph;
[0158] The second category: CIFO, Created Inside but Freed Outside the subgraph, indicates variables created inside the subgraph and released outside the subgraph;
[0159] The third category: COFI, Created Outside but Freed Inside the subgraph, indicates variables created outside the subgraph and released inside the subgraph;
[0160] The fourth category: COFO, Created Outside and Freed Outside the subgraph, indicates variables created outside the subgraph and released outside the subgraph.
[0161] By classifying the variables, it is possible to optimize the variables reasonably to avoid the situation where one variable corresponds to multiple addresses, thereby reducing the difficulty of connection operations between storage plans.
[0162] After determining the second resource occupancy peak value and the classification result, the variable storage plan of the computational graph is adjusted based on the second resource occupancy peak value and the defined classification result, thereby obtaining a second adjustment result.
[0163] In an optional embodiment, in step S2223, adjusting the variable storage plan of the computation graph according to the second resource occupancy peak value and the classification result to obtain a second adjustment result includes the following method steps:
[0164] Step S22231, taking the second resource occupancy peak as the adjustment target, respectively perform resource reuse adjustment on the first classification variable and the second classification variable in the classification result in multiple subgraphs, and adjust the variable storage plan for the third classification variable in the classification result, to obtain a second adjustment result, wherein the first classification variable is created in the forward mode stage calculation graph and released in multiple subgraphs, the second classification variable is created in the backward mode stage calculation graph and released outside the multiple subgraphs, and the third classification variable is created and released in the same subgraph of the multiple subgraphs.
[0165] Considering that the activation values created in the forward mode can reuse the video memory of the released temporary buffer, the temporary buffer created in the backward mode can reuse the video memory of the released activation values. Figure 7 As shown, Figure 7 This is a schematic diagram of a variable life cycle relationship according to Example 1 of the present application. It can be seen that the activation value can generate video memory reuse, that is, resource reuse, with the temporary buffer created before the activation value is released and the temporary buffer created after the activation value is released.
[0166] In order to maximize the reuse between activation values and temporary buffers, each subgraph chooses to optimize the variables created in the forward mode with the attribute COFI and the variables created in the backward mode with the attribute CIFO. In addition, since most of the variables in the forward mode are saved as activation values in the backward mode, there are relatively few temporary buffers in the forward mode, while in the backward mode, for the calculation, transmission and update of gradients, there will be relatively many temporary buffers. Therefore, for the activation values that are not created and released in the same subgraph, they will be optimized in the released subtask. Since the subgraph can represent the complete life cycle of the CIFI variable, the subgraph will perform optimization on the CIFI variable. However, since it is difficult for the COFO variable to generate address reuse with other variables within the subgraph, the subgraph does not consider the COFO variable.
[0167] In an embodiment of the present application, when adjusting the variable storage plan of the computational graph based on the second resource occupancy peak and the classification result, the second resource occupancy peak can be used as the adjustment target to ensure that the resource occupancy peak of the variable storage plan of the entire computational graph is minimized, and resource reuse adjustments are performed on the first classification variable created in the forward direction and with the attribute COFI and the second classification variable created in the backward direction and with the attribute CIFO in the classification results in multiple subgraphs. At the same time, the variable storage plan is adjusted for the third classification variable CIFI in the classification result to obtain a second adjustment result.
[0168] In addition, while ensuring the above constraints, when using the constraint solving method based on the GEMO framework to optimize the variable storage plan, it is necessary to create an expressed variable Offset for each variable, and in order to ensure the correctness of address reuse between variables, it is also necessary to add constraints to the variable Offset to ensure that only variables with non-overlapping life cycles can be stored at the same address.
[0169] Based on the optimized variable storage plan of each subgraph, the non-leaf node variable storage plan can be derived as follows:
[0170]
[0171] Formula (9) represents the process of splicing leaf node variable plans, where base i Represents the subgraph G i The base address of the overall variable storage plan. In order to avoid the following during the splicing process Figure 6 Long-term fragmentation in the calculation base i Only activation values with long lifecycles are considered. i [e] represents the subgraph G i The offset of variable e in G iThe global offset (base) of the overall variable storage plan plus the internal offset of the variable can be obtained to obtain its storage address m after the variable plan is fused. j [e],m j That is, the storage plan of its parent node.
[0172] For example, Figure 8 As shown, Figure 8 This is a schematic diagram of a leaf node fusion process according to Example 1 of the present application. Figure 8 The following example illustrates the concatenation process of subgraphs G1 and G2 when the variable Offset is 0.
[0173] In the embodiment of the present application, considering that address conflicts may occur between variables of different subtasks during the specification process, in order to handle these address conflicts, the variables with smaller size and shorter life cycle are reallocated at the end. Since such variables with smaller size and shorter life cycle are usually less, and the addresses of other variables have been determined, the reallocation process can also be completed using an accurate but highly complex method.
[0174] Therefore, the data processing method provided in the embodiment of the present application, based on the divide-and-conquer idea of GEMO, proposes a method of subgraph disassembly-result reduction, thereby significantly reducing the complexity of the optimization problem for large-scale and complex computational graphs. In addition, by considering the structural characteristics of the model and the characteristics of resource usage during training, the limitations that may be introduced in the divide-and-conquer process are overcome, and a low-resource-overhead weight update scheduling scheme and subtask optimization behavior constraints are proposed. A highly effective constraint solving method is used to handle resource reuse between variables, ensuring the reliability of the optimization results while providing high efficiency and high scalability.
[0175] In an optional embodiment, a graphical user interface is provided by a terminal device, and the content displayed by the graphical user interface at least partially includes a model execution plan optimization scenario, and the data processing method further includes the following method steps:
[0176] Step S251, in response to a first touch operation on the graphical user interface, displaying an initial resource occupation result of the initial machine learning model in the current training process, wherein the initial resource occupation result includes at least one of the following: a storage resource occupation result of the initial machine learning model in the current training process, and a processing resource occupation result of the initial machine learning model in the current training process;
[0177] Step S252, in response to the second touch operation on the graphical user interface, when a preset adjustment opportunity is met, the execution plan is adjusted based on the segmentation result to obtain a target resource occupation result.
[0178] The terminal device may be the client device 20 mentioned above, and the graphical user interface may be a user interface on the client device 20 that enables the user to perform various operations through input devices such as a mouse, keyboard and / or touch screen, thereby interacting with a computer operating system or application. The graphical user interface at least displays a model execution plan optimization scenario.
[0179] The graphical user interface also includes a first control (or a first touch area). When a first touch operation acting on the first control (or the first touch area) is detected, the initial resource occupancy results of the initial machine learning model during the current training process are displayed on the graphical user interface.
[0180] In an embodiment of the present application, a user may perform a first touch operation on a graphical user interface, so that the graphical user interface will display the initial resource occupancy result of the initial machine learning model in the current training process based on the user's first touch operation, so as to provide feedback to the user. The initial resource occupancy result includes, but is not limited to, the storage resource occupancy result of the initial machine learning model in the current training process, the processing resource occupancy result of the initial machine learning model in the current training process, etc., so as to facilitate the user to observe the resource occupancy of the initial machine learning model in the current training process.
[0181] The graphical user interface also includes a second control (or a second touch area). When a second touch operation acting on the second control (or the second touch area) is detected, the execution plan of the initial machine learning model will be adjusted based on the segmentation result obtained by sub-graph segmentation of the initial machine learning model when the preset adjustment timing is met, so as to reduce the resource occupation of the initial machine learning model and obtain the target resource occupation result.
[0182] The preset adjustment time may be the current moment, or a moment after a preset time period. In an embodiment of the present application, the execution plan may be adjusted based on the segmentation result immediately after the user performs the second touch operation, i.e., immediate optimization, or the execution plan may be adjusted based on the segmentation result after a period of time after the user performs the second touch operation, i.e., delayed optimization, so as to obtain the target resource occupancy result. Optionally, delayed optimization may be started when the resource occupancy of the initial learning model reaches a preset threshold.
[0183] In an embodiment of the present application, the user can perform a second touch operation on the graphical user interface, thereby customizing the time for optimizing the initial machine learning model according to actual needs, thereby reducing the resource usage of the initial machine learning model.
[0184] It should be noted that the first touch operation and the second touch operation can both be operations in which a user touches the display screen of the terminal device with a finger and touches the terminal device. The touch operation can include single-point touch and multi-point touch, wherein the touch operation of each touch point can include click, long press, heavy press, swipe, etc. The first touch operation and the second touch operation can also be touch operations implemented by input devices such as a mouse and a keyboard.
[0185] It can be understood that when the operating resources of the client device 20 can meet the deployment and operation conditions of the initial machine learning model, the initial machine learning model in the embodiment of the present application can be deployed in the client device 20 for operation.
[0186] On the contrary, when the operating resources of the client device 20 cannot meet the deployment and operation conditions of the initial machine learning model, the initial machine learning model in the embodiment of the present application can be deployed and run in the server 10. The user can perform a touch operation on the graphical user interface in the client device 20, so that the client device 20 sends the instruction corresponding to the touch operation to the server 10, and the server 10 determines the corresponding response information based on the instruction, and feeds back the response information to the client device 20, which is displayed by the graphical user interface in the client device 20.
[0187] In an optional embodiment, in step S252, the execution plan is adjusted based on the segmentation result to obtain the target resource occupation result, including the following method steps:
[0188] Step S2521, hierarchically adjusting the execution plan based on the segmentation result to obtain multiple candidate resource occupation results;
[0189] Step S2522, in response to a third touch operation on the graphical user interface, selecting a target resource occupation result from a plurality of candidate resource occupation results;
[0190] Step S2523: Display the target resource occupation result in the graphical user interface.
[0191] The hierarchical adjustment of the execution plan can be understood as determining different degrees of adjustment methods for the execution plan based on the processing performance of the hardware device, thereby obtaining the resource occupancy results of the initial machine learning model after adjustment using different adjustment methods, that is, obtaining multiple candidate resource occupancy results.
[0192] The graphical user interface also includes a third control (or a third touch area), and when a third touch operation acting on the third control (or the third touch area) is detected, a target resource occupation result is determined from multiple candidate resource occupation results. It can be understood that the third touch operation can be an operation for the user to select a target resource occupation result from multiple candidate resource occupation results.
[0193] After selecting the target resource occupancy result, the target resource occupancy result is displayed in the graphical user interface, which means that the execution plan is adjusted in a manner corresponding to the target resource occupancy result, so that after the execution plan of the initial machine learning model is adjusted, the resource occupancy of the initial machine learning model is optimized to the target resource occupancy result.
[0194] For example, in the embodiment of the present application, after obtaining the segmentation result, the hardware processing performance of the terminal device is combined with the calculation complexity factor, the calculation efficiency factor, etc. to determine the adjustment percentage of the execution plan, such as simple adjustment, large adjustment, etc., and then obtain the candidate resource occupancy results corresponding to the simple adjustment, large adjustment, etc. The user can select the degree of adjustment of the execution plan based on multiple candidate resource occupancy results, thereby optimizing the execution plan according to the degree of adjustment selected by the user, reducing the resource occupancy of the initial machine learning model, obtaining the target resource occupancy result, and displaying the target resource occupancy result in the graphical user interface.
[0195] It is easy to understand that the beneficial effects of the data processing method provided by the present application include the following points.
[0196] Beneficial effect (1): the data processing method provided by the present application can improve the resource utilization efficiency of the model and reduce the resource occupation requirement of the model without introducing modifications to the training steps and other overheads;
[0197] Beneficial effect (2): The data processing method provided by the present application is based on the divide-and-conquer concept and proposes a subgraph decomposition-result reduction method, which significantly reduces the complexity of the optimization problem for large-scale and complex-structured computational graphs.
[0198] Beneficial effect (3): The data processing method provided by the present application takes into account the structural characteristics of the model and the resource usage characteristics of the training process, proposes a low-resource-overhead weight update scheduling scheme and subtask optimization behavior constraints, and introduces a highly effective constraint solving method to handle the reuse between variables, thereby ensuring the reliability of the optimized execution sequence and variable storage plan;
[0199] Beneficial effect (4): The data processing method provided by the present application provides a tree-based algorithm implementation, which automatically realizes the generation and optimization of subtasks and ensures the parallel execution between subtasks to better support the use of high-complexity methods;
[0200] Beneficial effect (5): The data processing method provided by the present application can display the resource usage of the model to the user, and can determine the degree of optimization of the execution plan of the model based on the user's selection, that is, it can optimize the resource usage of the model according to the actual needs of the user.
[0201] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0202] In addition, it should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0203] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), including several instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0204] Example 2
[0205] In the operating environment as in Example 1, the present application provides Fig. 9 A data processing method is shown. Fig. 9 is a flow chart of a data processing method according to Embodiment 2 of the present application, such as Fig. 9 As shown, the data processing method includes:
[0206] Step S91, obtaining a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model;
[0207] Step S92, under the video memory optimization framework, adjust the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupancy requirements of the initial machine learning model.
[0208] The preset data structure is used to represent the calculation process of the initial machine learning model. It can clearly display the flow and dependencies of the entire calculation process of the initial machine learning model, making it easier for users to understand and optimize the initial machine learning model.
[0209] The execution plan of the initial machine learning model includes two aspects: the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, where the variables can be scalars, vectors, tensors, etc.
[0210] The memory optimization framework can be understood as a memory optimization framework based on a preset data structure. It is used to optimize the execution order of computing units in the preset data structure and the variable storage method corresponding to the computing units, thereby minimizing the resource usage of the initial machine learning model, such as storage resource usage, CPU resource usage, etc., so as to better optimize the initial machine learning model training process, improve the training efficiency of the initial machine learning model, and improve the performance and efficiency of the initial machine learning model.
[0211] The target adjustment result is used to determine the resource occupancy requirement of the initial machine learning model, which can be understood as being used to determine the resource occupancy of the initial machine learning model after adjusting the execution plan of the initial machine learning model based on a preset data structure.
[0212] In an embodiment of the present application, by obtaining a preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure under the video memory optimization framework, that is, optimizing and adjusting the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units under the video memory optimization framework, the initial machine learning model training process is better optimized, and a target adjustment result for determining the resource occupancy requirement of the initial machine learning model is obtained.
[0213] The above-mentioned data processing method provided in the embodiment of the present application can be applied to, but is not limited to, application scenarios involving computational graph processing in the fields of e-commerce services, educational services, legal services, medical services, conference services, social network services, financial product services, logistics services and navigation services, such as: scenarios for training e-commerce service models, scenarios for training educational service models, scenarios for training legal service models, scenarios for training medical service models, etc., which are not limited here.
[0214] By adopting the embodiment of the present application, by obtaining the preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure under the video memory optimization framework, a target adjustment result for determining the resource occupancy requirement of the initial machine learning model is obtained. Through the above method, the purpose of efficiently reducing the resource requirements and resource overhead of large models is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource requirements and resource overhead of the model, and ensuring the effectiveness, efficiency and scalability of the optimization process without introducing modifications to the model training steps and other overheads, thereby solving the technical problems of low performance, long optimization time and poor usability of the method of optimizing the execution order of operators in related technologies.
[0215] It should be noted that the preferred implementation of this embodiment can refer to the relevant description in Example 1, which will not be repeated here.
[0216] Example 3
[0217] In the operating environment as in Example 1, the present application provides Fig.10 A data processing method is shown. Fig.10 is a flow chart of a data processing method according to Embodiment 3 of the present application, such as Fig.10 As shown, the data processing method includes:
[0218] Step S101, obtaining a preset data structure corresponding to the initial e-commerce service model, wherein the preset data structure is used to represent the calculation process of the initial e-commerce service model;
[0219] Step S102, adjusting the execution plan of the initial e-commerce service model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupation requirement of the initial e-commerce service model;
[0220] Step S103: training the initial e-commerce service model according to the target adjustment result to obtain the target e-commerce service model.
[0221] The preset data structure is used to represent the calculation process of the initial e-commerce service model, which can clearly display the flow and dependencies of the entire calculation process of the initial e-commerce service model, making it easier for users to understand and optimize the initial e-commerce service model.
[0222] The execution plan of the initial e-commerce service model includes two aspects: the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, where the variables can be scalars, vectors, tensors, etc.
[0223] The target adjustment result is used to determine the resource occupancy requirement of the initial e-commerce service model, which can be understood as being used to determine the resource occupancy of the initial e-commerce service model after adjusting the execution plan of the initial e-commerce service model based on a preset data structure.
[0224] When training the initial e-commerce service model, the embodiment of the present application takes into account that the preset data structure can clearly display the flow and dependencies of the entire calculation process of the initial e-commerce service model. Therefore, the embodiment of the present application optimizes the execution plan of the initial e-commerce service model from two aspects: the execution order of the calculation units and the variable storage method corresponding to the calculation units, thereby minimizing the resource occupancy of the initial e-commerce service model, such as storage resource occupancy, CPU resource occupancy, etc., so as to better optimize the initial e-commerce service model training process, thereby improving the training efficiency of the initial e-commerce service model, and improving the performance and efficiency of the initial e-commerce service model.
[0225] In an embodiment of the present application, by obtaining a preset data structure corresponding to the initial e-commerce service model, and then adjusting the execution plan of the initial e-commerce service model based on the preset data structure, that is, optimizing and adjusting the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, the initial e-commerce service model training process is better optimized, and a target adjustment result for determining the resource occupancy requirement of the initial e-commerce service model is obtained. After obtaining the target adjustment result, the initial e-commerce service model is trained based on the target adjustment result, so that the machine learning model training process can be optimized, the model training efficiency can be improved, and the resource overhead of training the initial e-commerce service model can be reduced, and finally the target machine learning model can be obtained.
[0226] The above-mentioned data processing method provided in the embodiment of the present application can also be applied to, but is not limited to, application scenarios involving query request processing in the fields of educational services, legal services, medical services, conference services, social network services, financial product services, logistics services and navigation services, such as: scenarios for training educational service models, scenarios for training legal service models, scenarios for training medical service models, etc., which are not limited here.
[0227] By adopting the embodiment of the present application, by obtaining the preset data structure corresponding to the initial e-commerce service model, and then adjusting the execution plan of the initial e-commerce service model based on the preset data structure, a target adjustment result for determining the resource occupation demand of the initial e-commerce service model is obtained, and finally, the initial e-commerce service model is trained based on the target adjustment result to obtain a target machine learning model. Through the above method, the purpose of optimizing the training process of the machine learning model and improving the training efficiency of the machine learning model is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource occupation demand and resource overhead of the model without introducing modifications to the model training steps and other overheads, and ensuring the effectiveness, efficiency and scalability of the optimization process, thereby solving the technical problems of low performance, long optimization time and poor availability of the method of optimizing the execution order of operators in the related technology.
[0228] It should be noted that the preferred implementation of this embodiment can refer to the relevant description in Example 1, which will not be repeated here.
[0229] Example 4
[0230] According to an embodiment of the present application, a device embodiment for implementing the above data processing method is also provided. Fig.11 is a structural diagram of a data processing method and device according to Embodiment 4 of the present application, such as Fig.11 As shown, the device comprises:
[0231] An acquisition module 1101 is used to acquire a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent a calculation process of the initial machine learning model;
[0232] An adjustment module 1102 adjusts the execution plan of the initial machine learning model based on a preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupation requirement of the initial machine learning model;
[0233] The training module 1103 trains the initial machine learning model according to the target adjustment result to obtain the target machine learning model.
[0234] Optionally, the preset data structure includes: a computational graph, and the adjustment module 1102 is further used to: segment the computational graph into subgraphs to obtain segmentation results, wherein the segmentation results are used to determine the division relationship between multiple subgraphs obtained by segmenting the computational graph through the preset data structure; adjust the execution plan of the initial machine learning model based on the segmentation results to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of operators in the computational graph and the variable storage method corresponding to the operators.
[0235] Optionally, the computational graph includes: multiple nodes and edges for connecting different nodes, the multiple nodes are used to represent operators in the initial machine learning model, and the edges are used to represent variables corresponding to the operators. The above-mentioned adjustment module 1102 is also used to: find some nodes from the computational graph and determine the scheduling position of the weight update operation from the computational graph, wherein some nodes have a fixed execution time; perform sub-graph segmentation on the computational graph based on the some nodes and the scheduling position to obtain the segmentation result.
[0236] Optionally, the above-mentioned adjustment module 1102 is also used to: determine the forward mode stage calculation graph and the backward mode stage calculation graph from the calculation graph; obtain the first execution time and the second execution time of each node in the forward mode stage calculation graph and the backward mode stage calculation graph, wherein the first execution time is the earliest execution time of each node, and the second execution time is the latest execution time corresponding to the first execution time; based on the first execution time and the second execution time, search for some nodes from the calculation graph.
[0237] Optionally, the adjustment module 1102 is also used to: calculate the resource occupancy peak of the initial machine learning model using the forward activation values to be saved and the size of the variables generated in the forward mode stage; at the execution time of the weight update operation, calculate the resource occupancy requirement of the weight update operation through the forward activation values that have not yet been released and the video memory consumption of the temporary buffer; determine the scheduling position of the weight update operation from the calculation graph based on the resource occupancy peak and the resource occupancy requirement of the weight update operation.
[0238] Optionally, the above-mentioned adjustment module 1102 is also used to: perform sub-graph segmentation on the computation graph based on some nodes and scheduling positions to obtain multiple first sub-graphs, wherein the multiple first sub-graphs are independent sub-graphs for creating and releasing variables within the same sub-graph; perform sub-graph segmentation on at least some of the multiple first sub-graphs to obtain multiple second sub-graphs, wherein the multiple second sub-graphs are non-independent sub-graphs for respectively creating and releasing variables within different sub-graphs; and construct a sub-graph tree using the computation graph as the root node and the multiple first sub-graphs and the multiple second sub-graphs to obtain the segmentation result.
[0239] Optionally, the above-mentioned adjustment module 1102 is also used to: adjust the execution order of operators of the calculation graph based on the segmentation result to obtain a first adjustment result; adjust the variable storage plan of the calculation graph based on the segmentation result to obtain a second adjustment result; determine the target adjustment result through the first adjustment result and the second adjustment result.
[0240] Optionally, the above-mentioned adjustment module 1102 is also used to: determine multiple operator execution sequences of the initial machine learning model based on the segmentation results, and determine multiple independent areas in the calculation graph based on some nodes found from the calculation graph; obtain the first resource occupancy peak values of the multiple independent areas under the multiple operator execution sequences, wherein the first resource occupancy peak value is a theoretical peak value determined by the multiple independent areas; adjust the operator execution order of the calculation graph according to the first resource occupancy peak value to obtain a first adjustment result.
[0241] Optionally, the above-mentioned adjustment module 1102 is also used to: determine a first variable and a second variable based on a first resource occupancy peak value, wherein the first variable is used to determine whether to create a variable, and the second variable is used to determine whether to save the variable in the video memory; adjust the variable life cycle based on the first variable and the second variable to obtain an adjusted life cycle; use the adjusted life cycle to adjust the operator execution order of the calculation graph to obtain a first adjustment result.
[0242] Optionally, the above-mentioned adjustment module 1102 is also used to: obtain the variable storage plans of multiple subgraphs respectively based on the segmentation results, and classify the variables based on the segmentation results to obtain classification results; connect the variable storage plans of multiple subgraphs to determine the second resource occupancy peak, wherein the second resource occupancy peak is the resource occupancy peak of the variable storage plan of the calculation graph; adjust the variable storage plan of the calculation graph according to the second resource occupancy peak and the classification result to obtain a second adjustment result.
[0243] Optionally, the above-mentioned adjustment module 1102 is also used to: take the second resource occupancy peak as the adjustment target, perform memory multiplexing adjustment on the first classification variable and the second classification variable in the classification result in multiple subgraphs, and adjust the variable storage plan of the third classification variable in the classification result, to obtain a second adjustment result, wherein the first classification variable is created in the forward mode stage calculation graph and released in multiple subgraphs, the second classification variable is created in the backward mode stage calculation graph and released outside the multiple subgraphs, and the third classification variable is created and released in the same subgraph of the multiple subgraphs.
[0244] Optionally, a graphical user interface is provided through a terminal device, and the content displayed by the graphical user interface at least partially includes a model execution plan optimization scenario, and also includes: a processing module, used to respond to a first touch operation applied to the graphical user interface, and display the initial resource occupancy results of the initial machine learning model in the current training process, wherein the initial resource occupancy results include at least one of the following: storage resource occupancy results of the initial machine learning model in the current training process, and processing resource occupancy results of the initial machine learning model in the current training process; in response to a second touch operation applied to the graphical user interface, when a preset adjustment timing is met, the execution plan is adjusted based on the segmentation result to obtain the target resource occupancy result.
[0245] Optionally, the processing module is also used to perform hierarchical adjustments to the execution plan based on the segmentation results to obtain multiple candidate resource occupation results; in response to a third touch operation applied to the graphical user interface, select a target resource occupation result from the multiple candidate resource occupation results; and display the target resource occupation result in the graphical user interface.
[0246] According to the embodiment of the present application, by obtaining the preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure, a target adjustment result for determining the resource occupation demand of the initial machine learning model is obtained, and finally, the initial machine learning model is trained based on the target adjustment result to obtain a target machine learning model. Through the above method, the purpose of optimizing the training process of the machine learning model and improving the training efficiency of the machine learning model is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource occupation demand and resource overhead of the model, and ensuring the effectiveness, efficiency and scalability of the optimization process without introducing modifications to the model training steps and other overheads, thereby solving the technical problems of low performance, long optimization time and poor usability of the method of optimizing the execution order of operators in the related technology.
[0247] It should be noted that the acquisition module 1101, adjustment module 1102 and training module 1103 correspond to step S21 and step S23 in Example 1, and the three modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory and processed by one or more processors, and the above-mentioned modules may also run in the server 10 provided in Example 1.
[0248] According to an embodiment of the present application, another device embodiment for implementing the above data processing method is also provided. Fig.12 is a structural diagram of another data processing method device according to Embodiment 4 of the present application, such as Fig.12As shown, the device comprises:
[0249] An acquisition module 1201 is used to acquire a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model;
[0250] Adjustment module 1202, under the video memory optimization framework, adjusts the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupancy requirements of the initial machine learning model.
[0251] By adopting the embodiment of the present application, by obtaining the preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure under the video memory optimization framework, a target adjustment result for determining the resource occupancy requirement of the initial machine learning model is obtained. Through the above method, the purpose of efficiently reducing the resource requirements and resource overhead of large models is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource requirements and resource overhead of the model, and ensuring the effectiveness, efficiency and scalability of the optimization process without introducing modifications to the model training steps and other overheads, thereby solving the technical problems of low performance, long optimization time and poor usability of the method of optimizing the execution order of operators in related technologies.
[0252] It should be noted that the acquisition module 1201 and the adjustment module 1202 correspond to step S91 and step S92 in Example 2, and the two modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 2. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory and processed by one or more processors, and the above-mentioned modules may also be run in the server 10 provided in Example 1.
[0253] According to an embodiment of the present application, another device embodiment for implementing the above data processing method is also provided. Fig.13 is a structural diagram of another data processing method and device according to Embodiment 4 of the present application, such as Fig.13 As shown, the device comprises:
[0254] An acquisition module 1301 is used to acquire a preset data structure corresponding to the initial e-commerce service model, wherein the preset data structure is used to represent a calculation process of the initial e-commerce service model;
[0255] An adjustment module 1302 adjusts the execution plan of the initial e-commerce service model based on a preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupation requirement of the initial e-commerce service model;
[0256] The training module 1303 trains the initial e-commerce service model according to the target adjustment result to obtain the target e-commerce service model.
[0257] By adopting the embodiment of the present application, by obtaining the preset data structure corresponding to the initial e-commerce service model, and then adjusting the execution plan of the initial e-commerce service model based on the preset data structure, a target adjustment result for determining the resource occupation demand of the initial e-commerce service model is obtained, and finally, the initial e-commerce service model is trained based on the target adjustment result to obtain a target machine learning model. Through the above method, the purpose of optimizing the training process of the machine learning model and improving the training efficiency of the machine learning model is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource occupation demand and resource overhead of the model without introducing modifications to the model training steps and other overheads, and ensuring the effectiveness, efficiency and scalability of the optimization process, thereby solving the technical problems of low performance, long optimization time and poor availability of the method of optimizing the execution order of operators in the related technology.
[0258] It should be noted that the acquisition module 1301, adjustment module 1302 and training module 1303 correspond to step S101 and step S103 in Example 3, and the three modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 3. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory and processed by one or more processors, and the above-mentioned modules may also run in the server 10 provided in Example 1.
[0259] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in Example 1, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 1.
[0260] Example 5
[0261] The embodiment of the present application may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal.
[0262] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.
[0263] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the data processing method: obtaining a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model; adjusting the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupation requirements of the initial machine learning model; according to the target adjustment result, the initial machine learning model is trained to obtain a target machine learning model.
[0264] Optionally, Fig.14 is a structural block diagram of a computer terminal according to an embodiment of the present application. Fig.14 As shown, the computer terminal 14 may include: one or more (only one is shown in the figure) processors 1402, a memory 1404, a storage controller, and a peripheral interface, wherein the peripheral interface is connected to a radio frequency module, an audio module, and a display.
[0265] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the data processing method and device in the embodiment of the present application. The processor executes various functional applications and data processing by running the stored software programs and modules, that is, realizing the above-mentioned data processing method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer terminal 14 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0266] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: obtain a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model; adjust the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupancy requirements of the initial machine learning model; according to the target adjustment result, train the initial machine learning model to obtain a target machine learning model.
[0267] Optionally, the preset data structure includes: a computational graph, and the processor may also execute program code of the following steps: performing sub-graph segmentation on the computational graph to obtain segmentation results, wherein the segmentation results are used to determine the division relationship between multiple sub-graphs obtained by segmenting the computational graph through the preset data structure; adjusting the execution plan of the initial machine learning model based on the segmentation results to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of operators in the computational graph and the variable storage method corresponding to the operators.
[0268] Optionally, the computational graph includes: multiple nodes and edges for connecting different nodes, the multiple nodes are used to represent operators in the initial machine learning model, and the edges are used to represent variables corresponding to the operators. The above-mentioned processor can also execute the program code of the following steps: searching for some nodes from the computational graph and determining the scheduling position of the weight update operation from the computational graph, wherein some nodes have a fixed execution time; performing sub-graph segmentation on the computational graph based on the some nodes and the scheduling position to obtain the segmentation result.
[0269] Optionally, the processor may also execute the program code of the following steps: determining a forward mode stage calculation graph and a backward mode stage calculation graph from the calculation graph; obtaining a first execution time and a second execution time of each node in the forward mode stage calculation graph and the backward mode stage calculation graph, wherein the first execution time is the earliest execution time of each node, and the second execution time is the latest execution time corresponding to the first execution time; based on the first execution time and the second execution time, searching for some nodes from the calculation graph.
[0270] Optionally, the processor may also execute the following program code: using the forward activation values to be saved and the size of the variables generated in the forward mode stage to calculate the peak resource usage of the initial machine learning model; at the time of executing the weight update operation, using the forward activation values that have not yet been released and the video memory consumption of the temporary buffer, calculate the resource usage requirement of the weight update operation; based on the resource usage peak and the resource usage requirement of the weight update operation, determine the scheduling position of the weight update operation from the computational graph.
[0271] Optionally, the processor may also execute the program code of the following steps: performing subgraph segmentation on the computation graph based on some nodes and scheduling positions to obtain multiple first subgraphs, wherein the multiple first subgraphs are independent subgraphs for creating and releasing variables within the same subgraph; performing subgraph segmentation on at least some of the multiple first subgraphs to obtain multiple second subgraphs, wherein the multiple second subgraphs are non-independent subgraphs for respectively creating and releasing variables within different subgraphs; taking the computation graph as the root node, constructing a subgraph tree using the multiple first subgraphs and the multiple second subgraphs to obtain the segmentation result.
[0272] Optionally, the processor may also execute the program code of the following steps: adjusting the execution order of operators of the computational graph based on the segmentation result to obtain a first adjustment result; adjusting the variable storage plan of the computational graph based on the segmentation result to obtain a second adjustment result; and determining the target adjustment result through the first adjustment result and the second adjustment result.
[0273] Optionally, the processor may also execute the following program code: determining multiple operator execution sequences of the initial machine learning model based on the segmentation results, and determining multiple independent regions in the computational graph based on some nodes found in the computational graph; obtaining first resource occupancy peak values of multiple independent regions under multiple operator execution sequences, wherein the first resource occupancy peak value is a theoretical peak value determined by multiple independent regions; adjusting the operator execution order of the computational graph according to the first resource occupancy peak value to obtain a first adjustment result.
[0274] Optionally, the processor may also execute the following program code: determining a first variable and a second variable based on a first resource occupancy peak value, wherein the first variable is used to determine whether to create a variable, and the second variable is used to determine whether to save the variable in a video memory; adjusting the variable life cycle based on the first variable and the second variable to obtain an adjusted life cycle; and adjusting the execution order of operators of a computational graph using the adjusted life cycle to obtain a first adjustment result.
[0275] Optionally, the processor may also execute the program code of the following steps: respectively obtaining the variable storage plans of the multiple subgraphs based on the segmentation results, and classifying the variables based on the segmentation results to obtain the classification results; connecting the variable storage plans of the multiple subgraphs to determine the second resource occupancy peak, wherein the second resource occupancy peak is the resource occupancy peak of the variable storage plan of the computational graph; adjusting the variable storage plan of the computational graph according to the second resource occupancy peak and the classification results to obtain the second adjustment result.
[0276] Optionally, the processor may also execute the program code of the following steps: taking the second resource occupancy peak as the adjustment target, respectively adjusting the first classification variable and the second classification variable in the classification result in multiple subgraphs for video memory multiplexing, and adjusting the variable storage plan for the third classification variable in the classification result, to obtain a second adjustment result, wherein the first classification variable is created in the forward mode phase calculation graph and released within multiple subgraphs, the second classification variable is created in the backward mode phase calculation graph and released outside multiple subgraphs, and the third classification variable is created and released within the same subgraph of multiple subgraphs.
[0277] Optionally, the processor may also execute program code for the following steps: in response to a first touch operation on the graphical user interface, displaying the initial resource occupancy results of the initial machine learning model during the current training process, wherein the initial resource occupancy results include at least one of the following: storage resource occupancy results of the initial machine learning model during the current training process, processing resource occupancy results of the initial machine learning model during the current training process; in response to a second touch operation on the graphical user interface, when a preset adjustment timing is met, adjusting the execution plan based on the segmentation result to obtain the target resource occupancy results.
[0278] Optionally, the processor may also execute program code of the following steps: hierarchically adjusting the execution plan based on the segmentation results to obtain a plurality of candidate resource occupancy results; selecting a target resource occupancy result from a plurality of candidate resource occupancy results in response to a third touch operation applied to the graphical user interface; and displaying the target resource occupancy result in the graphical user interface.
[0279] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain a preset data structure calculation graph corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model. The calculation graph is obtained by converting the intermediate layer of the initial machine learning model; under the graph-based memory optimization framework, the execution plan of the initial machine learning model is adjusted based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupancy requirement of the initial machine learning model to sub-graph segment the calculation graph to obtain the segmentation result, and adjust the execution plan of the initial machine learning model based on the segmentation result to obtain the target adjustment result, wherein the segmentation result is used to determine the division relationship between multiple sub-graphs obtained by segmenting the calculation graph through the preset data structure, the execution plan is used to determine the execution order of operators in the calculation graph and the variable storage method corresponding to the operators, and the target adjustment result is used to determine the resource occupancy requirement of the initial machine learning model.
[0280] The processor can call the information and application stored in the memory through the transmission device to perform the following steps:
[0281] Obtain a preset data structure calculation graph corresponding to the initial e-commerce service model, wherein the preset data structure is used to represent the calculation process of the initial e-commerce service model. The calculation graph is obtained by transforming the intermediate layer of the initial e-commerce service model; adjust the execution plan of the initial e-commerce service model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupancy requirement of the initial e-commerce service model; perform sub-graph segmentation on the calculation graph to obtain a segmentation result, wherein the segmentation result is used to determine the division relationship between multiple sub-graphs obtained by segmenting the calculation graph through the preset data structure; adjust the execution plan of the initial e-commerce service model based on the segmentation result to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the operators in the calculation graph and the variable storage method corresponding to the operators, and the target adjustment result is used to determine the resource occupancy requirement of the initial e-commerce service model; train the initial e-commerce service model according to the target adjustment result to obtain a target e-commerce service model.
[0282] According to the embodiment of the present application, by obtaining the preset data structure corresponding to the initial machine learning model, and then adjusting the execution plan of the initial machine learning model based on the preset data structure, a target adjustment result for determining the resource occupation demand of the initial machine learning model is obtained, and finally, the initial machine learning model is trained based on the target adjustment result to obtain a target machine learning model. Through the above method, the purpose of optimizing the training process of the machine learning model and improving the training efficiency of the machine learning model is achieved, thereby achieving the technical effect of improving the resource utilization efficiency of the model, reducing the resource occupation demand and resource overhead of the model, and ensuring the effectiveness, efficiency and scalability of the optimization process without introducing modifications to the model training steps and other overheads, thereby solving the technical problems of low performance, long optimization time and poor usability of the method of optimizing the execution order of operators in the related technology.
[0283] It can be understood by those skilled in the art that Fig.14 The structure shown is for illustration only, and the computer terminal 14 may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Fig.14 The structure of the electronic device is not limited. For example, the computer terminal 14 may also include Fig.14 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Fig.14 Different configurations are shown.
[0284] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0285] Example 6
[0286] The embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the data processing method provided in the first embodiment.
[0287] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[0288] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: obtaining a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent the calculation process of the initial machine learning model; adjusting the execution plan of the initial machine learning model based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupation requirements of the initial machine learning model; according to the target adjustment result, the initial machine learning model is trained to obtain a target machine learning model.
[0289] Optionally, the preset data structure includes: a computational graph. In this embodiment, a computer-readable storage medium is configured to store program codes for executing the following steps: performing sub-graph segmentation on the computational graph to obtain segmentation results, wherein the segmentation results are used to determine the division relationship between multiple sub-graphs obtained by segmenting the computational graph through the preset data structure; adjusting the execution plan of the initial machine learning model based on the segmentation results to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of operators in the computational graph and the variable storage method corresponding to the operators.
[0290] Optionally, the computational graph includes: multiple nodes and edges for connecting different nodes, the multiple nodes are used to represent operators in the initial machine learning model, and the edges are used to represent variables corresponding to the operators. In this embodiment, the computer-readable storage medium is configured to store program codes for performing the following steps: searching for some nodes from the computational graph and determining the scheduling position of the weight update operation from the computational graph, wherein some nodes have a fixed execution time; performing sub-graph segmentation on the computational graph based on the some nodes and the scheduling position to obtain the segmentation result.
[0291] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: determining a forward mode stage calculation graph and a backward mode stage calculation graph from the calculation graph; obtaining a first execution time and a second execution time of each node in the forward mode stage calculation graph and the backward mode stage calculation graph, wherein the first execution time is the earliest execution time of each node, and the second execution time is the latest execution time corresponding to the first execution time; based on the first execution time and the second execution time, searching for some nodes from the calculation graph.
[0292] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: using the forward activation values to be saved and the size of the variables generated in the forward mode stage to calculate the resource occupancy peak of the initial machine learning model; at the execution time of the weight update operation, the resource occupancy requirement of the weight update operation is calculated through the forward activation values that have not yet been released and the video memory consumption of the temporary buffer; based on the resource occupancy peak and the resource occupancy requirement of the weight update operation, determining the scheduling position of the weight update operation from the computational graph.
[0293] Optionally, in this embodiment, a computer-readable storage medium is configured to store program code for executing the following steps: performing subgraph segmentation on the computation graph based on some nodes and scheduling positions to obtain multiple first subgraphs, wherein the multiple first subgraphs are independent subgraphs for creating and releasing variables within the same subgraph; performing subgraph segmentation on at least some of the multiple first subgraphs to obtain multiple second subgraphs, wherein the multiple second subgraphs are non-independent subgraphs for respectively creating and releasing variables within different subgraphs; taking the computation graph as the root node, constructing a subgraph tree using the multiple first subgraphs and the multiple second subgraphs to obtain a segmentation result.
[0294] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: adjusting the execution order of operators of the computational graph based on the segmentation result to obtain a first adjustment result; adjusting the variable storage plan of the computational graph based on the segmentation result to obtain a second adjustment result; and determining the target adjustment result through the first adjustment result and the second adjustment result.
[0295] Optionally, in this embodiment, a computer-readable storage medium is configured to store program code for executing the following steps: determining multiple operator execution sequences of an initial machine learning model based on the segmentation results, and determining multiple independent regions in the computational graph based on some nodes found from the computational graph; obtaining first resource occupancy peak values of multiple independent regions under multiple operator execution sequences, wherein the first resource occupancy peak value is a theoretical peak value determined by multiple independent regions; and adjusting the operator execution order of the computational graph according to the first resource occupancy peak value to obtain a first adjustment result.
[0296] Optionally, in this embodiment, a computer-readable storage medium is configured to store program code for executing the following steps: determining a first variable and a second variable based on a first resource occupancy peak value, wherein the first variable is used to determine whether to create a variable and the second variable is used to determine whether to save the variable in a video memory; adjusting the variable life cycle based on the first variable and the second variable to obtain an adjusted life cycle; and adjusting the execution order of operators of a computational graph using the adjusted life cycle to obtain a first adjustment result.
[0297] Optionally, in this embodiment, a computer-readable storage medium is configured to store program code for executing the following steps: obtaining variable storage plans of multiple subgraphs respectively based on the segmentation results, and classifying the variables based on the segmentation results to obtain classification results; connecting the variable storage plans of multiple subgraphs to determine a second resource occupancy peak, wherein the second resource occupancy peak is the resource occupancy peak of the variable storage plan of the calculation graph; adjusting the variable storage plan of the calculation graph according to the second resource occupancy peak and the classification result to obtain a second adjustment result.
[0298] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: taking the second resource occupancy peak as the adjustment target, respectively adjusting the video memory multiplexing of the first classification variable and the second classification variable in the classification result in multiple subgraphs, and adjusting the variable storage plan of the third classification variable in the classification result to obtain a second adjustment result, wherein the first classification variable is created in the forward mode stage calculation graph and released within multiple subgraphs, the second classification variable is created in the backward mode stage calculation graph and released outside the multiple subgraphs, and the third classification variable is created and released within the same subgraph of the multiple subgraphs.
[0299] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: in response to a first touch operation applied to a graphical user interface, displaying initial resource occupancy results of an initial machine learning model during a current training process, wherein the initial resource occupancy results include at least one of the following: storage resource occupancy results of an initial machine learning model during a current training process, processing resource occupancy results of an initial machine learning model during a current training process; in response to a second touch operation applied to the graphical user interface, when a preset adjustment timing is met, adjusting the execution plan based on the segmentation results to obtain a target resource occupancy result.
[0300] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: hierarchically adjusting the execution plan based on the segmentation result to obtain multiple candidate resource occupation results; in response to a third touch operation applied to the graphical user interface, selecting a target resource occupation result from the multiple candidate resource occupation results; and displaying the target resource occupation result in the graphical user interface.
[0301] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0302] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0303] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0304] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0305] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0306] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0307] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data processing method, characterized in that: include: Obtaining a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent a calculation process of the initial machine learning model; The execution plan of the initial machine learning model is adjusted based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupation requirement of the initial machine learning model; According to the target adjustment result, the initial machine learning model is trained to obtain the target machine learning model.
2. The data processing method according to claim 1, characterized in that: The preset data structure includes: a calculation graph, and adjusting the execution plan of the initial machine learning model based on the preset data structure to obtain the target adjustment result includes: Performing subgraph segmentation on the computation graph to obtain segmentation results, wherein the segmentation results are used to determine a division relationship between a plurality of subgraphs obtained by segmenting the computation graph through a preset data structure; Based on the segmentation result, the execution plan of the initial machine learning model is adjusted to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of operators in the calculation graph and the variable storage method corresponding to the operators.
3. The data processing method according to claim 2, characterized in that: The computation graph includes: a plurality of nodes and edges for connecting different nodes, the plurality of nodes are used to represent operators in the initial machine learning model, the edges are used to represent variables corresponding to the operators, and the computation graph is segmented into subgraphs to obtain the segmentation results including: Finding some nodes from the computation graph and determining a scheduling position of a weight update operation from the computation graph, wherein the some nodes have a fixed execution time; The computation graph is segmented into subgraphs based on the partial nodes and the scheduling positions to obtain the segmentation results.
4. The data processing method according to claim 3, characterized in that: Finding the partial nodes from the computation graph includes: Determine a forward mode phase computation graph and a backward mode phase computation graph from the computation graph; Obtaining a first execution time and a second execution time of each node in the forward mode phase calculation graph and the backward mode phase calculation graph, wherein the first execution time is the earliest execution time of each node, and the second execution time is the latest execution time corresponding to the first execution time; Based on the first execution time and the second execution time, searching the partial nodes from the computation graph.
5. The data processing method according to claim 4, characterized in that: Determining the scheduling position of the weight update operation from the computation graph includes: Calculate the resource occupancy peak value of the initial machine learning model using the forward activation value to be saved generated in the forward mode stage and the size of the variable; At the execution time of the weight update operation, the resource occupation requirement of the weight update operation is calculated by using the forward activation value that has not been released and the video memory consumption of the temporary buffer; Based on the resource occupancy peak and the resource occupancy requirement of the weight update operation, the scheduling position of the weight update operation is determined from the calculation graph.
6. The data processing method according to claim 3, characterized in that: The computation graph is segmented into subgraphs based on the partial nodes and the scheduling positions, and the segmentation results obtained include: Based on the partial nodes and the scheduling positions, the computation graph is divided into subgraphs to obtain a plurality of first subgraphs, wherein the plurality of first subgraphs are independent subgraphs for creating and releasing variables in the same subgraph; Performing subgraph segmentation on at least part of the plurality of first subgraphs to obtain a plurality of second subgraphs, wherein the plurality of second subgraphs are non-independent subgraphs in which variables are created and released respectively in different subgraphs; Taking the computation graph as a root node, a subgraph tree is constructed using the multiple first subgraphs and the multiple second subgraphs to obtain the segmentation result.
7. The data processing method according to claim 2, characterized in that: The execution plan of the initial machine learning model is adjusted based on the segmentation result, and the target adjustment result is obtained including: Adjusting the execution order of operators of the computation graph based on the segmentation result to obtain a first adjustment result; Adjusting the variable storage plan of the computation graph based on the segmentation result to obtain a second adjustment result; The target adjustment result is determined by the first adjustment result and the second adjustment result.
8. The data processing method according to claim 7, characterized in that: The execution order of operators of the computation graph is adjusted based on the segmentation result, and the first adjustment result is obtained, comprising: Determining multiple operator execution sequences of the initial machine learning model based on the segmentation results, and determining multiple independent regions in the computational graph based on some nodes found in the computational graph; Obtaining first resource occupancy peak values of the multiple independent regions under the multiple operator execution sequences, wherein the first resource occupancy peak values are theoretical peak values determined by the multiple independent regions; The operator execution order of the computation graph is adjusted according to the first resource occupancy peak value to obtain the first adjustment result.
9. The data processing method according to claim 8, characterized in that: The execution order of operators of the computation graph is adjusted according to the first resource occupancy peak value, and the first adjustment result is obtained including: Determine a first variable and a second variable according to the first resource occupancy peak value, wherein the first variable is used to determine whether to create the variable, and the second variable is used to determine whether to save the variable in the video memory; Adjusting the variable life cycle based on the first variable and the second variable to obtain an adjusted life cycle; The operator execution order of the computation graph is adjusted using the adjusted life cycle to obtain the first adjustment result.
10. The data processing method according to claim 7, characterized in that: The variable storage plan of the computation graph is adjusted based on the segmentation result, and the second adjustment result is obtained, comprising: Obtaining variable storage plans of the plurality of subgraphs respectively based on the segmentation results, and classifying the variables based on the segmentation results to obtain classification results; Connecting the variable storage plans of the multiple subgraphs to determine a second resource occupancy peak value, wherein the second resource occupancy peak value is a resource occupancy peak value of the variable storage plan of the computation graph; The variable storage plan of the computational graph is adjusted according to the second resource occupancy peak value and the classification result to obtain the second adjustment result.
11. The data processing method according to claim 10, characterized in that: The variable storage plan of the computation graph is adjusted according to the second resource occupancy peak value and the classification result, and the second adjustment result is obtained including: Taking the second resource occupancy peak as the adjustment target, the first classification variable and the second classification variable in the classification result are respectively adjusted for video memory multiplexing in the multiple subgraphs, and the variable storage plan is adjusted for the third classification variable in the classification result, to obtain the second adjustment result, wherein the first classification variable is created in the forward mode stage calculation graph and released within the multiple subgraphs, the second classification variable is created in the backward mode stage calculation graph and released outside the multiple subgraphs, and the third classification variable is created and released within the same subgraph of the multiple subgraphs.
12. The data processing method according to claim 1, characterized in that: A graphical user interface is provided through a terminal device, wherein the content displayed by the graphical user interface at least partially includes a model execution plan optimization scenario, and the data processing method further includes: In response to a first touch operation on the graphical user interface, an initial resource occupancy result of the initial machine learning model in the current training process is displayed, wherein the initial resource occupancy result includes at least one of the following: a storage resource occupancy result of the initial machine learning model in the current training process, and a processing resource occupancy result of the initial machine learning model in the current training process; In response to a second touch operation on the graphical user interface, when a preset adjustment opportunity is met, the execution plan is adjusted based on the segmentation result to obtain a target resource occupation result.
13. A data processing method, characterized in that: include: Obtaining a preset data structure corresponding to the initial machine learning model, wherein the preset data structure is used to represent a calculation process of the initial machine learning model; Under the video memory optimization framework, the execution plan of the initial machine learning model is adjusted based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the computing units in the preset data structure and the variable storage method corresponding to the computing units, and the target adjustment result is used to determine the resource occupancy requirements of the initial machine learning model.
14. A data processing method, characterized in that: include: Acquire a preset data structure corresponding to the initial e-commerce service model, wherein the preset data structure is used to represent a calculation process of the initial e-commerce service model; The execution plan of the initial e-commerce service model is adjusted based on the preset data structure to obtain a target adjustment result, wherein the execution plan is used to determine the execution order of the calculation units in the preset data structure and the variable storage method corresponding to the calculation units, and the target adjustment result is used to determine the resource occupation requirement of the initial e-commerce service model; According to the target adjustment result, the initial e-commerce service model is trained to obtain a target e-commerce service model.
15. An electronic device, characterized in that: include: A memory storing an executable program; A processor, used to run the program, wherein the program executes the data processing method according to any one of claims 1 to 14 when running.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the computer-readable storage medium is located is controlled to execute the data processing method according to any one of claims 1 to 14.