MEMO: Fine-grained Tensor Management For Ultra-long Context LLM Training
Not on the map. Why?
Abstract (arXiv)
Nowadays, Large Language Models (LLMs) have been trained using extended context lengths to foster more creative applications. However, long context training poses great challenges considering the constraint of GPU memory. It not only leads to substantial activation memory consumption during training, but also incurs considerable memory fragmentation. To facilitate long context training, existing frameworks have adopted strategies such as recomputation and various forms of parallelisms. Nevertheless, these techniques rely on redundant computation or extensive communication, resulting in low Model FLOPS Utilization (MFU). In this paper, we propose MEMO, a novel LLM training framework designed for fine-grained activation memory management. Given the quadratic scaling of computation and linear scaling of memory with sequence lengths when using FlashAttention, we offload memory-consuming activations to CPU memory after each layer's forward pass and fetch them during the backward pass. To maximize the swapping of activations without hindering computation, and to avoid exhausting limited CPU memory, we implement a token-wise activation recomputation and swapping mechanism. Furthermore, we tackle the memory fragmentation issue by employing a bi-level Mixed Integer Programming (MIP) approach, optimizing memory reuse across transformer layers. Empirical results demonstrate that MEMO achieves an average of 1.97x and 1.80x MFU compared to Megatron-LM and DeepSpeed, respectively. This improvement is attributed to MEMO's ability to minimize memory fragmentation, reduce recomputation and intensive communication, and circumvent the delays associated with the memory reorganization process due to fragmentation. By leveraging fine-grained activation memory management, MEMO facilitates efficient training of 7B LLM with 1 million sequence length on just 8 A800 GPUs, achieving an MFU of 52.30%.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 52 of its 104 references that are in the map. First posted on arXiv 16 Jul 2024.
Builds on
52 of 104 references.
References · 52
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2023GPT-4 Technical Reportcited by 18,396
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2017Billion-scale similarity search with GPUscited by 2,497
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
- 2019Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelismcited by 1,868
- 2020Big Bird: Transformers for Longer Sequencescited by 1,684
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,474
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
38 more
- 2017Mixed Precision Trainingcited by 1,156
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2016Training Deep Nets with Sublinear Memory Costcited by 848
- 2023PyTorch FSDP: Experiences on Scaling Fully Sharded Data Parallelcited by 660
- 2021Nystr"omformer: A Nystr"om-Based Algorithm for Approximating Self-Attentioncited by 471
- 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 457
- 2024Retrieval-Augmented Generation for AI-Generated Content: A Surveycited by 354
- 2021ZeRO-Offload: Democratizing Billion-Scale Model Trainingcited by 341
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
- 2022Reducing Activation Recomputation in Large Transformer Modelscited by 302
- 2023DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Modelscited by 245
- 2019A Study of BFLOAT16 for Deep Learning Trainingcited by 232
- 2024World Model on Million-Length Video And Language With Blockwise RingAttentioncited by 198
- 2024Data Engineering for Scaling Language Models to 128K Contextcited by 186
- 2020Memory-Efficient Pipeline-Parallel DNN Trainingcited by 134
- 2023Scaling Laws of RoPE-based Extrapolationcited by 125
- 2022Clinical-Longformer and Clinical-BigBird: Transformers for long clinical sequencescited by 69
- 2024USP: A Unified Sequence Parallelism Approach for Long Context Generative AIcited by 61
- 2022Galvatron: Efficient Transformer Training over Multiple GPUs Using Automatic Parallelismcited by 53
- 2020Dynamic Tensor Rematerializationcited by 46
- 2021tf.data: A Machine Learning Data Processing Frameworkcited by 41
- 2020Analyzing and Mitigating Data Stalls in DNN Trainingcited by 36
- 2021HET: Scaling out Huge Embedding Model Training via Cache-enabled Distributed Frameworkcited by 28
- 2021Survey: Transformer based Video-Language Pre-trainingcited by 27
- 2022MiCS: Near-linear Scaling for Training Gigantic Model on Public Cloudcited by 22
- 2020A Tensor Compiler for Unified Machine Learning Prediction Servingcited by 20
- 2024GMLake: Efficient and Transparent GPU Memory Defragmentation for Large-scale DNN Training with Virtual Memory Stitchingcited by 15
- 2023Improving Automatic Parallel Training via Balanced Memory Workload Optimizationcited by 14
- 2017Learning Models over Relational Data using Sparse Tensors and Functional Dependenciescited by 12
- 2023Experimental Analysis of Large-scale Learnable Vector Storage Compressioncited by 12
- 2020Tensor Relational Algebra for Machine Learning System Designcited by 11
- 2022Where Is My Training Bottleneck? Hidden Trade-Offs in Deep Learning Preprocessing Pipelinescited by 10
- 2022Optimizing Tensor Programs on Flexible Storagecited by 9
- 2023CAFE: Towards Compact, Adaptive, and Fast Embedding for Large-scale Recommendation Modelscited by 7
- 2018Profile-guided memory optimization for deep neural networkscited by 6
- 2021TOD: GPU-accelerated Outlier Detection via Tensor Operationscited by 6
- 2022OLLA: Optimizing the Lifetime and Location of Arrays to Reduce the Memory Usage of Neural Networkscited by 6
- 2024NeurDB: An AI-powered Autonomous Data Systemcited by 5
50 most cited of 52 All 52 (JSON)
Built on by
Citing papers per year: 2024: 2; 2025: 2; 2026: 1.
5 papers.
- 2024Training Ultra Long Context Language Model with Fully Pipelined Distributed Transformercited by 6
- 2025Apt-Serve: Adaptive Request Scheduling on Hybrid Cache for Scalable LLM Inference Servingcited by 6
- 2024Hydraulis: Balancing Large Transformer Model Training via Co-designing Parallel Strategies and Data Assignmentcited by 3
- 2025Futureproof Static Memory Planningcited by 0
- 2026Efficient Training on Multiple Consumer GPUs with RoundPipecited by 0
- 2026Efficient Training on Multiple Consumer GPUs with RoundPipe29 Apr 2026
- 2025Apt-Serve: Adaptive Request Scheduling on Hybrid Cache for Scalable LLM Inference Serving10 Apr 2025
- 2025Futureproof Static Memory Planning7 Apr 2025
- 2024Hydraulis: Balancing Large Transformer Model Training via Co-designing Parallel Strategies and Data Assignment10 Dec 2024
- 2024Training Ultra Long Context Language Model with Fully Pipelined Distributed Transformer30 Aug 2024