QuoKA: Query-Oriented KV Selection for Efficient LLM Prefill

Dalton Jones, Junyoung Park, Matthew J Morse, Mingu Lee, Matthew Harper Langston, Christopher Lott

TL;DR

QuoKA is a training-free, hardware-agnostic algorithm that slashes Large Language Model (LLM) prefill latency by intelligently subselecting the most important parts of the Key-Value (KV) cache. By identifying "outlier" queries that deviate from the average, QuoKA can approximate full attention with 88% fewer KV pairs, delivering up to a 7x speedup on CPUs and 5x on GPUs without sacrificing accuracy.

The Bottleneck: Long Prompts and Chunked Prefill

When you send a long prompt to an LLM, the model first performs a "prefill" stage, processing the entire input to initialize its memory (the KV cache). This stage is computationally expensive because the standard attention mechanism has quadratic complexity—as the prompt gets longer, the computational workload grows exponentially.

While "chunked prefill" (breaking the prompt into smaller blocks) helps manage memory limits, the underlying math remains heavy. Existing "sparse attention" methods attempt to skip unnecessary calculations, but they often fall into two traps: they either require custom, non-portable hardware kernels (like specific CUDA code for NVIDIA GPUs), or they are designed strictly for the token-by-token "generation" phase, performing poorly when processing many prompt tokens simultaneously. QuoKA aims to provide a portable, high-performance solution specifically optimized for this prefill bottleneck.

Methods: The QuoKA Pipeline

QuoKA (Query-oriented KV selection) operates on a clever geometric observation about how LLMs distribute attention. It follows a three-stage pipeline to filter down the KV cache before computing full attention:

Overview of the QuoKA pipeline during chunked prefill, detailing query selection and cosine similarity scoring.
  1. Query Subselection: Instead of using every query in a chunk to decide which keys are important, QuoKA identifies a small set of "representative" queries. It ranks queries based on their cosine similarity to the mean query of the chunk and keeps the "outliers"—those with the lowest similarity.
  2. Cosine-Similarity Scoring: Rather than using standard dot products (which can be unstable and scale-dependent), QuoKA uses cosine similarity to score the relationship between these representative queries and the keys in the cache. This provides a bounded, more reliable proxy for attention weights.
  3. Score Aggregation: To select the final keys to keep, QuoKA takes the maximum score across the selected queries (ensuring rare but important interactions aren't averaged out) and the mean score across grouped-query attention (GQA) heads.

Because QuoKA relies entirely on standard linear algebra operations, it bypasses the need for specialized kernels. This allows it to run efficiently on almost any hardware, from high-end GPUs to standard Intel CPUs.

Key Insights and Ideas

The foundation of QuoKA rests on understanding the distribution of attention in modern LLMs.

Attention matrix visualization highlighting the concentrated, sparse nature of query-key interactions.
  • The "Boring" Mean Query: The researchers discovered that most queries in a chunk are very similar to the average query and tend to focus on the exact same small set of keys. The queries that look different from the average are actually the most informative for determining which parts of the KV cache are essential. Prioritizing these low-similarity queries closely approximates the behavior of full attention.
  • Pre-aggregation Efficiency: By averaging queries across KV groups before computing similarity, QuoKA significantly reduces the number of operations. This "pre-aggregation" makes the algorithm's complexity scale with the number of KV heads rather than the (much larger) number of attention heads.
  • Portability is Key: Unlike many recent sparse attention papers that live and die by custom CUDA kernels, QuoKA’s reliance on standard math makes it a "plug-and-play" solution. This is especially valuable for edge devices and consumer-grade hardware where custom kernel support is often missing.

Performance and Results

The authors evaluated QuoKA across a diverse range of models (Llama 3, Qwen, SmolLM) and rigorous benchmarks, including Needle-In-A-Haystack (NIAH), LongBench, RULER, and Math500. The results demonstrate significant efficiency gains:

  • Massive Speedups: QuoKA achieved a 5x speedup in attention kernels on NVIDIA A100 GPUs and nearly a 7x speedup on Intel Xeon CPUs.
  • Lower Latency: It reduced the Time-To-First-Token (TTFT)—the delay before the model starts generating text—by 3x on 50k-token prompts.
  • High Sparsity, Low Loss: The model maintained near-baseline accuracy while using 88% fewer KV pairs per attention evaluation. On the LongBench suite, QuoKA outperformed other state-of-the-art sparse methods (like SparQ or Loki) by 10–20% at similar budget levels.
  • Robustness: The method proved stable across different model architectures (MoE, NoPE, RoPE) and varying chunk sizes.

Limitations and Future Work

While QuoKA is highly effective at selecting which KVs to use for a specific chunk during prefill, it does not currently address KV eviction—the process of permanently deleting low-importance tokens to save memory over very long, continuous conversations. The authors note that combining QuoKA with established eviction policies is a promising next step.

Additionally, while the scoring mechanism is fast, future work could explore even more efficient ways to compute the query-key similarity. Potential avenues include exploiting channel-level sparsity or using learned low-dimensional projections to further reduce computational overhead.

Summary updated

BibTeX
@inproceedings{jones2026quoka,
  author = {Dalton Jones and Junyoung Park and Matthew J Morse and Mingu Lee and Matthew Harper Langston and Christopher Lott},
  title = {{QuoKA: Query-Oriented KV Selection for Efficient LLM Prefill}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=YS4N1YxXSM},
}
Figure