Star Attention: Efficient LLM Inference over Long Sequences

Shantanu Acharya, Fei Jia, Boris Ginsburg · OpenReview

Abstract

Inference with Transformer-based Large Language Models (LLMs) on long sequences is both costly and slow due to the quadratic complexity of the self-attention mechanism. We introduce Star Attention, a two-phase block-sparse approximation that improves computational efficiency by sharding attention across multiple hosts while minimizing communication overhead. In the first phase, the context is processed using blockwise-local attention across hosts, in parallel. In the second phase, query and response tokens attend to all prior cached tokens through sequence-global attention. Star Attention integrates seamlessly with most Transformer-based LLMs trained with global attention, reducing memory requirements and inference time by up to 11x while preserving 97-100% of accuracy.

Introduction

The context window of LLMs has expanded significantly, with modern models supporting millions of tokens. This enables transformative use cases such as analyzing entire code repositories or summarizing extensive document sets. However, the underlying Transformer architecture faces a "quadratic bottleneck": doubling the input length quadruples the computational and memory cost of self-attention.

Existing solutions generally fall into two categories, both with significant drawbacks. Distributed attention methods, like Ring Attention, spread the workload across GPUs but require constant, heavy communication during inference, leading to latency. Sparse attention methods reduce computation by limiting the attention scope but often require expensive retraining or suffer from substantial accuracy degradation. Furthermore, LLMs exhibit "attention sinks," where they rely heavily on the initial tokens of a sequence for stability. Breaking text into independent chunks disrupts this pattern, causing model logic to fail.

Methods

Star Attention is a two-phase distributed inference algorithm designed to minimize communication while preserving natural attention patterns.

Overview of Star Attention's two-phase distributed inference process, showing context encoding with anchor blocks and query encoding with global softmax.

Phase 1: Context Encoding (The Anchor Block)

The long context is divided into blocks and distributed across multiple hosts. To maintain model stability, each host receives a copy of the first block—the Anchor Block. By prefixing every local chunk with this anchor, the model preserves its attention sink, allowing for parallel local attention computation without inter-host communication.

Phase 2: Query Encoding and Token Generation

During the generation phase, the query is broadcast to all hosts. Each host computes local attention against its cached tokens. A designated "query host" then gathers summarized results (scalars and vectors) to compute a global softmax. This enables the model to maintain a global view of the context during generation without moving massive Key-Value (KV) caches between GPUs.

Key Insights

A critical discovery of this work is that the semantic content of the first block is more vital than its absolute position. Without the anchor block, the model creates "spurious" attention sinks at the start of every chunk, leading to total performance failure. Including the anchor block effectively "tricks" the model into a near-perfect approximation of global attention.

Visualization of the attention sink phenomenon, where the model places high attention scores on the initial tokens of a sequence.

By avoiding the communication-heavy "ring" patterns during encoding, Star Attention scales linearly with the number of hosts. It is particularly effective for retrieval and aggregation tasks, where local summaries are synthesized efficiently in the query phase.

Evaluation and Results

The researchers evaluated Star Attention using rigorous long-context benchmarks, including RULER, BABILong, and InfiniteBench, testing on Llama-3.1-8B and 70B models.

  • Performance Gains: Star Attention achieved up to an 11x speedup for Llama-3.1-70B at 64K context compared to Ring Attention. At 1 million tokens, the speedup reached 16.9x.
  • High Fidelity: Across most benchmarks, the method preserved 97–100% of the accuracy of full global attention.
  • Competitive Advantage: It significantly outperformed other sparse methods like StreamingLLM and MInference, especially as sequence lengths increased.

Conclusion

While Star Attention excels in retrieval and summarization, it faces limitations in Multi-Hop Tracing, where logic depends on specific tokens in distant, previous blocks. Because token-to-token communication is restricted during the initial encoding phase, performance dips in these complex reasoning scenarios. Future work will focus on refining the anchor block mechanism and developing enhanced cross-block communication strategies to close the gap in multi-hop reasoning performance.

Summary updated

BibTeX
@inproceedings{acharya2025star,
  author = {Shantanu Acharya and Fei Jia and Boris Ginsburg},
  title = {{Star Attention: Efficient LLM Inference over Long Sequences}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=QY7Au9nZwp},
}
Figure