Coop: Memory is not a Commodity

Tensor rematerialization allows the training of deep neural networks (DNNs) under limited memory budgets by checkpointing the models and recomputing the evicted tensors as needed. However, the existing tensor rematerialization techniques overlook the memory system in deep learning frameworks and implicitly assume that free memory blocks at different addresses are identical. Under this flawed assumption, discontiguous tensors are evicted, among which some are not used to allocate the new tensor. This leads to severe memory fragmentation and increases the cost of potential rematerializations. To address this issue, we propose to evict tensors within a sliding window to ensure all evictions are contiguous and are immediately used. Furthermore, we proposed cheap tensor partitioning and recomputable in-place to further reduce the rematerialization cost by optimizing the tensor allocation. We named our method Coop as it is a co-optimization of tensor allocation and tensor rematerialization. We evaluated Coop on eight representative DNNs. The experimental results demonstrate that Coop achieves up to $2\times$ memory saving and hugely reduces compute overhead, search latency, and memory fragmentation compared to the state-of-the-art baselines.

Paper

Similar papers

Peer review

Reviewer UBH87/10 · confidence 5/52023-06-26

Summary

The authors propose to consider memory fragmentation when using tensor rematerialization on dynamic computation graphs. With three new memory management methods, sliding window algorithm, cheap tensor partitioning, and recomputable in-place, the authors enhance the checkpointing method with lower computation overhead and memory consumption.

Strengths

* The paper is well-organized and easy to follow. * The perspective is new. Considering memory fragmentation can enhance the gradient checkpointing. * The results are great across the eight neural networks. * The implementation is available in the supplementary material.

Weaknesses

**Major issues** 1. Table 1. The cost density depends on the hardware accelerators. It is better to introduce the hardware specifications. The authors can also mention the arithmetic intensity, which is independent of the hardware. Also, in a single neural network, different operators belonging to the same category may have different cost densities (e.g., different kernel sizes in convolution layers). 2. In cheap tensor partitioning, the authors allocate tensors from the leftmost and rightmost of the memory pool. Is it possible to have more ports for the memory pool? What if there are 3 levels of cost densities in the computation graph? In general computation graphs, the cost density or the arithmetic intensity of operators has a continuous distribution. Is it a good idea to classify them into two categories, “cheap” and “expensive” tensors? 3. The authors miss one of the most important evaluation metrics, the end-to-end training time under different memory budgets, which is more critical than the computation overhead. 4. The authors mention that “static graph methods are beyond the scope of this paper.” I am aware that symbolic and eager executions have distinct features. However, I have several concerns about that. * Among the eight computation graphs in the experiments, six have static structures, while only two have dynamic ones. It is better to discuss more on the dynamic structures. * The proposed method leverages the global information that several tensors are unevictable. If the computation graph is fully dynamic, we have no idea which tensors will be used in the future. **Minor issues** 1. Line 180. Please explain the N. I assume that it is the number of tensors. 2. A period after “Compute Overhead and Memory Budget” in Line 287, “Search Latency” in Line 303, and “Memory Fragmentation” in Line 315. 3. The caption of Figure 5. y-axes -> y-axis. 4. Results on Search Latency. The authors may list other statistics, e.g., min/max value, standard deviation to demonstrate, to demonstrate the small variations of the proposed method. 5. The authors mainly use the term “memory allocation” in the paper. It is better to replace it with “memory management” since there are other memory operations, such as eviction.

Questions

Please see the Weaknesses, especially the major issues.

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

5: You are absolutely certain about your assessment. You are very familiar with the related work and checked the math/other details carefully.

Soundness

3 good

Presentation

3 good

Contribution

3 good

Limitations

The authors do not discuss limitations. I think the proposed COOP has the inherent limitations of the checkpoint method on the dynamic computation graphs.

Reviewer ks3C7/10 · confidence 3/52023-06-26

Summary

Tensor materialization trades the memory with recomputation. Prior tensor materialization methods do not consider the memory fragmentation problem of the memory system used in deep learning frameworks, which makes them evict unnecesary tensors. The authors of this paper proposed a memory-system-aware rematerialization method called Coop to reduce the memory fragmentation. Experiments show that Coop can achieve up to 2x memory saving comparied with prior works.

Strengths

1. The authors proposed a new method based on sliding window algorithm (sec 3.3) to alliviate the fragmentation problem of rematerialization. 2. The experiments show that this method is effective and can greatly reduce the compute overhead for specific memory ratio compared with prior works.

Weaknesses

1. The requirement of underlying memory allocator might limit the applicability of the proposed method This paper assumed the memory allocator used by the deep learning systems (discussed in section 2.1). The underlying memory allocator must be able to **merge** the freed chuncks if they are contiguous. There are other kinds of memory allocators (e.g., record the mapping from chunck size to a list of free chuncks with the specific chunk size) that do not have this feature, thus the proposed method can not be (directly) used for deep learning systems with this kind of memory allocators. 2. More discussion on the effectiveness of the the page-table-based memory system is needed Similar to CPU memory system, the GPU memory system also employed the page table to manage its memory. Thus, we can free the discontiguous memory chunks and allocate a new one with the sum of the sizes of the freed chunks. From the virtual memory's view, the allocated memory is contiguous. Thus, there is no fragmentation problem discussed in this paper, and the prior works can be directly used. The good news is that, since CUDA 11.2, we can directly use the memory pool [1] implemented in cuda runtime/driver to enjoy this feature. Thus, I am interested in whether the prior works have the fragmentation problem if they use the memory pool implemented in cuda? We can use the following program to validate that the page-table based GPU memory system. In the program, we allocate 3 chuncks of 7 GB called p1, p2, and p3. Then, we free p1 and p3 (they are not contiguous). At last, we allocate a chunk of memory with 14 GB called p4 successfully. ```python #include <stdio.h> #include <cuda.h> #include <unistd.h> #define CHECK(e) {auto s = e; if (s != cudaSuccess) printf("CUDA error: %s", cudaGetErrorString(s));} #define GB(x) ((x) * 1024ull * 1024 * 1024) int main() { void *p1, *p2, *p3, *p4; CHECK(cudaMalloc(&p1, GB(7))); CHECK(cudaMalloc(&p2, GB(7))); CHECK(cudaMalloc(&p3, GB(7))); printf("first allocation done\n"); printf("p1=%p\n", p1); printf("p2=%p\n", p2); printf("p3=%p\n", p3); // sleep 5 seconds, we can check the memory usage in `nvidia-smi` during this time sleep(5); printf("free p1 and p3, allocate p4\n"); CHECK(cudaFree(p1)); CHECK(cudaFree(p3)); CHECK(cudaMalloc(&p4, GB(14))); printf("p4=%p\n", p4); printf("successfully allocated p4\n"); CHECK(cudaFree(p2)); CHECK(cudaFree(p4)); } ``` I can run above program on a RTX 3090 (24GB memory). ``` first allocation done p1=0x7f4a68000000 p2=0x7f48a8000000 p3=0x7f46e8000000 free p1 and p3, allocate p4 p4=0x7f4528000000 successfully allocated p4 ``` [1] https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY__POOLS.html

Questions

1. Whether the prior works have the fragmentation problem if they use the memory pool implemented in cuda? (See weaknesses part)

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

3 good

Contribution

2 fair

Limitations

The proposed method relied on that the underlying memory allocator is able to merge contiguous chunks.

Reviewer bdP26/10 · confidence 2/52023-07-03

Summary

This paper proposes an optimization framework called Coop to solve the severe memory fragmentation, which is overlooked by prior tensor rematerialization works. Coop designs a sliding window algorithm to determine evicted tensor, guaranteeing the freed memory is contiguous and available for a new tensor. Further, Coop adopts a cheap tensor partitioning method to rearrange the tensor in the memory layout based on the cost density, and a memory reuse mechanism, namely recomputable in-place, for the in-place operations. There two ideas are combined to reduce additional tensor rematerializaiton cost.

Strengths

1. This paper provides a framework to solve the bottleneck of the high memory fragment rate in the tensor rematerialization scheme. The proposed sliding algorithm, cheap tensor partition mechanism, and recomputable in-place method reduce the rematerialization cost and improve memory utilization. 2. The problem formulation and writing make the paper is easy to understand.

Weaknesses

1. It would be better to give an algorithm to describe the framework comprehensively.

Questions

1. From the figures in the evaluation part, the proposed Coop is not always optimal in search latency. Please analyze the underlying reasons. 2. Is the additional sliding window search algorithm needed after recomputable in-place and cheap tensor partitioning in Figure 1? If not, how can the evicted tensors be determined with minimum cost? It would be better to provide an algorithm description.

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

2: You are willing to defend your assessment, but it is quite likely that you did not understand the central parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

3 good

Contribution

2 fair

Limitations

1. Is there any trade-off for implementing the framework Coop?

Reviewer BV8L6/10 · confidence 3/52023-07-07

Summary

This paper considers the rematerialization problem for DNN training and studies it from the perspective of memory fragmentation.

Strengths

Please see the "Questions" section.

Weaknesses

Please see the "Questions" section.

Questions

- I think this paper is interesting in the sense that it raises and studies a problem that could affect the performance of other rematerialization algorithms in the literature. The problem of memory fragmentation is not taken into account in most of the DNN memory optimization papers in the literature. - The comparisons presented in the paper seem to be limited to heuristic based methods only. I think a comparison against the checkmate method ([11]) would make the results more interesting. The checkmate method is known to return the optimal solution since it's an exact method. However, it's also known that it doesn't scale to large-scale graphs. Perhaps numerical experiments for some small scale graphs could be still valuable since checkmate as a baseline would represent the optimal under the assumption that memory fragmentation is not an issue. This, in my opinion, would make the contributions of this paper clearer. - I haven't read the work of [21]. Given what the authors discuss about the DTE method, is this statement in line 64 true: "We argued for the first time that existing tensor rematerialization methods overlook the memory system during optimization and wrongly assume that the memory in DL systems is a fungible commodity"? Another statement similar to this is "To the best of our knowledge, Coop is the only tensor rematerialization scheme that fully bypasses the incorrect assumption of DL memory system." Minor - It is not immediately clear what is meant by "search latency" the first time it is mentioned in the text. It is explained later in the text, perhaps that explanation could be moved up to where it's mentioned first in the text. - This sentence in line 70 is hard to follow: "The properties of memory allocators in deep learning frameworks are considered to reduce the heuristic ..."

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

2 fair

Presentation

2 fair

Contribution

3 good

Limitations

Please see the "Questions" section.

Reviewer ks3C2023-08-10

Thanks the informative experiments on the memory pool provided by NVIDIA runtime/driver. I have no other questions. Good job!

Reviewer UBH82023-08-11

Thank you for the response

Thanks to the authors for their response, especially the attached tables and figures. Most of my concerns have been addressed. I have only one question regarding W2.1. > We divided the operations into two categories since we observed an obvious jump in the cost densities of the commonly used operations, as shown in Figure 1 of the attached pdf. > Coop does not make any assumptions about the structures of the neural network and can be universally implemented in any deep learning framework. The first statement is from the authors' response, and the second one is the last sentence of Section 5. I am aware that the field of MLSys focuses on both (1) general optimization without assumptions on model and hardware, and (2) oriented optimizations against a workload. The authors may define their contributions with a consistent claim. For most of the operators in NN, they can be simply classified into two categories by their complexity: linear or less (e.g., element-wise ops), larger than linear (matmul). I think this assumption makes sense and is widely adopted. Thank you for your great work.

Authorsrebuttal2023-08-11

Thanks for the constructive feedback

Thanks for the constructive feedback. We fully agree with the reviewer that most operators in neural networks can be classified into two categories by their complexities, i.e., linear/sub-linear and super-linear. This provides a theoretical basis for our experimental results (Figure 1 in the attached pdf). Therefore, Coop works under an implicit assumption that super-linear complexity translates to high cost density. Even though this assumption applies to most known neural networks, it is not theoretically guaranteed because of the constant terms. We will add the discussions about this assumption to Section 3.4 and update the statement that "Coop does not make any assumptions about the structures of the neural network" in Section 5 accordingly.

Reviewer UBH82023-08-12

Thanks for your great work

Thanks for your quick response. Given that the paper is solid and the implementations are submitted, I would like to raise my rating from 6 to 7.

Reviewer BV8L2023-08-15

Thanks for the responses to my questions. I still believe that the insights of this paper on the memory fragmentation aspect of rematerialization are important and therefore I maintain a positive opinion about the work.

Reviewer bdP22023-08-20

The comments addressed my concerns. Thank you very much!

Program Chairsdecision2023-09-21

Decision

Accept (spotlight)

© 2026 NYSGPT2525 LLC