Method and system for optimizing computational graph, electronic equipment and storage medium
By obtaining hardware status and performance index in real time and adjusting the calculation graph dynamically, the problem that the calculation graph cannot be dynamically adjusted in the existing technology is solved, and the utilization rate of computing resources and computing efficiency are improved.
Patent Information
- Application Number
- CN202510310614.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-04-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art cannot dynamically adjust the calculation chart according to real-time load and hardware state in high-performance computing scenarios, resulting in the inability to fully utilize computing resources and affecting computing efficiency.
By obtaining the status data and performance index of the target hardware in real time, as well as the computing load of the target server, dynamically adjust the custom task list and calculation chart, including adjusting the calculation frequency, accuracy and calculation chart structure to adapt to real-time changes.
It improves the utilization rate of computing resources and the stability of the system, can better adapt to different computing scenarios and real-time changes, and improves computing efficiency.
Smart Images

Figure CN119829258A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of high-performance computing technology, and in particular to a method, system, electronic device, and storage medium for optimizing a computational graph. Background Art
[0002] In today's era of rapid technological development, high-performance computing plays a vital role in many fields such as scientific research, industrial manufacturing, financial analysis, and artificial intelligence. Whether it is large-scale meteorological simulation, molecular dynamics calculations in drug development, or training complex deep learning models, extremely high requirements are placed on computing resources.
[0003] However, the existing technologies currently used in the field of computational graph optimization and load control have obvious shortcomings. As far as the optimization of computational graphs is concerned, static configuration is generally relied on. Before the computing task is started, the developer will optimize the computational graph based on experience or preset rules, and these settings remain unchanged throughout the computing process. However, in actual high-performance computing scenarios, the real-time load of computing tasks changes dynamically, and the number and complexity of tasks submitted in different time periods, as well as the status of hardware such as temperature and memory usage, will change. Statically configured computational graphs cannot perceive these real-time changes, and cannot flexibly adjust optimization strategies according to actual conditions, resulting in the inability to fully utilize computing resources, which in turn affects computing efficiency. Summary of the invention
[0004] In order to solve the above problems, the present application provides a method, system, electronic device and storage medium for optimizing a computational graph, so as to improve the utilization rate of computing resources and the stability of the system.
[0005] The first aspect of the present application discloses a method for optimizing a computational graph, comprising: Acquire status data and performance index of target hardware and computing load of target server in real time, wherein the status data includes temperature and memory usage; Dynamically adjusting a custom task list and a calculation graph according to the state data, the performance index, and the calculation load, wherein the custom task list includes multiple calculation methods; According to the dynamically adjusted calculation graph, the calculation tasks in the dynamically adjusted custom task list are executed, and the execution results are obtained; Optimization is performed according to the execution result to obtain an optimized calculation graph.
[0006] Optionally, the multiple calculation methods include a matrix multiplication calculation method, a two-dimensional convolution calculation method, and a rectified linear unit calculation method, and before the real-time acquisition of the state data of the target hardware and the calculation load of the target server, the method further includes: Set the mindSpore environment through context; Initialize the matrix multiplication calculation method, two-dimensional convolution calculation method, and rectified linear unit calculation method in the custom task list.
[0007] Optionally, dynamically adjusting the custom task list and the calculation graph according to the state data, the performance index and the calculation load includes: Dynamically adjusting the calculation frequencies of the multiple calculation methods according to the temperature; Dynamically adjusting the calculation accuracy of the multiple calculation methods according to a preset error tolerance and the performance index; The structure of the computational graph is dynamically adjusted according to the memory usage and the computational load.
[0008] Optionally, dynamically adjusting the calculation frequencies of the multiple calculation methods according to the temperature includes: If the temperature exceeds a preset temperature threshold, the calculation frequency of the multiple calculation methods is reduced.
[0009] Optionally, dynamically adjusting the calculation accuracy of the multiple calculation methods according to the preset error tolerance and the performance index includes: Calculating a precision factor based on a preset error tolerance and the performance index; If the precision factor is greater than 0.8, the calculation precision of the multiple calculation methods is set to half-precision floating point number; If the precision factor is greater than 0.5 and less than or equal to 0.8, the calculation precision of the multiple calculation methods is set to mixed precision; If the precision factor is less than or equal to 0.5, the calculation precision of the multiple calculation methods is set to single-precision floating point numbers.
[0010] Optionally, the structure of the computation graph is dynamically adjusted according to the memory usage and the computation load: If the memory usage rate is higher than a preset memory usage threshold, splitting the computation graph into multiple computation subgraphs; If the computing load is higher than a preset load threshold, the computing graph is task migrated.
[0011] Optionally, the real-time acquisition of target hardware status data and performance index, and target server computing load, wherein the status data includes temperature and memory usage, includes: According to a preset cycle period, the subprocess.check_output function of the subprocess module is called to obtain the temperature of the target hardware in real time, and the get_memory_usage function of the subprocess module is called to obtain the memory usage rate of the target hardware in real time; Acquire a performance index of the target hardware in real time, wherein the performance index represents the ability of the target hardware to perform operations of different precisions in real time; Calculate the load balancing factor of the target server in real time; Evaluate the calculation load according to the load balancing factor; If it is detected that the step of acquiring the status data and performance index of the target hardware and the computing load of the target server in real time is abnormal, the abnormal data is sent to the processing server.
[0012] The second aspect of the present application discloses a system for optimizing a computational graph, comprising: A real-time acquisition unit, used to acquire status data and performance index of target hardware and computing load of target server in real time, wherein the status data includes temperature and memory usage; A dynamic adjustment unit, used to dynamically adjust a custom task list and a calculation graph according to the state data, the performance index and the calculation load, wherein the custom task list includes multiple calculation methods; An execution unit, used to execute the computing tasks in the dynamically adjusted custom task list according to the dynamically adjusted computing graph, and obtain the execution results; The optimization unit is used to perform optimization according to the execution result to obtain an optimized calculation graph.
[0013] A third aspect of the present application provides an electronic device, including: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the first aspect and any optional method for optimizing the computation graph of the first aspect.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium on which a program is stored. When the program is executed on a computer, the method for optimizing the computational graph in the first aspect and any optional aspect of the first aspect is executed.
[0015] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: The present application provides a method for optimizing a computational graph, firstly obtaining the status data and performance index of the target hardware and the computing load of the target server in real time, the status data including temperature and memory usage; then dynamically adjusting the custom task list and the computational graph according to the status data, performance index and computational load, the custom task list including a variety of computational methods; then executing the computational tasks in the dynamically adjusted custom task list according to the dynamically adjusted computational graph, and obtaining the execution results; finally optimizing according to the execution results to obtain the optimized computational graph. The method for optimizing the computational graph of the present application collects key information in real time, and dynamically adjusts the custom task list and the computational graph according to the key information, so as to flexibly adjust the optimization strategy according to the actual situation, reasonably allocate tasks to different computing resources, make full use of all available computing resources, improve computing efficiency, make up for the shortcomings of static configuration, and better adapt to different computing scenarios and real-time changes. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0017] Figure 1 A schematic diagram of an embodiment of a method for optimizing a computational graph for the present application; Figure 2 A schematic diagram of another embodiment of the method for optimizing the computation graph for the present application; Figure 3 A schematic diagram of another embodiment of the method for optimizing the computation graph for the present application; Figure 4 A schematic diagram of another embodiment of the method for optimizing the computation graph for the present application; Figure 5 A schematic diagram of an embodiment of a system for optimizing a computation graph for the present application; Figure 6 This is a schematic diagram of an embodiment of an electronic device of the present application. DETAILED DESCRIPTION
[0018] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0019] It should be understood that when used in the present application specification, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0020] It should also be understood that the term “and / or” used in the specification of the present application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0021] As used in the present specification, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "if it is determined" or "if [the described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [the described condition or event] is detected" or "in response to detecting [the described condition or event]" depending on the context.
[0022] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0023] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0024] In high-performance computing, computational graph optimization and load control are key to improving computing efficiency and system stability. In the prior art, computational graph optimization usually relies on static configuration and cannot be dynamically adjusted according to real-time load and hardware status. In addition, existing load control methods lack the ability to monitor and dynamically adjust hardware status in real time, which can easily lead to hardware overheating or resource waste.
[0025] Based on this, the present application discloses a method, system, electronic device and storage medium for optimizing a computational graph, which are used to improve the utilization of computing resources and the stability of the system.
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in 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 are within the scope of protection of this application.
[0027] The method of the present application can be applied to a server, a device, a terminal or other devices with logic processing capabilities, and the present application does not limit this. For the convenience of description, the following description is made by taking the execution subject as an example of a terminal.
[0028] See also Figure 1 , the present application provides an embodiment of a method for optimizing a computational graph, comprising: 101. Obtain the status data and performance index of the target hardware and the computing load of the target server in real time. The status data includes temperature and memory usage; In this embodiment, in a high-performance computing environment, in order to optimize the calculation graph, it is necessary to first grasp the relevant information of the target hardware and the target server in real time. The status data of the target hardware is an important indicator reflecting the current operating status of the target hardware, among which temperature and memory usage are key factors. If the temperature of the target hardware is too high, the performance of the target hardware may be reduced or even damaged, affecting the stability and reliability of the calculation. The memory usage reflects the occupancy of the target hardware memory resources. If the memory usage is too high, there may be a problem of insufficient memory, causing the program to run slowly or crash. By obtaining the status data in real time, potential problems of the target hardware can be discovered in time, and corresponding measures can be taken to adjust them. The performance index of the target hardware is used to measure the computing power and processing efficiency of the target hardware. Different target hardware has differences in performance. Understanding the performance index of the target hardware helps to reasonably allocate computing tasks. The computing load of the target server reflects the busyness of the current processing tasks of the target server. During operation, the target server will process multiple computing tasks at the same time. If the computing load is too high, it may cause slow response and affect the timeliness of the calculation. By obtaining the computing load of the target server in real time, the task allocation can be dynamically adjusted according to the load situation to avoid response overload and ensure the smooth progress of the calculation.
[0029] 102. Dynamically adjust the custom task list and calculation graph according to status data, performance index and calculation load. The custom task list includes multiple calculation methods; In this embodiment, the tasks in the task list can be reordered, assigned or adjusted according to the status data of the target hardware, the performance index and the computing load of the target server. For example, if the temperature of a certain hardware is too high, the number of assigned tasks can be reduced; if the performance of another hardware is high, complex tasks can be added. The calculation graph is an abstract representation of the computing tasks and their dependencies. It describes the sequence and data flow between each computing step. The structure of the calculation graph can be adjusted according to the information obtained in real time. By dynamically adjusting the calculation graph, the computing tasks can be more reasonably distributed on various hardware and servers, thereby improving computing efficiency.
[0030] 103. According to the dynamically adjusted calculation graph, the calculation tasks in the dynamically adjusted custom task list are executed, and the execution results are obtained; In this embodiment, after completing the dynamic adjustment of the custom task list and the calculation graph, the calculation task can be executed according to the adjusted calculation graph and the custom task list. According to the order and dependency relationship specified by the dynamically adjusted calculation graph, the calculation tasks in the custom task list are executed in sequence. Each task will be run on appropriate hardware and servers to make full use of resources. During the execution process, the system will ensure data transfer and synchronization between tasks to ensure the correctness of the calculation. After the calculation task is executed, the corresponding execution result will be obtained. These results can be intermediate calculation results or final calculation outputs. The execution result is feedback on the calculation process, which reflects the execution of the calculation task and the accuracy of the calculation. By analyzing the execution result, the performance and effect of the calculation can be evaluated, providing a basis for subsequent optimization.
[0031] 104. Optimize according to the execution result to obtain an optimized calculation graph.
[0032] In this embodiment, the last step is to further optimize the calculation graph according to the execution results of the calculation task. The execution results are analyzed in depth, including calculation time, calculation accuracy, resource utilization and other aspects. For example, when it is found that the execution time of a certain calculation task is too long, this may be due to unreasonable allocation of the task or problems with the structure of the calculation graph; if the calculation accuracy does not meet the requirements, the calculation method or parameters may need to be adjusted. By analyzing the execution results, problems and deficiencies in the calculation process can be found. According to the analysis results, the calculation graph is optimized, and the structure of the calculation graph can be adjusted, such as merging or splitting nodes, adjusting the execution order of tasks; the calculation method and parameters can also be optimized, such as selecting a more efficient algorithm, adjusting the calculation accuracy, etc. By continuously optimizing the calculation graph, the calculation efficiency can be improved, resource consumption can be reduced, and the system can maintain good performance in different computing environments.
[0033] In this embodiment, first, the status data and performance index of the target hardware and the computing load of the target server are obtained in real time, and the status data includes temperature and memory usage; then, according to the status data, performance index and computing load, the custom task list and the computing graph are dynamically adjusted, and the custom task list includes a variety of calculation methods; then, according to the dynamically adjusted computing graph, the computing tasks in the dynamically adjusted custom task list are executed, and the execution results are obtained; finally, optimization is performed according to the execution results to obtain the optimized computing graph. The method for optimizing the computing graph of the present application collects key information in real time, and dynamically adjusts the custom task list and the computing graph according to the key information, so as to flexibly adjust the optimization strategy according to the actual situation, reasonably allocate tasks to different computing resources, make full use of all available computing resources, improve computing efficiency, make up for the shortcomings of static configuration, and better adapt to different computing scenarios and real-time changes.
[0034] See also Figure 2 ,exist Figure 1 Before step 101 of the illustrated embodiment acquires the status data and performance index of the target hardware and the computing load of the target server in real time, an initialization operation is required as a basis for executing subsequent steps, wherein initialization is mainly performed for various computing methods, and the various computing methods include a matrix multiplication computing method, a two-dimensional convolution computing method, and a rectified linear unit computing method. The initialization step may specifically include, but is not limited to, the following: 201. Set the mindSpore environment through context; In this embodiment, before performing a computing task based on the mindSpore framework, it is first necessary to set the mindSpore operating environment through context. This step is the basis of the entire computing process, and its purpose is to provide a suitable and stable operating basis for subsequent computing operations. In this process, some other important parameters can also be set, such as memory management mode, random number seed, etc. Reasonable setting of these parameters can further optimize computing performance and ensure the repeatability of calculation results. By setting a suitable memory management mode, memory usage can be effectively reduced and program crashes caused by insufficient memory can be avoided; and by setting a fixed random number seed, it can be ensured that the random number generation sequence is the same each time the program is run, so that the execution results are repeatable, which is convenient for comparing and analyzing the performance of different algorithms or models.
[0035] 202. Initialize the matrix multiplication calculation method, two-dimensional convolution calculation method and rectified linear unit calculation method in the custom task list.
[0036] In this embodiment, after completing the setting of the mindSpore environment, it is necessary to initialize the matrix multiplication calculation method, the two-dimensional convolution calculation method, and the rectified linear unit calculation method in the custom task list. These three calculation methods are very basic and important operations in deep learning, and they play a key role in building and training neural network models. Among them, the matrix multiplication calculation method is one of the core operations for transferring information between neural network layers. It is usually used in fully connected layers (also called dense layers), where input data and weight matrices are multiplied to produce outputs. The two-dimensional convolution calculation method is the basic building block of convolutional neural networks. It is used to extract spatial features of images or other two-dimensional data. Its convolution operation involves sliding a small filter across the input data and applying dot products to generate feature maps. The rectified linear unit calculation method is a widely used activation function that can introduce nonlinearity and help the model learn complex patterns. It works by setting all negative values to zero while keeping positive values unchanged. Through the initialization step, it can be ensured that these calculation methods can run correctly in the mindSpore environment.
[0037] See also Figure 3 ,according to Figure 2 The matrix multiplication calculation method, the two-dimensional convolution calculation method and the corrected linear unit calculation method mentioned in the illustrated embodiment are Figure 1 In step 102 of the illustrated embodiment, the dynamic adjustment of the custom task list and the calculation graph according to the state data, the performance index and the calculation load may specifically include, but is not limited to, the following: 301. Dynamically adjust the calculation frequency of multiple calculation methods according to temperature; In this embodiment, the temperature data of the hardware is obtained in real time, and this function can be achieved through hardware sensors or system monitoring tools. For example, in some server systems, BMC (Baseboard Management Controller) can be used to obtain temperature information of hardware such as CPU and GPU. According to the monitored temperature data, a corresponding calculation frequency adjustment strategy is formulated, that is, if the temperature exceeds the preset temperature threshold, the calculation frequency of various calculation methods is reduced, and the preset temperature threshold is set according to actual needs. For example, when the temperature is lower than 60°C, the calculation task is run at a normal frequency; when the temperature is between 60°C-70°C, the calculation frequency is reduced by 10%; when the temperature exceeds 70°C, the calculation frequency is reduced by 20%, etc.
[0038] 302. Dynamically adjust the calculation accuracy of multiple calculation methods according to the preset error tolerance and performance index; In this embodiment, during the calculation process, different application scenarios have different requirements for the accuracy of the calculation results, and the computing resources and time consumed by different calculation accuracies are also different. Higher calculation accuracy usually requires more computing resources and time, and although lower calculation accuracy can improve the calculation efficiency, it may introduce certain errors. Therefore, according to the preset error tolerance and the performance index of the hardware, the calculation accuracy is dynamically adjusted, which can improve the calculation efficiency and reduce the calculation cost under the premise of meeting the accuracy requirements of the calculation results. First, the preset error tolerance is determined according to the specific application scenario and requirements. In some scientific computing scenarios with high accuracy requirements, the error tolerance may be set lower; while in some application scenarios with high real-time requirements, the error tolerance can be appropriately relaxed. At the same time, it is necessary to evaluate the performance index of the hardware, such as calculation speed, memory bandwidth, etc.
[0039] According to the error tolerance and performance index, the calculation accuracy adjustment strategy is formulated. First, the precision factor is calculated according to the preset error tolerance and performance index. The formula for calculating the precision factor is as follows: Precision factor = Error tolerance / Hardware performance index. The larger the precision factor, the higher the tolerance of the system to errors. You can choose a lower calculation accuracy to improve performance. The specific adjustment strategy is: if the precision factor is greater than 0.8, the calculation accuracy of multiple calculation methods is set to half-precision floating point; if the precision factor is greater than 0.5 and less than or equal to 0.8, the calculation accuracy of multiple calculation methods is set to mixed precision; if the precision factor is less than or equal to 0.5, the calculation accuracy of multiple calculation methods is set to single-precision floating point.
[0040] 303. Dynamically adjust the structure of the computational graph based on memory usage and computational load.
[0041] In this embodiment, during the calculation process, the memory usage rate and the computational load will change with the execution of the computing task. If the memory usage rate is too high, it may lead to insufficient memory, affecting the normal progress of the calculation; if the computational load is too high, it may cause excessive computing pressure on certain nodes, affecting the computing efficiency. Therefore, dynamically adjusting the structure of the computational graph according to the memory usage rate and the computational load can optimize the allocation of computing resources, improve computing efficiency, and avoid the problems of insufficient memory and computing bottlenecks. According to the monitored memory usage rate and computational load information, a computational graph structure adjustment strategy is formulated. The specific adjustment strategy is: if the memory usage rate is higher than the preset memory usage threshold, the computational graph is split into multiple computational subgraphs to reduce the memory usage of each subgraph; if the computational load is higher than the preset load threshold, the computational graph is task migrated, that is, part of the tasks of the current node are migrated to other nodes to achieve load balancing.
[0042] See also Figure 4 , Figure 1In step 101 of the illustrated embodiment, the real-time acquisition of the state data and performance index of the target hardware and the computing load of the target server may specifically include, but is not limited to, the following: 401. According to a preset cycle, the subprocess.check_output function of the subprocess module is called to obtain the temperature of the target hardware in real time, and the get_memory_usage function of the subprocess module is called to obtain the memory usage rate of the target hardware in real time; In this embodiment, in a high-performance computing scenario, the status data of the hardware changes dynamically. The preset cycle means obtaining the key status information of the hardware at fixed time intervals, which can ensure that the acquired data is real-time and can timely reflect the current real status of the hardware. Through continuous and periodic monitoring, we can grasp the changing trend of the hardware status so as to make corresponding adjustments in time.
[0043] The subprocess.check_output function is a function in the subprocess module. It allows calling external commands in Python programs and obtaining their output results. In this step, the function is used to call system commands related to hardware temperature monitoring to obtain the real-time temperature of the target hardware. The get_memory_usage function is also a function in the subprocess module. Its function is to obtain the memory usage of the target hardware. Memory usage is one of the important indicators to measure the degree of hardware resource utilization. Excessive memory usage may cause system performance degradation or even crash. The get_memory_usage function can be used to grasp the usage of hardware memory in real time, providing a basis for subsequent resource allocation and optimization.
[0044] 402. Obtaining a performance index of the target hardware in real time, where the performance index represents the ability of the target hardware to perform operations of different precisions in real time; In this embodiment, the performance index of the target hardware is a comprehensive indicator that reflects the ability of the target hardware to perform operations with different precisions. In deep learning and high-performance computing, different tasks have different requirements for computing precision. For example, some tasks may only require lower precision (such as half-precision floating point numbers) to meet the needs, while some tasks require higher precision (such as single-precision or double-precision floating point numbers). The performance index can help us understand the computing efficiency of the hardware at different precisions, so as to reasonably select the computing precision according to the needs of specific tasks and improve computing efficiency.
[0045] 403. Calculate the load balancing factor of the target server in real time; In this embodiment, the load balancing factor is a quantitative indicator used to measure the load of the target server. It comprehensively considers multiple load-related factors of the target server, such as CPU usage, memory usage, disk I / O load, network bandwidth usage, etc. By calculating the load balancing factor, you can have an intuitive understanding of the overall load status of the target server, so as to determine whether the target server is in a balanced working state.
[0046] 404. Evaluate and calculate the load based on the load balancing factor; In this embodiment, by analyzing the size and change trend of the load balancing factor, it can be determined whether the computing load of the target server is within the normal range, too high or too low. When the load balancing factor exceeds the preset threshold, it means that the computing load of the target server is too high, and corresponding measures may need to be taken to reduce the load, and some tasks need to be migrated to other servers with lower loads in time to achieve load balancing of the entire system; when the computing load is too low, it means that the resources of the target server are not fully utilized, and more tasks can be assigned to the target server.
[0047] 405. If it is detected that an abnormality occurs in the step of obtaining the status data and performance index of the target hardware and the computing load of the target server in real time, the abnormal data is sent to the processing server.
[0048] In this embodiment, in the process of obtaining hardware status data, performance index and server computing load in real time, abnormal situations may occur due to various reasons, such as hardware failure, network interruption, sensor failure, etc. Once an abnormal situation is detected, the relevant abnormal data needs to be sent to the processing server. The processing server can analyze and process these abnormal data, such as recording logs, issuing alarms, taking corresponding emergency measures, etc. Timely processing of abnormal data can ensure the stability and reliability of the system and reduce losses caused by abnormal situations.
[0049] The above embodiment describes the method for optimizing the calculation graph provided by the present application. The following describes the system, electronic device, and storage medium for optimizing the calculation graph provided by the present application: See also Figure 5 , the present application provides an embodiment of a system for optimizing a computational graph, including: A real-time acquisition unit 501 is used to acquire the status data and performance index of the target hardware and the computing load of the target server in real time, the status data including temperature and memory usage; A dynamic adjustment unit 502, used to dynamically adjust the custom task list and the calculation graph according to the state data, the performance index and the calculation load, wherein the custom task list includes multiple calculation methods; An execution unit 503 is used to execute the computing tasks in the dynamically adjusted custom task list according to the dynamically adjusted computing graph, and obtain the execution result; The optimization unit 504 is used to perform optimization according to the execution result to obtain an optimized calculation graph.
[0050] Optionally, before the real-time acquisition unit 501, the method further includes: A setting unit 505 is used to set the mindSpore environment through context; The initialization unit 506 is used to initialize the matrix multiplication calculation method, the two-dimensional convolution calculation method and the rectified linear unit calculation method in the custom task list.
[0051] Optionally, the dynamic adjustment unit 502 is specifically configured to: Dynamically adjust the calculation frequency of various calculation methods according to temperature; Dynamically adjust the calculation accuracy of multiple calculation methods according to the preset error tolerance and performance index; Dynamically adjust the structure of the computation graph based on memory usage and computational load.
[0052] Optionally, the dynamic adjustment unit 502 is specifically configured to: If the temperature exceeds a preset temperature threshold, the calculation frequency of the multiple calculation methods is reduced.
[0053] Optionally, the dynamic adjustment unit 502 is specifically configured to: Calculate the precision factor based on the preset error tolerance and performance index; If the precision factor is greater than 0.8, the calculation precision of various calculation methods is set to half-precision floating point numbers; If the precision factor is greater than 0.5 and less than or equal to 0.8, the calculation precision of multiple calculation methods is set to mixed precision; If the precision factor is less than or equal to 0.5, the calculation precision of various calculation methods is set to single-precision floating point numbers.
[0054] Optionally, the dynamic adjustment unit 502 is specifically configured to: If the memory usage rate is higher than the preset memory usage threshold, the computation graph is split into multiple computation subgraphs; If the computing load is higher than the preset load threshold, the task migration of the computing graph is performed.
[0055] Optionally, the real-time acquisition unit 501 is specifically used for: According to the preset cycle, the subprocess.check_output function of the subprocess module is called to obtain the temperature of the target hardware in real time, and the get_memory_usage function of the subprocess module is called to obtain the memory usage of the target hardware in real time; Obtain the performance index of the target hardware in real time. The performance index represents the ability of the target hardware to perform operations of different precisions in real time. Calculate the load balancing factor of the target server in real time; Evaluate the computational load based on the load balancing factor; If an abnormality is detected in the step of obtaining the status data and performance index of the target hardware and the computing load of the target server in real time, the abnormal data will be sent to the processing server.
[0056] See also Figure 6 , the present application provides an electronic device, including: Processor 601 , memory 602 , input / output unit 603 , and bus 604 .
[0057] The processor 601 is connected to the memory 602 , the input and output unit 603 , and the bus 604 .
[0058] The memory 602 stores a program, and the processor 601 calls the program to execute the following steps: Figures 1 to 4 A method for optimizing a computational graph as shown in any one of the embodiments.
[0059] The present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, the program performs the following steps: Figures 1 to 4 A method for optimizing a computational graph as shown in any one of the embodiments.
[0060] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0061] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, 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, such as 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0062] 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.
[0063] 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.
[0064] 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 is essentially 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. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A method for optimizing a computational graph, characterized in that: include: Acquire status data and performance index of target hardware and computing load of target server in real time, wherein the status data includes temperature and memory usage; Dynamically adjusting a custom task list and a calculation graph according to the state data, the performance index, and the calculation load, wherein the custom task list includes multiple calculation methods; According to the dynamically adjusted calculation graph, the calculation tasks in the dynamically adjusted custom task list are executed, and the execution results are obtained; Optimization is performed according to the execution result to obtain an optimized calculation graph.
2. The method according to claim 1, characterized in that The multiple calculation methods include a matrix multiplication calculation method, a two-dimensional convolution calculation method, and a rectified linear unit calculation method. Before the real-time acquisition of the state data of the target hardware and the calculation load of the target server, the method further includes: Set the mindSpore environment through context; Initialize the matrix multiplication calculation method, two-dimensional convolution calculation method, and rectified linear unit calculation method in the custom task list.
3. The method according to claim 1, characterized in that The dynamically adjusting the custom task list and the calculation graph according to the state data, the performance index and the calculation load includes: Dynamically adjusting the calculation frequencies of the multiple calculation methods according to the temperature; Dynamically adjusting the calculation accuracy of the multiple calculation methods according to a preset error tolerance and the performance index; The structure of the computational graph is dynamically adjusted according to the memory usage and the computational load.
4. The method according to claim 3, characterized in that The dynamically adjusting the calculation frequencies of the multiple calculation methods according to the temperature includes: If the temperature exceeds a preset temperature threshold, the calculation frequency of the multiple calculation methods is reduced.
5. The method according to claim 3, characterized in that: The dynamically adjusting the calculation accuracy of the multiple calculation methods according to the preset error tolerance and the performance index includes: Calculating a precision factor based on a preset error tolerance and the performance index; If the precision factor is greater than 0.8, the calculation precision of the multiple calculation methods is set to half-precision floating point number; If the precision factor is greater than 0.5 and less than or equal to 0.8, the calculation precision of the multiple calculation methods is set to mixed precision; If the precision factor is less than or equal to 0.5, the calculation precision of the multiple calculation methods is set to single-precision floating point numbers.
6. The method according to claim 3, characterized in that The structure of the computational graph is dynamically adjusted according to the memory usage and the computational load: If the memory usage rate is higher than a preset memory usage threshold, splitting the computation graph into multiple computation subgraphs; If the computing load is higher than a preset load threshold, the computing graph is task migrated.
7. The method according to claim 1, characterized in that The real-time acquisition of the status data and performance index of the target hardware and the computing load of the target server, wherein the status data includes temperature and memory usage, includes: According to a preset cycle period, the subprocess.check_output function of the subprocess module is called to obtain the temperature of the target hardware in real time, and the get_memory_usage function of the subprocess module is called to obtain the memory usage rate of the target hardware in real time; Acquire a performance index of the target hardware in real time, wherein the performance index represents the ability of the target hardware to perform operations of different precisions in real time; Calculate the load balancing factor of the target server in real time; Evaluate the calculation load according to the load balancing factor; If it is detected that the step of acquiring the status data and performance index of the target hardware and the computing load of the target server in real time is abnormal, the abnormal data is sent to the processing server.
8. A system for optimizing a computational graph, characterized in that: include: A real-time acquisition unit, used to acquire status data and performance index of target hardware and computing load of target server in real time, wherein the status data includes temperature and memory usage; A dynamic adjustment unit, used to dynamically adjust a custom task list and a calculation graph according to the state data, the performance index and the calculation load, wherein the custom task list includes multiple calculation methods; An execution unit, used to execute the computing tasks in the dynamically adjusted custom task list according to the dynamically adjusted computing graph, and obtain the execution results; The optimization unit is used to perform optimization according to the execution result to obtain an optimized calculation graph.
9. An electronic device, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method for optimizing a computation graph according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is executed on a computer, the method for optimizing a computational graph according to any one of claims 1 to 7 is performed.
Citation Information
Patent Citations
Distribution factor-based rapid load flow calculation algorithm applied to cascading failure
CN102855381A
Heuristically guided asynchronous history optimization method and related equipment
CN115633031A
Computation graph optimization method, device and equipment
CN116204847A
Automatic resource allocation method for bearing neural network
CN119356836A