AlayaDB: The Data Foundation for Efficient and Effective Long-context LLM Inference

Yangshen Deng, Zhengxin You, Long Xiang, Qilong Li, Peiqi Yuan, Zhaoyang Hong, Yitao Zheng, Wanting Li, Runzhong Li, Haotian Liu, Kyriakos Mouratidis, Man Lung Yiu, Huan Li, Qiaomu Shen, Rui Mao, Bo Tang

Introduction

As Large Language Models (LLMs) evolve to process millions of tokens, the computational and memory demands of the KV cache—which stores keys and values of previous tokens—have become a critical bottleneck. AlayaDB is a specialized vector database designed to serve as the "data foundation" for long-context LLM inference. By decoupling the KV cache and attention computation from the model engine and introducing a novel Dynamic Inner Product Range (DIPR) query, it achieves superior generation quality and lower latency while significantly reducing GPU memory overhead.

The Bottleneck of Long-Context Inference

Current solutions for handling the linear growth of the KV cache generally fall into three categories, each with significant drawbacks:

  1. Coupled Architectures: Keeping all data on the GPU ensures high quality but consumes excessive memory and suffers from high Time-To-First-Token (TTFT).
  2. KV Cache Disaggregation: Offloading the cache to CPU or disk saves memory but introduces high latency due to constant data shuffling.
  3. Sparse Attention (Top-k): Retrieving a fixed number of "important" tokens ($k$) fails to account for the varying information needs of different layers and tasks, often degrading performance.
Comparison of LLM inference architectures, contrasting traditional coupled and disaggregated approaches with AlayaDB's integrated sparse attention and retrieval model.

AlayaDB addresses this by treating LLM attention as a database query problem, aiming to meet latency Service Level Objectives (SLOs) while maintaining high generation quality.

Methodology: Attention as a Service

AlayaDB moves the attention calculation into the database, a paradigm shift toward data-centric computation. Its architecture consists of three primary layers:

  • User Interface (DB & Session APIs): Instead of raw KV vectors, the LLM engine sends a query vector and receives the final result of the attention computation, drastically reducing data transfer overhead.
  • Query Processing Engine: This layer utilizes a Rule-based Query Optimizer to select execution plans. Central to this is the Dynamic Inner Product Range (DIPR) query. Unlike static Top-k search, DIPR adaptively retrieves all tokens within a specific range of the maximum inner product, allowing the system to scale the amount of information retrieved based on task complexity.
  • Vector Storage Engine: Built on the Storage Performance Development Kit (SPDK), it bypasses the traditional kernel for high-speed disk I/O and uses a custom buffer manager to keep critical index blocks in memory.
Standard LLM inference procedure and the self-attention mechanism involving Query (Q), Key (K), and Value (V) matrices, which AlayaDB optimizes by offloading to a specialized storage engine.

Evaluation and Key Insights

The researchers evaluated AlayaDB using the $\infty$-Bench (Infinite-Bench) with the Llama-3-8B-Instruct-262k model. The benchmark covers retrieval, code debugging, summarization, and mathematical tasks with context lengths up to 192.6K tokens.

Key insights from the study include:

  • Dynamic Sparsity: The number of "critical" tokens varies wildly across attention heads (from 50 to over 40,000), making static retrieval methods inefficient.
  • Index Sharing: For models using Grouped Query Attention (GQA), AlayaDB shares a single "RoarGraph" index across multiple query heads, accelerating index construction by up to 62x compared to CPU-based methods.

Results

AlayaDB demonstrates significant improvements across all key performance metrics:

  • Superior Quality: On $\infty$-Bench, AlayaDB achieved an average quality score of 47.0, outperforming "Full Attention" (45.6) and significantly beating Top-100 (45.3) and StreamingLLM (16.9).
  • Massive Speedups: In context reuse scenarios, AlayaDB's TTFT was 19x to 42x faster than LMCache.
  • Resource Efficiency: The system achieved the highest generation quality with the lowest GPU memory consumption among tested sparse attention methods, consistently meeting strict latency SLOs (token generation $\le 0.24s$).

Conclusion and Future Work

AlayaDB establishes a new standard for long-context inference by treating the KV cache as a managed database resource. Future work will focus on implementing complex parallelism strategies for distributed inference, integrating with engines like vLLM and SGLang, and exploring hierarchical storage (RAM, NVMe, Cloud) to support even larger contexts.

Summary updated

BibTeX
@inproceedings{deng2025alayadb,
  author = {Yangshen Deng and Zhengxin You and Long Xiang and Qilong Li and Peiqi Yuan and Zhaoyang Hong and Yitao Zheng and Wanting Li and Runzhong Li and Haotian Liu and Kyriakos Mouratidis and Man Lung Yiu and Huan Li and Qiaomu Shen and Rui Mao and Bo Tang},
  title = {{AlayaDB: The Data Foundation for Efficient and Effective Long-context LLM Inference}},
  booktitle = {SIGMOD Conference Companion},
  year = {2025},
  doi = {10.1145/3722212.3724428},
}
Figure