Abstract
Large Language Models (LLMs) face significant computational and memory challenges as context lengths scale to 128K tokens and beyond. TCA-Attention is a training-free, sparse attention mechanism that addresses the "quadratic wall" of self-attention. By combining a one-time offline calibration with an online, context-aware token selection process, it accelerates both prefilling and decoding stages while reducing KV cache memory usage by up to 61%. Evaluation on benchmarks like LongBench-E and RULER demonstrates a 2.8× speedup on 128K context lengths without requiring model retraining or architectural modifications.
The Quadratic Wall in Long-Context Modeling
As LLMs process increasingly massive contexts, the self-attention mechanism's computational cost grows quadratically ($O(L^2)$) with sequence length. Simultaneously, the memory required for Key-Value (KV) caches grows linearly, often exhausting GPU VRAM. Existing solutions frequently rely on static sparsity patterns that fail to adapt to content or require expensive fine-tuning. TCA-Attention argues that identifying and retaining only "core" tokens dynamically is the key to efficient long-context modeling.
TCA-Attention: A Two-Phase Approach
TCA-Attention operates in two lightweight phases to achieve high-performance sparse attention:
1. Offline Calibration (Head-Specific Sparsity)
Attention heads in LLMs are intrinsically diverse; some focus on local context, while others act as global "sinks." TCA-Attention performs a single forward pass on a small calibration dataset to determine a specific "sparsity budget" for each individual head. This respects the model's architecture by not applying a "one-size-fits-all" mask.
2. Online Token Selection (Context-Adaptive)
During inference, the model dynamically selects tokens from two subsets:
- Local Subset: Preserves the most recent $w$ tokens to capture immediate context.
- Global Subset: Selects "core" tokens from the distant past using a lightweight block-level redundancy metric.
Key Insights: Exploiting Head Diversity
A critical finding of this work is that attention patterns vary wildly across different heads and layers. These patterns can be categorized into four main types: Uniform, Bipolar, Terminal Bias, and Attention Sinks. TCA-Attention’s head-specific budgets are designed to accommodate these diverse behaviors, ensuring that critical information is not lost during sparsification.
Experimental Results
The authors evaluated TCA-Attention against several SOTA baselines, including MInference, FlexPrefill, and XAttention, across various long-context tasks.
| Methods | Average Score | Latency (ms) |
|---|---|---|
| LLaMA3.1-8B-Instruct | 53.19 | 316.14 |
| • MInference | 53.06 | 324.84 |
| • FlexPrefill | 53.23 | 280.11 |
| • XAttention | 50.91 | 133.85 |
| • TCA-Attention (Ours) | 53.51 | 120.96 |
| Qwen2.5-7B-Instruct | 51.16 | 268.55 |
| • MInference | 51.18 | 292.33 |
| • FlexPrefill | 51.41 | 244.37 |
| • XAttention | 50.66 | 119.87 |
| • TCA-Attention (Ours) | 51.51 | 105.93 |
Key performance highlights include:
- Speedup: Achieved a 2.8× speedup in prefilling latency at 128K context length compared to vanilla FlashAttention-2.
- Memory Savings: Reduced KV cache memory footprint by 61% (e.g., from 8.00GB to 3.12GB on LLaMA-3.1-8B).
- Performance Parity: Maintained or exceeded the accuracy of full-attention models while being significantly faster than competitors.
Conclusion
TCA-Attention provides a robust, training-free solution for scaling LLMs to long contexts. By leveraging head-specific sparsity and context-adaptive token selection, it breaks the quadratic wall of attention without sacrificing model performance. Its plug-and-play nature makes it an ideal candidate for immediate deployment in high-performance inference systems.
Summary updated