Using Span Queries to Optimize for Cache and Attention Locality
On the map: LLM reasoning → Test-time compute and efficient thinking
also in 1 more
Abstract (arXiv)
Clients are evolving beyond chat completion, and now include a variety of innovative inference-time scaling and deep reasoning techniques. At the same time, inference servers remain heavily optimized for chat completion. Prior work has shown that large improvements to KV cache hit rate are possible if inference servers evolve towards these non-chat use cases. However, they offer solutions that are also optimized for a single use case, RAG. In this paper, we introduce the span query to generalize the interface to the inference server. We demonstrate that chat, RAG, inference-time scaling, and agentic workloads can all be expressed as span queries. We show how the critical distinction that had been assumed by prior work lies in whether the order of the inputs matter -- do they commute? In chat, they do not. In RAG, they often do. This paper introduces span queries, which are expression trees of inference calls, linked together with commutativity constraints. We describe span query syntax and semantics. We show how they can be automatically optimized to improve KV cache locality. We show how a small change to vLLM (affecting only 492 lines) can enable high-performance execution of span queries. Using this stack, we demonstrate that span queries can achieve 10-20x reductions in TTFT for two distinct non-chat use cases. Finally, we show that span queries can also be optimized to improve attention locality, so as to avoid the so-called lost-in-the-middle problem. We demonstrate that an attention-optimized span query on a 2b parameter model vastly outperforms the accuracy of a stock inference server using an 8b model.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in Test-time compute and efficient thinking, one of 17 directions in LLM reasoning. Builds on 13 of its 20 references that are in the map. First posted on arXiv 4 Nov 2025.
Builds on
13 of 20 references.
Closest ancestors · 1
Same direction, newest first
Other references · 12
- 2017Attention Is All You Needcited by 59,932
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
- 2020Constructing A Multi-hop QA Dataset for Comprehensive Evaluation of Reasoning Stepscited by 1,259
- 2023SGLang: Efficient Execution of Structured Language Model Programscited by 1,107
- 2023Graph of Thoughts: Solving Elaborate Problems with Large Language Modelscited by 873
- 2024CacheBlend: Fast Large Language Model Serving for RAG with Cached Knowledge Fusioncited by 211
- 2025Evaluating Judges as Evaluators: The JETTS Benchmark of LLM-as-Judges as Test-Time Scaling Evaluatorscited by 42
- 2024Block-Attention for Efficient Prefillingcited by 34
- 2025Efficient Attention Mechanisms for Large Language Models: A Surveycited by 21
- 2024Networks of Networks: Complexity Class Principles Applied to Compound AI Systems Designcited by 13
Built on by
Citing papers per year: 2026: 1.
1 paper.
- 2026MiniPIC: Flexible Position-Independent Caching in <100LOC11 Jun 2026
Similar, not cited
Close in wording, no citation either way
- 2024Quest: Query-Aware Sparsity for Efficient Long-Context LLM Inference
- 2026Persistent Memory in Multi-Agent LLM Inference: What It Costs, What It Buys, and When You Can Tell
- 2024SCBench: A KV Cache-Centric Analysis of Long-Context Methods
- 2024InstCache: A Predictive Cache for LLM Serving
- 2026GrowPage: On-Demand KV Budgeting for Efficient LLM Reasoning Serving
- 2025Latency and Token-Aware Test-Time Compute
- 2025A*-Decoding: Token-Efficient Inference Scaling
- 2026Asynchronous Verified Semantic Caching for Tiered LLM Architectures