mlsanityData to 14 Oct 2026

A Little Goes a Long Way: Efficient Long Context Training and Inference with Partial Contexts

arXiv 2410.01485 ↗First posted 2 Oct 2024cs.CLcited by 9

On the map: Efficient LLM inference and serving → KV cache optimization

Abstract (arXiv)

Training and serving long-context large language models (LLMs) incurs substantial overhead. To address this, two critical steps are often required: a pretrained LLM typically undergoes a separate stage for context length extension by training on long-context data, followed by architectural modifications to reduce the overhead of KV cache during serving. This paper argues that integrating length extension with a GPU-friendly KV cache reduction architecture not only reduces training overhead during length extension, but also achieves better long-context performance. This leads to our proposed LongGen, which finetunes a pretrained LLM into an efficient architecture during length extension. LongGen builds on three key insights: (1) Sparse attention patterns, such as window attention (attending to recent tokens), attention sink (initial ones), and blockwise sparse attention (strided token blocks) are well-suited for building efficient long-context models, primarily due to their GPU-friendly memory access patterns, enabling efficiency gains not just theoretically but in practice as well. (2) It is essential for the model to have direct access to all tokens. A hybrid architecture with 1/3 full attention layers and 2/3 efficient ones achieves a balanced trade-off between efficiency and long-context performance. (3) Lightweight training on 5B long-context data is sufficient to extend the hybrid model's context length from 4K to 128K. We evaluate LongGen on both Llama-2 7B and Llama-2 70B, demonstrating its effectiveness across different scales. During training with 128K-long contexts, LongGen achieves 1.55x training speedup and reduces wall-clock time by 36%, compared to a full-attention baseline. During inference, LongGen reduces KV cache memory by 62%, achieving 1.67x prefilling speedup and 1.41x decoding speedup.

Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Placed in KV cache optimization, one of 12 directions in Efficient LLM inference and serving. Builds on 45 of its 48 references that are in the map. First posted on arXiv 2 Oct 2024.

Builds on

45 of 48 references.

Closest ancestors · 7

Same direction, newest first

  1. 2024RazorAttention: Efficient KV Cache Compression Through Retrieval Heads22 Jul
  2. 2024PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling4 Jun
  3. 2024SnapKV: LLM Knows What You are Looking for Before Generation22 Apr
  4. 2023Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs3 Oct
  5. 2023Efficient Memory Management for Large Language Model Serving with PagedAttention12 Sep
  6. 2023H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models24 Jun
  7. 2023Scissorhands: Exploiting the Persistence of Importance Hypothesis for LLM KV Cache Compression at Test Time26 May

Other references · 38

  1. 2024The Llama 3 Herd of Modelscited by 14,715
  2. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
  3. 2020Measuring Massive Multitask Language Understandingcited by 7,963
  4. 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,371
  5. 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,718
  6. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
  7. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
  8. 2020Longformer: The Long-Document Transformercited by 3,413
  9. 2023Qwen Technical Reportcited by 3,344
  10. 2023Mistral 7Bcited by 3,164
  11. 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
  12. 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
26 more
  1. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
  2. 2020Big Bird: Transformers for Longer Sequencescited by 1,684
  3. 2019Generating Long Sequences with Sparse Transformerscited by 1,546
  4. 2024RULER: What's the Real Context Size of Your Long-Context Language Models?cited by 1,346
  5. 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,336
  6. 2020Efficient Transformers: A Surveycited by 790
  7. 2021Combining Recurrent, Convolutional, and Continuous-time Models with Linear State-Space Layerscited by 608
  8. 2020HiPPO: Recurrent Memory with Optimal Polynomial Projectionscited by 605
  9. 2024MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attentioncited by 383
  10. 2023Effective Long-Context Scaling of Foundation Modelscited by 303
  11. 2024Retrieval Head Mechanistically Explains Long-Context Factualitycited by 232
  12. 2024BABILong: Testing the Limits of LLMs with Long Context Reasoning-in-a-Haystackcited by 215
  13. 2024Simple linear attention language models balance the recall-throughput tradeoffcited by 208
  14. 2024Data Engineering for Scaling Language Models to 128K Contextcited by 186
  15. 2022Mega: Moving Average Equipped Gated Attentioncited by 179
  16. 2024Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modelingcited by 174
  17. 2019Blockwise Self-Attention for Long Document Understandingcited by 159
  18. 2024You Only Cache Once: Decoder-Decoder Architectures for Language Modelscited by 144
  19. 2024Zamba: A Compact 7B SSM Hybrid Modelcited by 124
  20. 2024Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Taskscited by 105
  21. 2023Towards Efficient Generative Large Language Model Serving: A Survey from Algorithms to Systemscited by 102
  22. 2023SlimPajama-DC: Understanding Data Combinations for LLM Trainingcited by 72
  23. 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrievalcited by 64
  24. 2022Efficient Long Sequence Modeling via State Space Augmented Transformercited by 37
  25. 2024Resonance RoPE: Improving Context Length Generalization of Large Language Modelscited by 27
  26. 2023Sparse Modular Activation for Efficient Sequence Modelingcited by 20

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 3; 2025: 4; 2026: 2.

9 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025InfiniteHiP: Extending Language Model Context Up to 3 Million Tokens on a Single GPU
  2. 2025From 128K to 4M: Efficient Training of Ultra-Long Context Large Language Models
  3. 2026Out of the Memory Barrier: A Highly Memory Efficient Training System for LLMs with Million-Token Contexts
  4. 2025RetroInfer: A Vector Storage Engine for Scalable Long-Context LLM Inference
  5. 2025HGCA: Hybrid GPU-CPU Attention for Long Context LLM Inference
  6. 2025Breaking the Boundaries of Long-Context LLM Inference: Adaptive KV Management on a Single Commodity GPU
  7. 2024Discovering the Gems in Early Layers: Accelerating Long-Context LLMs with 1000x Input Token Reduction
  8. 2024DuoAttention: Efficient Long-Context LLM Inference with Retrieval and Streaming Heads