As Large Language Models (LLMs) scale to process massive context windows of 128K tokens and beyond, they increasingly hit a "memory wall." During the decoding phase—where the model generates text one token at a time—it must store and access a Key-Value (KV) cache of all previous tokens. This cache grows linearly with sequence length, quickly becoming a massive bottleneck for both memory capacity and compute latency.
Existing "sparse attention" solutions attempt to mitigate this by only attending to a subset of the KV cache. However, they suffer from two primary limitations. First is selection overhead: identifying which tokens are "important" can sometimes be as computationally expensive as performing full attention. Second is layer independence: most methods treat each Transformer layer as an isolated unit, recalculating token importance from scratch at every step and ignoring the fact that consecutive layers often focus on the same information.
To address these inefficiencies, researchers have introduced TidalDecode, a novel algorithm and system that speeds up LLM decoding by exploiting "spatial coherence"—the tendency for different layers in a Transformer to attend to the same tokens. By selecting important tokens only at a few key layers and reusing those selections across others, TidalDecode achieves up to a 2.1× speedup over full attention while maintaining, or even improving, generative accuracy.
Position Persistent Sparse Attention (PPSA)
The core innovation behind TidalDecode is Position Persistent Sparse Attention (PPSA). The underlying premise is straightforward: if Layer 2 determines that a specific token is highly relevant, Layer 3 is very likely to share that assessment.
To operationalize this, TidalDecode categorizes Transformer layers into three distinct types:
- Full Attention Layers: The first few layers perform standard dense attention to ensure a strong, comprehensive initial representation of the context.
- Token Selection Layers: At specific intervals (e.g., at the beginning and in the middle of the model), the system performs full attention to identify the top-$k$ tokens with the highest attention scores. These indices are then stored in a "token buffer."
- Sparse Attention Layers: All subsequent layers skip the expensive selection process entirely. They simply load the KV pairs for the tokens stored in the buffer and perform attention exclusively on them.
To prevent "pollution"—a scenario where sparse updates cause the KV cache representations to drift away from the true distribution over time—the authors also propose a Cache Correction mechanism. This periodically "refills" the cache by re-running full attention on generated tokens, keeping the representations accurate over long generation steps.
Key Insights: The Power of Spatial Coherence
A major contribution of this work is quantifying the correlation of attention scores between layers. The authors found that while adjacent layers are highly correlated, distant layers are less so.
This spatial coherence explains why a single token selection at the start of the network isn't enough. As representations evolve deeper in the network, the set of "important" tokens shifts. Adding a second selection layer in the middle of the model (for example, Layer 13 for Llama-3) dramatically boosts accuracy by refreshing the token buffer at the exact point where correlation with the initial layers begins to degrade.
Furthermore, because TidalDecode reuses exact attention scores across many layers, the computational "cost" of being precise is amortized. This allows TidalDecode to use exact selection at its key layers, leading to better accuracy than approximate methods (like Quest) that rely on heuristics. Interestingly, TidalDecode occasionally outperformed full attention on the LongBench dataset. The authors hypothesize that by forcing the model to attend only to the most relevant tokens, the sparse mechanism acts as a noise filter, preventing the model from getting distracted by irrelevant parts of a long prompt.
Evaluation and Results
The researchers evaluated TidalDecode across several challenging benchmarks, including Needle-in-the-Haystack (retrieval in up to 100K tokens), PG-19 (perplexity), and LongBench (long-document QA, summarization). Testing was performed on the Llama-2 (7B), Llama-3 (8B/70B), and Llama-3.1 (8B) model families.
- Significant Speedups: TidalDecode reduced end-to-end inference latency by up to 2.1× compared to state-of-the-art full attention implementations (FlashInfer) and 1.2× compared to Quest.
- High Fidelity: On the 100K-context "Needle-in-the-Haystack" test, TidalDecode achieved 100% accuracy using a budget of only 128 tokens—a tiny fraction of the total context.
- Efficiency: The system achieves these gains while maintaining a very high level of sparsity (often >99%), which is crucial for scaling to even longer sequences in the future.
Limitations and Future Work
While highly effective, TidalDecode currently requires some model-specific tuning. The "optimal" layer for token re-selection varies by model family (e.g., Layer 7 for Llama-2 vs. Layer 13 for Llama-3), requiring per-model profiling. Additionally, the current implementation uses a fixed token budget ($k$). Future iterations could explore adaptive budgets that dynamically adjust based on the complexity of the prompt or the specific decoding step. Finally, while the Cache Correction mechanism is theoretically sound, its real-world impact on latency when running concurrently remains an area for further engineering optimization.
Summary updated