Dynamic storage management method, device, equipment and medium during task runtime
By using a first-in-first-out queue to manage buffer objects in reversible computing tasks, the problem of being unable to adapt to the storage characteristics of reversible deep learning models in the existing technology is solved, and the utilization of storage resources and computing efficiency are improved.
Patent Information
- Application Number
- CN202410789232.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-06-19
AI Technical Summary
Existing technologies cannot fully adapt to the storage characteristics of reversible deep learning models, resulting in low utilization efficiency of storage resources.
When performing reversible computing tasks, a first-in-first-out queue is used to manage buffer objects. By identifying the buffer objects in the memory release request and adding them to the queue, the queue is sequentially scanned to obtain buffer objects that satisfy the memory application request, avoiding data refresh and reset operations. , improve the reuse rate of storage resources.
It improves the utilization of computing, bandwidth and storage resources of the reversible deep learning model, and reduces the time overhead and runtime overhead of memory management.
Smart Images

Figure CN118363542B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of memory management technology, and in particular to a method, device, equipment and medium for dynamic storage management during task execution. Background Art
[0002] The reversibility technology of deep learning models is a technical solution that can effectively optimize the efficiency of computing, bandwidth and storage resource utilization during model training. The specific implementation method is to convert certain local structures (also called reversible structures) in the deep learning model into specific reversible modes to obtain a reversible deep learning model. Among them, the core of the reversible mode is to use the gradient tensor at the output position and the adjoint tensor transmitted through the reversible structure to synthesize the gradient, eliminating the need for accumulated storage activations.
[0003] Through research, the inventors found that the reversible deep learning model has storage characteristics such as short storage life cycle and frequent storage reuse during the model training process. However, there is no storage management strategy in the prior art that can accurately adapt to the storage characteristics of the reversible deep learning model. Therefore, the advantages of the reversible deep learning model cannot be fully utilized. Summary of the invention
[0004] The present invention provides a method, device, equipment and medium for dynamic storage management during task execution, so as to provide a dynamic storage management strategy that effectively adapts to reversible computing tasks.
[0005] According to one aspect of an embodiment of the present invention, a dynamic storage management method during task runtime is provided, comprising:
[0006] In the process of using the back-end system to execute the reversible computing task, whenever a memory release request is detected, a first buffer object in the memory release request is identified, and the first buffer object is added to a set first-in-first-out queue;
[0007] Whenever a memory application request is detected, the first-in-first-out queue is sequentially scanned to obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request, and the second buffer object is provided to the requester of the memory application request.
[0008] According to another aspect of an embodiment of the present invention, a dynamic storage management device during task execution is provided, comprising:
[0009] A memory release processing module is used to, in the process of using the back-end system to execute the reversible computing task, whenever a memory release request is detected, identify the first buffer object in the memory release request and add the first buffer object to a set first-in-first-out queue;
[0010] The memory application processing module is used to sequentially scan the first-in-first-out queue whenever a memory application request is detected, obtain the first second buffer object in the first-in-first-out queue that meets the memory application request, and provide the second buffer object to the requester of the memory application request.
[0011] According to another aspect of an embodiment of the present invention, an electronic device is provided, the electronic device comprising:
[0012] at least one processor; and
[0013] a memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the dynamic storage management method during task execution described in any embodiment of the present invention.
[0015] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the dynamic storage management method during task execution described in any embodiment of the present invention.
[0016] The technical solution of the embodiment of the present invention, through the process of using the back-end system to execute reversible computing tasks, whenever a memory release request is detected, the first buffer object in the memory release request is identified, and the first buffer object is added to the set first-in-first-out queue; whenever a memory application request is detected, the first-in-first-out queue is sequentially scanned to obtain the first second buffer object in the first-in-first-out queue that meets the memory application request, and the second buffer object is provided to the requester of the memory application request. The technical solution makes full use of the storage usage characteristics of the reversible deep learning model, such as the short storage life cycle and frequent storage reuse, the rule that the input and output tensor capacities of a single reversible structure are usually consistent, and the total storage capacity during the model training process tends to be consistent, and innovatively proposes a new dynamic storage management strategy that can effectively adapt to reversible computing tasks, so as to further improve the advantages of the reversible deep learning model in computing, bandwidth and storage resource utilization.
[0017] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 is a flowchart of a dynamic storage management method during task execution provided by Embodiment 1 of the present invention;
[0020] Figure 2 is a flowchart of another method for dynamic storage management during task execution provided by Embodiment 2 of the present invention;
[0021] Figure 3 It is a flowchart of a method for realizing a method of searching step by step in a frequency reduction direction to obtain a target frequency with the goal of minimizing runtime time overhead, which is applicable to an embodiment of the present invention;
[0022] Figure 4 is a schematic diagram of a dynamic storage management scenario applicable to an embodiment of the present invention;
[0023] Figure 5 is a schematic diagram of the structure of a dynamic storage management device during task execution provided by Embodiment 3 of the present invention;
[0024] Figure 6 It is a structural schematic diagram of an electronic device for implementing the dynamic storage management method during task execution according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Embodiment 1
[0028] Figure 1 This is a flowchart of a method for dynamic storage management during task execution provided by Embodiment 1 of the present invention. This embodiment is applicable to the case of dynamic storage management in a reversible computing scenario. The method can be executed by a dynamic storage management device during task execution. The device can be implemented in the form of hardware and / or software and can generally be configured in an electronic device for executing reversible computing tasks. Figure 1 As shown, the method includes:
[0029] S110. In the process of using the backend system to execute the reversible computing task, whenever a memory release request is detected, a first buffer object in the memory release request is identified, and the first buffer object is added to a set first-in-first-out queue.
[0030] The backend system can be understood as a physical execution device for loading and executing a set machine learning model. The reversible computing task can be understood as a task of performing reverse gradient calculation using one or more reversible modes included in the reversible deep learning model.
[0031] As mentioned above, the reversible mode refers to the ability to synthesize the gradient using the gradient tensor at the output position and the accompanying tensor transmitted through its own structure to eliminate the specific subnetwork architecture of accumulated storage activation. At present, reversible modes of various network structures have been developed, such as additive reversible mode, affine reversible mode, or momentum reversible mode, etc., which are not limited in this embodiment. Accordingly, the reversible computing task can be a model training task for setting a reversible deep learning model.
[0032] Specifically, during the process of the backend system executing a reversible computing task, a resource party (for example, a computing thread started in a computing unit) applies for a piece of memory (also called a buffer object) through a memory application request, and after completing the set computing task by using the memory, it can send a memory release request to release the continued occupation of the memory. Among them, the buffer object can be understood as a memory space of a set size.
[0033] In the prior art, when the memory management service receives the memory release request, it first detects whether the memory is being reused by other resource parties. If so, the memory continues to be occupied until all reused resource parties release the memory. If not, the data stored in this memory needs to be refreshed and reset, and released to the memory pool to be provided to the resource party for subsequent application.
[0034] However, the inventors have discovered through research that during the execution of reversible computing tasks, because the introduction of the reversible mode eliminates the need for cumulative storage activation, the life cycle of the buffer object is short, and a large number of allocated buffer objects will be quickly released. In addition, due to the special form of the reversible mode, the sizes of buffer objects in reversible computing are usually very similar. Therefore, over a period of time, the application and release of buffer objects of the same or similar size will occur intensively.
[0035] In view of this, in each embodiment of the present invention, a new type of dynamic storage management strategy is proposed. Whenever a memory release request is detected, the first buffer object to be released is first identified in the memory release request. At this time, instead of executing the memory release process for the first buffer object according to the prior art, the first buffer object is directly added to a first-in-first-out (FIFO) queue.
[0036] That is, different from the prior art, when the resource release conditions are met, the first buffer object of the present application no longer performs operations of refreshing and resetting data and releasing it to the memory pool, but can be directly added to the first-in-first-out queue for cache to wait for application by other resource parties.
[0037] In this embodiment, considering that during the execution of a reversible computing task, multiple resource parties may apply for the same buffer object for common use, the multiple resource parties will send corresponding memory release requests after finishing using the buffer object.
[0038] Based on this, adding the first buffer object to the set first-in-first-out queue can be specifically as follows: if the first buffer object is not stored in the first-in-first-out queue, directly adding the first buffer object to the first-in-first-out queue; if the first buffer object is already stored in the first-in-first-out queue, giving up adding the first buffer object to the first-in-first-out queue.
[0039] The FIFO queue may be a pre-configured storage queue for storing buffer objects to be released for direct application by other resource parties. The storage space size of the FIFO queue may be preset according to actual conditions, and this embodiment does not limit this.
[0040] Correspondingly, before adding the first buffer object to the set first-in-first-out queue, the method may further include: reducing a reference count of the first buffer object.
[0041] Each buffer object applied for use has a one-to-one reference count, which is used to describe how many resource parties reuse the buffer object. Accordingly, each time a buffer object is applied for use by a resource party, the reference count of the buffer object is increased by one; each time a buffer object is released by a resource party, the reference count of the buffer object is decreased by one.
[0042] It is understandable that before adding the first buffer object to the set first-in-first-out queue, if the first-in-first-out queue is full, the first buffer object stored in the first-in-first-out queue can be directly replaced. Further, if it is detected that the above storage replacement operation is frequently performed, it can be considered to expand the storage space of the first-in-first-out queue according to a certain ratio.
[0043] S120. Whenever a memory application request is detected, sequentially scan the first-in-first-out queue, obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request, and provide the second buffer object to the requester of the memory application request.
[0044] In this embodiment, whenever a memory application request is detected, a first-in-first-out queue is first searched for a second buffer object that can satisfy the memory application request in a first-in-first-out order. If the second buffer object can be found, the second buffer object can be directly provided to the requester of the memory application request without performing an operation of applying for memory in the memory pool.
[0045] Combined with the data storage characteristics of reversible computing described above, the buffer objects stored in the first-in-first-out queue that are released first are more likely to be seen by memory application requests first. This time feature is consistent with the rule that the buffer objects in reversible computing have a short life cycle. In addition, the first-in-first-out queue skips the data refresh, reset, and merging actions of the conventional memory pool buffer objects, and the released buffer objects are stored at the same size. This feature is consistent with the feature that the sizes are usually similar or the same in reversible computing, and the data space utilization rate is high.
[0046] Accordingly, in an optional implementation of this embodiment, sequentially scanning the first-in-first-out queue to obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request may include:
[0047] Obtain a buffer object to be selected in the first-in-first-out queue in turn, and detect whether the buffer object to be selected meets the memory requirement of the memory application request; if so, continue to detect whether the reference count of the buffer object to be selected meets the reusability condition; if not, return to execute the operation of obtaining a buffer object to be selected in the first-in-first-out queue in turn; if it is determined that the reusability condition is met, determine the buffer object to be selected as the second buffer object, and increase the reference count of the buffer object to be selected; if it is determined that the reusability condition is not met, return to execute the operation of obtaining a buffer object to be selected in the first-in-first-out queue in turn.
[0048] In this embodiment, a candidate buffer object can be obtained in sequence according to the first-in-first-out order defined in the first-in-first-out queue to perform two tests. The first test is to detect whether the memory size of the candidate buffer object meets the memory requirement of the memory application request. If it does, the second test is performed to detect whether the candidate buffer object can be reused. Generally speaking, when the reference count of the candidate buffer object is 0, it means that all resource parties using the candidate buffer object have completed the release of its resources. At this time, the candidate buffer object can be determined as the second buffer object.
[0049] Correspondingly, after the to-be-selected buffer object is determined as the second buffer object, the reference count of the to-be-selected buffer object can be increased accordingly. The specific increase amount is matched by the number of requesting parties defined in the memory application request. If the number of requesting parties is 2, the reference count of the to-be-selected buffer object is increased by 2, and if the number of requesting parties is 3, the reference count of the to-be-selected buffer object is increased by 3.
[0050] Of course, it is understandable that if no second buffer object satisfying the memory application request is obtained by traversing the FIFO queue, then the solution of the prior art can be used to apply for the required second buffer object from the memory pool.
[0051] Further, providing the second buffer object to the requester of the memory application request may specifically include:
[0052] After skipping the data refresh and reset operation on the second buffer object and marking the second buffer object as a data ineffective state, the second buffer object is provided to the requester of the memory application request.
[0053] As mentioned above, since the embodiments of the present invention do not actually release the buffer object to the memory pool, the data refresh and reset operations on the second buffer object can be directly skipped to further improve the efficiency of memory management and simplify the memory management implementation process. However, it should be noted that although the data refresh and reset operations on the second buffer object are skipped, it is necessary to mark the second buffer object as being in an invalid data state in the second buffer object.
[0054] The data ineffective state is used to describe that the data currently stored in the second buffer object is invalid data, so as to avoid data calculation errors caused by the requester of the memory application request directly using the data stored in the second buffer object.
[0055] The technical solution of the embodiment of the present invention, through the process of using the back-end system to execute reversible computing tasks, whenever a memory release request is detected, the first buffer object in the memory release request is identified, and the first buffer object is added to the set first-in-first-out queue; whenever a memory application request is detected, the first-in-first-out queue is sequentially scanned to obtain the first second buffer object in the first-in-first-out queue that meets the memory application request, and the second buffer object is provided to the requester of the memory application request. The technical solution makes full use of the storage usage characteristics of the reversible deep learning model, such as the short storage life cycle and frequent storage reuse, the rule that the input and output tensor capacities of a single reversible structure are usually consistent, and the total storage capacity during the model training process tends to be consistent, and innovatively proposes a new dynamic storage management strategy that can effectively adapt to reversible computing tasks, so as to further improve the advantages of the reversible deep learning model in computing, bandwidth and storage resource utilization.
[0056] Embodiment 2
[0057] Figure 2 This is a flowchart of another dynamic storage management method during task execution provided by Embodiment 2 of the present invention. This embodiment is optimized based on the above embodiments. In this embodiment, a method for implementing memory defragmentation and storage compression operations at a lower frequency is specifically provided in the process of using a backend system to execute a reversible computing task. Figure 2 As shown, the method includes:
[0058] S210 , starting from the standard execution frequency and aiming at minimizing the runtime time overhead, searching step by step in the frequency reduction direction to obtain the target frequency.
[0059] The target frequency is less than a standard execution frequency of a memory defragmentation operation and a storage compression operation.
[0060] Compared with conventional computing requirements, the reversible mode contained in the reversible deep learning model has the same input and output tensor capacity and shape due to the reversible transformation. Therefore, defragmentation and storage compaction are time-consuming and inefficient tasks in the operation of the reversible deep learning model. The reason is that a large number of fragments will frequently be merged and sorted to reallocate small-sized storage requirements, resulting in a large amount of runtime overhead.
[0061] In view of this, the embodiments of the present invention no longer follow the standard execution frequency (a preset empirical value) of memory defragmentation operations and storage compression operations commonly used in the prior art, but choose to design a more reasonable target frequency that is generally much smaller than the standard execution frequency.
[0062] Among them, the target frequency refers to the frequency of executing memory defragmentation operations and storage compression operations in the process of using the back-end system to perform reversible computing tasks. For example, the frequency can be the number of executions per unit time, such as 3 times per second or 5 times per second.
[0063] Accordingly, in the reversible computing process, when the current system time reaches the execution time point that matches the target frequency, the backend system generally interrupts the execution of the reversible computing task, and instead performs the memory defragmentation operation and the storage compression operation first. Of course, it is understandable that the smaller the above target frequency is set, the less time is spent on the memory defragmentation operation and the storage compression operation in the execution of the reversible computing task. However, when the target frequency is too low, the backend system may have excessive memory fragmentation, which may significantly deteriorate the computing performance. Therefore, it is necessary to search for an optimal value of the target frequency with the goal of minimizing the runtime time overhead.
[0064] The runtime time overhead can be understood as the total time span required for the backend system to fully execute the reversible computing task. The above runtime time overhead includes the time taken by the backend system to execute the actual reversible computing task, as well as the time taken by the interrupt task to perform one or more memory defragmentation operations and storage compression operations before the reversible computing task is completed.
[0065] It can be understood that by executing the dynamic storage management method of each embodiment of the present invention, the demand for memory defragmentation operations and storage compression operations can be greatly reduced. Therefore, starting from the standard execution frequency, the most suitable target frequency can be found in the direction of reducing the frequency.
[0066] Specifically, in Figure 3 , which takes the standard execution frequency as the starting point, minimizes the runtime time overhead, and searches step by step in the frequency reduction direction to obtain the target frequency. Figure 3 As shown, the implementation method specifically includes:
[0067] S3100: Perform frequency reduction processing on the current frequency according to the target ratio to obtain a reduced frequency, wherein the current frequency is initialized as a standard execution frequency.
[0068] Specifically, the target ratio may be preset according to actual conditions, for example, 0.5 times, 0.6 times or 0.7 times, etc., and this embodiment does not limit this.
[0069] S3200: During the execution of the test task, perform a memory defragmentation operation and a storage compression operation at a reduced frequency, and after the execution is completed, obtain the current task execution time. The test task is consistent with the task type of the reversible computing task.
[0070] In this embodiment, a test task that is consistent with the task type of the reversible computing task but has a computational scale much smaller than that of the reversible computing task can be pre-constructed. The reason for this setting is that the current task execution time calculated for the test task can accurately describe the actual task execution time of the reversible computing task from the numerical change trend.
[0071] S3300, check whether the current task execution time is less than the currently stored optimized execution time: if so, execute S3400; otherwise, execute S3800.
[0072] The optimized execution time is initialized to the task execution time when the memory defragmentation operation and the storage compression operation are performed according to the standard execution frequency.
[0073] It can be understood that when the execution frequency of memory defragmentation operations and storage compression operations is reduced, when the current task execution time obtained is less than the optimized execution time, it means that the application effect of the reduced frequency is better than the current frequency. At this time, the reduced frequency can be used as the new current frequency, and the current task execution time can be used as the new optimized execution time.
[0074] Similarly, after reducing the execution frequency of memory defragmentation operations and storage compression operations, the current task execution time obtained is greater than or equal to the optimized execution time, indicating that the application effect of the current reduced frequency is worse than the current frequency, indicating that the newly selected search frequency cannot be lower than the current reduced frequency. At this time, the reduced frequency can be determined as the current limit search frequency, and between the current frequency and the current limit search frequency, it is searched whether there is a new frequency that is lower than the current frequency and has a better application effect than the current frequency.
[0075] S3400 , taking the reduced frequency as the new current frequency, and taking the current task execution time as the new optimized execution time, and executing S3500 .
[0076] S3500, check whether there is a current limit search frequency: if not, return to execute S3100; if so, execute S3600.
[0077] If there is no limit search frequency currently, it means that the current frequency can be continuously reduced without restriction to find the optimal frequency; if there is a limit search frequency currently, the optimal frequency must be found between the current frequency and the current limit search frequency.
[0078] S3600. Detect whether the search process is completed based on the numerical difference between the current frequency and the limit search frequency: if so, execute S3900; otherwise, execute S3700.
[0079] Specifically, when the numerical difference between the current frequency and the limit search frequency is small, for example, when the difference value is less than or equal to 1 or less than or equal to 2, the search may not be continued and the search result may be obtained directly.
[0080] S3700. After selecting a frequency between the current frequency and the limit search frequency as a new reduction frequency, return to execute S3200.
[0081] Specifically, a median frequency between the current frequency and the limit search frequency may be obtained as a new reduction frequency.
[0082] S3800: After determining the reduced frequency as the current limit search frequency, execute S3600.
[0083] S3900. Use the frequency corresponding to the optimized execution time stored when the search is completed as the target frequency.
[0084] In a specific example, assuming that the standard execution frequency is 100 times / second, and the task execution time corresponding to the standard execution frequency is 5 seconds, then, the standard execution frequency can be first used as the current frequency, and 5 seconds can be initialized and stored as the optimized execution time. First, the frequency is determined to be reduced to 50 times / second, and the corresponding task execution time corresponding to 50 times / second is obtained as 4.5 seconds. At this time, 50 times / second can be determined as the new current frequency, and 4.5 seconds can be updated and stored as the new optimized execution time. Afterwards, it is determined that the reduced frequency is 25 times / second, and the corresponding task execution time corresponding to 25 times / second is 4.8 seconds. Since 4.8 seconds is greater than 4.5 seconds, 25 times / second is required to be used as the limit search frequency, and a new reduced frequency is searched again between 25 times / second and 50 times / second, for example, 37 times / second, and the corresponding task execution time corresponding to 37 times / second is obtained as 4 seconds. At this time, 37 times / second can be used as the new previous frequency, and 4 seconds can be updated and stored as the new optimized execution time, and then, the new reduced frequency is searched again between 25 times / second and 37 times / second, and so on, until the entire search process is completed to find the optimal target frequency.
[0085] S220. In the process of using the backend system to execute the reversible computing task, perform memory defragmentation operations and storage compression operations according to the target frequency.
[0086] S230, in the process of using the backend system to execute the reversible computing task, whenever a memory release request is detected, identifying the first buffer object in the memory release request, and adding the first buffer object to a set first-in-first-out queue;
[0087] S240. Whenever a memory application request is detected, sequentially scan the first-in-first-out queue, obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request, and provide the second buffer object to the requester of the memory application request.
[0088] The technical solution of the embodiment of the present invention proposes a new low-frequency defragmentation and compression strategy. By searching for the optimal low-frequency execution of memory defragmentation operations and storage compression operations, the runtime overhead of reversible computing tasks can be greatly reduced, and the operating efficiency of reversible deep learning models during the model training process can be significantly improved.
[0089] Specific application scenarios
[0090] Figure 4 FIG. 1 is a schematic diagram of a dynamic storage management scenario applicable to an embodiment of the present invention. Figure 4 As shown, the entire dynamic storage management scenario is divided into two parts: system resources and runtime system through the dotted line.
[0091] Specifically, at the system resource level, a mapping relationship between physical addresses and virtual address spaces needs to be established. First, a unified address space needs to be built on the physical layer to manage the host machine and the acceleration device. This step is the basis for ensuring that all storage resources can be effectively managed. In this way, data from different physical storage media can be seamlessly processed, whether internal storage or externally connected devices. Next, at the virtual address layer, physical storage needs to be mapped to virtual addresses. The implementation of this layer is critical because it provides an abstract way for upper-level applications (i.e., runtime systems) to access storage resources without having to worry about specific physical storage details. The design of the virtual address layer can also enhance the flexibility and scalability of storage management.
[0092] In the embodiments of the present invention, by combining the memory pool with the buffer object FIFO queue, fast memory allocation and recovery management can be performed. Specifically, based on the traditional memory pool management, the embodiments of the present invention introduce a layer of FIFO queue description for buffer objects (Buffer objects). Compared with the traditional memory pool, this combined use method is more suitable for processing storage usage requirements with short life cycle and high reuse frequency. The implementation of this step is crucial to improving the efficiency of memory management. Specifically, the module responds to requests for memory allocation and release in the following manner:
[0093] Memory allocation: When there is a storage allocation request, the FIFO queue is scanned sequentially. For the buffer object with the same capacity or larger capacity at the head of the queue, its reference count is checked to determine whether it can be reused. If it can be reused, the data refresh and reset steps are skipped and the buffer object is reused directly.
[0094] Memory release and reuse: When a temporary variable is used up, such as an activation value in the model, the reference count of the buffer object is reduced, but the storage is not immediately recycled or the object is destroyed. Instead, it is placed at the end of the FIFO queue and waits for storage application requirements of the appropriate size.
[0095] This design is also based on the characteristics of the short storage life cycle of the reversible deep learning model, and the characteristics of the overall storage of the reversible deep learning model is constant complexity and relatively stable. After the model completes the training warm-up, the memory utilization is quite stable, and there is a large number of tensor storage requirements of the same size. Therefore, canceling frequent storage recycling and replacing it with high-frequency direct reuse is a key implementation focus of each embodiment of the present invention.
[0096] Memory release and recycling: Destroy buffer objects and recycle system resources at a low frequency in the order of the FIFO queue. This solution is based on the consideration that the life cycle is generally short in the reversible model (the buffer object at the head of the FIFO queue is highly likely no longer needed). Recycling directly according to the FIFO queue avoids the high cost of program termination in the conventional memory recycling garbage collection process, and avoids the complex logic of coloring and changing the state of buffer objects in common memory garbage collection technologies. It greatly speeds up processing efficiency.
[0097] In general, this design can greatly improve the efficiency of memory allocation and release: it uses the characteristics of the FIFO queue to quickly recycle and reallocate memory. When a storage object is no longer needed, it is placed at the end of the FIFO queue and waits for the next allocation. When there is a new storage demand, the FIFO queue is checked first, and the free memory at the head of the queue is quickly allocated, which greatly speeds up the memory allocation and release process.
[0098] Specialized low-frequency defragmentation and storage compression strategies: Compared with conventional computing requirements, the reversible mode in the reversible deep learning model has the same input and output tensor capacity and shape due to the reversible conversion. Therefore, defragmentation and storage compression are relatively time-consuming and inefficient tasks in the operation of the reversible model. It will cause a large number of fragments to be merged and sorted and then reallocated to a small size of storage requirements. This will cause a lot of runtime overhead. The embodiments of the present invention adopt specialized low-frequency defragmentation and compression strategies. It is used to greatly reduce runtime overhead and significantly improve model operation efficiency.
[0099] Embodiment 3
[0100] Figure 5 This is a schematic diagram of the structure of a dynamic storage management device during task execution provided by Embodiment 3 of the present invention. Figure 5 As shown, the device comprises:
[0101] The memory release processing module 510 is used to identify the first buffer object in the memory release request and add the first buffer object to a set first-in-first-out queue whenever a memory release request is detected during the process of executing the reversible computing task using the back-end system;
[0102] The memory application processing module 520 is used to sequentially scan the FIFO queue whenever a memory application request is detected, obtain the first second buffer object in the FIFO queue that meets the memory application request, and provide the second buffer object to the requester of the memory application request.
[0103] The technical solution of the embodiment of the present invention, through the process of using the back-end system to execute reversible computing tasks, whenever a memory release request is detected, the first buffer object in the memory release request is identified, and the first buffer object is added to the set first-in-first-out queue; whenever a memory application request is detected, the first-in-first-out queue is sequentially scanned to obtain the first second buffer object in the first-in-first-out queue that meets the memory application request, and the second buffer object is provided to the requester of the memory application request. The technical solution makes full use of the storage usage characteristics of the reversible deep learning model, such as the short storage life cycle and frequent storage reuse, the rule that the input and output tensor capacities of a single reversible structure are usually consistent, and the total storage capacity during the model training process tends to be consistent, and innovatively proposes a new dynamic storage management strategy that can effectively adapt to reversible computing tasks, so as to further improve the advantages of the reversible deep learning model in computing, bandwidth and storage resource utilization.
[0104] Based on the above embodiments, it further includes a reference count update module, which is used to:
[0105] Before adding the first buffer object to the set first-in-first-out queue, reducing the reference count of the first buffer object;
[0106] Accordingly, the memory application processing module 520 may be specifically used for:
[0107] Obtaining a buffer object to be selected from the first-in-first-out queue in turn, and detecting whether the buffer object to be selected meets the memory requirement of the memory application request;
[0108] If the condition is satisfied, then continue to check whether the reference count of the candidate buffer object meets the reusability condition; if not, return to execute the operation of obtaining a candidate buffer object in the first-in-first-out queue in sequence;
[0109] If it is determined that the reusable condition is met, the to-be-selected buffer object is determined as the second buffer object, and a reference count of the to-be-selected buffer object is increased;
[0110] If it is determined that the reusability condition is not met, the operation of sequentially acquiring a buffer object to be selected from the first-in-first-out queue is returned to be executed.
[0111] Based on the above embodiments, the memory application processing module 520 can be further used to:
[0112] After skipping the data refresh and reset operation on the second buffer object and marking the second buffer object as a data ineffective state, the second buffer object is provided to the requester of the memory application request.
[0113] Based on the above embodiments, a storage compression module may be further included, which is used to:
[0114] In the process of performing the reversible computing task using the backend system, performing the memory defragmentation operation and the storage compression operation according to the target frequency;
[0115] The target frequency is less than a standard execution frequency of a memory defragmentation operation and a storage compression operation.
[0116] On the basis of the above embodiments, a target frequency search module may also be included, which is used to:
[0117] Before executing the memory defragmentation operation and the storage compression operation according to the target frequency, starting from the standard execution frequency and aiming at minimizing the runtime time overhead, the target frequency is acquired by searching step by step along the frequency reduction direction.
[0118] Based on the above embodiments, the target frequency search module can be specifically used for:
[0119] According to the target ratio, the current frequency is subjected to frequency reduction processing to obtain a reduced frequency; wherein the current frequency is initialized as a standard execution frequency;
[0120] During the execution of the test task, the memory defragmentation operation and the storage compression operation are performed at a reduced frequency, and after the execution is completed, the current task execution time is obtained;
[0121] Comparing the current task execution time with the currently stored optimized execution time; wherein the optimized execution time is initialized to the task execution time when the memory defragmentation operation and the storage compression operation are performed according to the standard execution frequency;
[0122] If the current task execution time is less than the optimized execution time, the reduced frequency is used as the new current frequency, and the current task execution time is used as the new optimized execution time;
[0123] Detect whether there is a limit search frequency at present. If not, return to execute and perform frequency reduction processing on the current frequency according to the target ratio; if so, select a frequency between the current frequency and the limit search frequency as a new reduction frequency, return to execute during the execution of the test task, perform memory defragmentation operation and storage compression operation according to the reduction frequency until the search process is completed;
[0124] If the current task execution time is greater than or equal to the optimized execution time, after determining the reduced frequency as the current limit search frequency, returning to execute, after selecting a frequency between the current frequency and the limit search frequency as a new reduced frequency, returning to execute during the execution of the test task, performing a memory defragmentation operation and a storage compression operation according to the reduced frequency until the search process is completed;
[0125] Using the frequency corresponding to the optimized execution time stored when the search is completed as the target frequency;
[0126] The test task is consistent with the task type of the reversible computing task.
[0127] Based on the above embodiments, the reversible computing task may be a model training task for setting a reversible deep learning model.
[0128] The dynamic storage management device during task execution provided by the embodiment of the present invention can execute the dynamic storage management method during task execution provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0129] Embodiment 4
[0130] Figure 6 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0131] like Figure 6 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0132] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0133] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, for example, executing the dynamic storage management method during task runtime as described in any embodiment of the present invention.
[0134] That is: in the process of using the back-end system to perform reversible computing tasks, whenever a memory release request is detected, the first buffer object in the memory release request is identified, and the first buffer object is added to the set first-in-first-out queue; whenever a memory application request is detected, the first-in-first-out queue is scanned sequentially, and the first second buffer object in the first-in-first-out queue that meets the memory application request is obtained, and the second buffer object is provided to the requester of the memory application request.
[0135] In some embodiments, the dynamic storage management method during task execution as described in any embodiment of the present invention may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the dynamic storage management method during task execution as described in any embodiment of the present invention described above may be executed. Alternatively, in other embodiments, the processor 11 may be configured to execute the dynamic storage management method during task execution as described in any embodiment of the present invention by any other appropriate means (for example, by means of firmware).
[0136] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0137] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0138] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0139] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0140] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0141] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0142] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0143] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A dynamic storage management method during task runtime, characterized in that: include: In the process of using the back-end system to execute the reversible computing task, whenever a memory release request is detected, a first buffer object in the memory release request is identified, and the first buffer object is added to a set first-in-first-out queue; Whenever a memory application request is detected, sequentially scan the first-in-first-out queue, obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request, and provide the second buffer object to the requester of the memory application request; The method further comprises: According to the target ratio, the current frequency is subjected to frequency reduction processing to obtain a reduced frequency; wherein the current frequency is initialized as a standard execution frequency of a memory defragmentation operation and a storage compression operation; During the execution of the test task, the memory defragmentation operation and the storage compression operation are performed at a reduced frequency, and after the execution is completed, the current task execution time is obtained; Comparing the current task execution time with the currently stored optimized execution time; wherein the optimized execution time is initialized to the task execution time when the memory defragmentation operation and the storage compression operation are performed according to the standard execution frequency; If the current task execution time is less than the optimized execution time, the reduced frequency is used as the new current frequency, and the current task execution time is used as the new optimized execution time; Detect whether there is a limit search frequency at present. If not, return to execute and perform frequency reduction processing on the current frequency according to the target ratio; if so, select a frequency between the current frequency and the limit search frequency as a new reduction frequency, return to execute during the execution of the test task, perform memory defragmentation operation and storage compression operation according to the reduction frequency until the search process is completed; If the current task execution time is greater than or equal to the optimized execution time, after determining the reduced frequency as the current limit search frequency, returning to execute, after selecting a frequency between the current frequency and the limit search frequency as a new reduced frequency, returning to execute during the execution of the test task, performing a memory defragmentation operation and a storage compression operation according to the reduced frequency until the search process is completed; using a frequency corresponding to the optimized execution time stored when the search is completed as a target frequency, wherein the test task is consistent with the task type of the reversible computing task; In the process of using the back-end system to perform the reversible computing task, the memory defragmentation operation and the storage compression operation are performed according to the target frequency.
2. The method according to claim 1, characterized in that Before adding the first buffer object to the set first-in-first-out queue, the method further includes: Decrementing a reference count to the first buffer object; Sequentially scanning the first-in-first-out queue to obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request includes: Obtaining a buffer object to be selected from the first-in-first-out queue in turn, and detecting whether the buffer object to be selected meets the memory requirement of the memory application request; If the condition is satisfied, then continue to check whether the reference count of the candidate buffer object meets the reusability condition; if not, return to execute the operation of obtaining a candidate buffer object in the first-in-first-out queue in sequence; If it is determined that the reusable condition is met, the to-be-selected buffer object is determined as the second buffer object, and a reference count of the to-be-selected buffer object is increased; If it is determined that the reusability condition is not met, the operation of sequentially acquiring a buffer object to be selected from the first-in-first-out queue is returned to be executed.
3. The method according to claim 1, characterized in that Providing the second buffer object to the requester of the memory application request includes: After skipping the data refresh and reset operation on the second buffer object and marking the second buffer object as a data ineffective state, the second buffer object is provided to the requester of the memory application request.
4. The method according to any one of claims 1 to 3, characterized in that: The reversible computing task is a model training task for setting a reversible deep learning model.
5. A dynamic storage management device during task execution, characterized in that: include: A memory release processing module is used to, in the process of using the back-end system to execute the reversible computing task, identify the first buffer object in the memory release request whenever a memory release request is detected, and add the first buffer object to a set first-in-first-out queue; a memory application processing module, configured to sequentially scan the first-in-first-out queue whenever a memory application request is detected, obtain the first second buffer object in the first-in-first-out queue that satisfies the memory application request, and provide the second buffer object to the requester of the memory application request; The device also includes a target frequency search module, which is used to: According to the target ratio, the current frequency is subjected to frequency reduction processing to obtain a reduced frequency; wherein the current frequency is initialized as a standard execution frequency of a memory defragmentation operation and a storage compression operation; During the execution of the test task, the memory defragmentation operation and the storage compression operation are performed at a reduced frequency, and after the execution is completed, the current task execution time is obtained; Comparing the current task execution time with the currently stored optimized execution time; wherein the optimized execution time is initialized to the task execution time when the memory defragmentation operation and the storage compression operation are performed according to the standard execution frequency; If the current task execution time is less than the optimized execution time, the reduced frequency is used as the new current frequency, and the current task execution time is used as the new optimized execution time; Detect whether there is a limit search frequency at present. If not, return to execute and perform frequency reduction processing on the current frequency according to the target ratio; if so, select a frequency between the current frequency and the limit search frequency as a new reduction frequency, return to execute during the execution of the test task, perform memory defragmentation operation and storage compression operation according to the reduction frequency until the search process is completed; If the current task execution time is greater than or equal to the optimized execution time, after determining the reduced frequency as the current limit search frequency, returning to execute, after selecting a frequency between the current frequency and the limit search frequency as a new reduced frequency, returning to execute during the execution of the test task, performing a memory defragmentation operation and a storage compression operation according to the reduced frequency until the search process is completed; using a frequency corresponding to the optimized execution time stored when the search is completed as a target frequency, wherein the test task is consistent with the task type of the reversible computing task; In the process of using the back-end system to perform the reversible computing task, the memory defragmentation operation and the storage compression operation are performed according to the target frequency.
6. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the dynamic storage management method during task execution according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the dynamic storage management method during task execution according to any one of claims 1 to 4.
