NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Out of the Memory Barrier: A Highly Memory-Efficient Training System for LLMs with Million-Token Contexts

Wenhao Li, Daohai Yu, Gen Luo, Yuxin Zhang, Yifan Wu, Jiaxin Liu, Ziyang Gong, Zimu Liao, Fei Chao, Rongrong Ji

TL;DR

OOMB (Out Of the Memory Barrier) is a novel training system that enables Large Language Models (LLMs) to handle million-token contexts on a single GPU. By combining chunk-recurrent training with asynchronous CPU offloading and paged memory management, it reduces activation memory to a constant footprint, allowing a 7B model to train on 4 million tokens with just 10MB of additional memory per 10K tokens.

The "Memory Wall" in Long-Context Training

The primary obstacle to training LLMs on long sequences is the "memory wall." As context length increases, the memory required for activations (intermediate values stored during the forward pass) and the KV cache (keys and values used in attention) grows linearly.

Standard techniques like FlashAttention help mitigate this, but they do not alter the fundamental linear scaling. For a 256K context, the KV cache alone can consume 64GB of VRAM, exhausting an A100 GPU before even accounting for model weights. Currently, training on millions of tokens requires massive GPU clusters using "context parallelism," which is prohibitively expensive and inaccessible for most researchers.

The OOMB Approach

To address this, the authors introduce OOMB, which shifts the training paradigm from fully parallel to a hybrid "chunk-recurrent" approach. Its architecture relies on several synergistic optimizations:

OOMB System Architecture and Performance
  1. Chunk-Wise Training with Recomputation: Instead of processing the entire sequence simultaneously, OOMB breaks it into manageable chunks. It computes activations for a chunk, discards them to save space, and recomputes them on-the-fly during the backward pass. This strategy keeps activation memory at a constant $\mathcal{O}(1)$ footprint, regardless of the total sequence length.
  2. Paged KV Cache & Gradient Management: Inspired by inference engines like vLLM, OOMB utilizes a paged memory manager for both the KV cache and its gradients. This eliminates memory fragmentation and the need for expensive tensor concatenations.
  3. Specialized Triton Kernels: Custom kernels bypass PyTorch’s standard autograd system to perform in-place gradient accumulation. This reduces memory I/O and prevents the KV cache from being stored as a bulky activation.
  4. Asynchronous CPU Offloading: Because the KV cache still grows with context length, OOMB preemptively moves it to CPU memory. Utilizing dedicated CUDA streams, data transfer occurs in the background concurrently with GPU computation, effectively hiding the transfer latency.
  5. Page-Level Sparse Attention: To maintain manageable computation at extreme lengths, OOMB employs a Top-K retrieval method to attend only to the most relevant "pages" of the history, rather than computing attention over every single token.

Key Insights and Results

The system was evaluated using the Qwen2.5-7B model on ultra-long sequences (up to 8 million tokens) sourced from the arXiv dataset.

  • The Bottleneck Shift: By resolving the activation memory problem, OOMB successfully shifts the primary bottleneck to the KV cache, which is more easily managed via offloading and paging.
  • Extreme Scalability: OOMB successfully trained Qwen2.5-7B with a 4-million-token context on a single H200 GPU.
  • Minimal Memory Growth: For every additional 10K tokens of context, the total memory overhead increased by a mere 10MB.
  • Significant Speedups: On a 256K context, OOMB’s sparse attention implementation provided a 13.5× speedup compared to dense training baselines. Furthermore, OOMB outperformed Ring Flash Attention (a state-of-the-art parallel method) in per-device throughput, demonstrating that serial chunk-wise processing can be more efficient than complex inter-GPU communication.
  • Democratizing Long Context: The most significant implication is that million-token training no longer strictly requires a massive GPU cluster. With intelligent memory management, a single high-end GPU can perform tasks that previously required a data center.

Limitations and Future Work

While highly memory-efficient, the chunk-wise serial processing introduces a latency overhead compared to a hypothetical fully parallel training run. Additionally, the use of sparse attention is an approximation of full attention; while preliminary validation is promising, further research is needed to assess its impact on tasks requiring extremely dense global context. The effectiveness of asynchronous offloading also heavily depends on CPU-GPU interconnect bandwidth (e.g., PCIe vs. NVLink). Future work will explore more optimal sparse attention strategies and investigate the impact of this training style on downstream reasoning tasks.

Summary updated

BibTeX
@inproceedings{li2026out,
  author = {Wenhao Li and Daohai Yu and Gen Luo and Yuxin Zhang and Yifan Wu and Jiaxin Liu and Ziyang Gong and Zimu Liao and Fei Chao and Rongrong Ji},
  title = {{Out of the Memory Barrier: A Highly Memory-Efficient Training System for LLMs with Million-Token Contexts}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=dSa3ImCQr7},
}
Figure