atlas

Research map / Architectures and efficiency / Attention and transformers

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

ICLR 2025 · Architectures and efficiency › Attention and transformers · approach: Sparse attention for long-context LLMs · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes LongGen, which finetunes a pretrained Llama-2 into a hybrid model with 1/3 full attention layers (middle) and 2/3 GPU-friendly sparse attention layers (attention sink or block sparse) during context extension from 4K to 128K.

Problem

Long-context LLMs are expensive to train (context extension) and serve (KV cache memory), and post-hoc inference-time KV cache eviction methods underperform on long-context retrieval and reasoning.

Approach

Integrate context-length extension with a GPU-friendly KV-reduced hybrid architecture: sparse attention (attention sink or block sparse with static, block-wise access) in top and bottom layers and full attention in the middle layers, trained with a custom FlashAttention-2-based Triton kernel and served with vLLM.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use the LongGen hybrid architecture with 1/3 full-attention layersLlama2-7B · NIAHaccuracy: 100% -> 100%No clear effect
Use the LongGen hybrid architecture with 1/3 full-attention layersLlama2-7B · BABILongaverage accuracy: 0.29 -> 0.27Hurt
Use the LongGen hybrid architecture with 1/3 full-attention layersLlama2-7B · RULERaverage accuracy: 0.41 -> 0.38Hurt
Use the LongGen hybrid architecture with 1/3 full-attention layersLlama2-70B · BABILongaverage accuracy: 0.46 -> 0.46No clear effect
Use the LongGen hybrid architecture with 1/3 full-attention layersLlama2-70B · RULERaverage accuracy: 0.67 -> 0.65Hurt
Train with LongGen's sparse attention architectureLlama2-7B · 128K trainingwall-clock training speedup: 1.55xHelped
Use LongGen's partial-context architectureLlama2-7B · 128K inferenceKV cache memory: 69.2 GB -> 26.5 GB; 62% reductionHelped
Use LongGen's partial-context architectureLlama2-7B · 128K inferenceprefilling speedup: 1.67xHelped
Use LongGen's partial-context architectureLlama2-7B · 128K inferencedecoding speedup: 1.41xHelped
Use LongGen w/ AttnSink instead of inference-time KV evictionLlama2-7B · NIAHpass rate: 51% -> 100%Helped
Use LongGen w/ BlockSparse instead of inference-time KV evictionLlama2-7B · NIAHpass rate: 51% -> 100%Helped
Place the full-attention layers in the middle rather than the top, bottom, or interleaved positions (ablation)LongGen w/ AttnSink · BABILongaccuracyHelped

Surprising findings

Limitations

Experimental setup

Datasets: SlimPajama

Benchmarks: Needle-in-a-Haystack BABILong RULER MMLU GSM8K BBH

Metrics: pass rate accuracy wall-clock speedup KV cache memory prefilling speedup decoding speedup

Baselines: Attention Sink H2O RazorAttention PyramidKV Sliding Window YOCO Full Attention

Builds on: FlashAttention-2 attention sink (StreamingLLM) Mistral sliding window attention YOCO vLLM

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy