RelayAttention for Efficient Large Language Model Serving with Long System Prompts
Not on the map. Why?
Abstract (arXiv)
A practical large language model (LLM) service may involve a long system prompt, which specifies the instructions, examples, and knowledge documents of the task and is reused across requests. However, the long system prompt causes throughput/latency bottlenecks as the cost of generating the next token grows w.r.t. the sequence length. This paper aims to improve the efficiency of LLM services that involve long system prompts. Our key observation is that handling these system prompts requires heavily redundant memory accesses in existing causal attention computation algorithms. Specifically, for batched requests, the cached hidden states (ie, key-value pairs) of system prompts are transferred from off-chip DRAM to on-chip SRAM multiple times, each corresponding to an individual request. To eliminate such a redundancy, we propose RelayAttention, an attention algorithm that allows reading these hidden states from DRAM exactly once for a batch of input tokens. RelayAttention is a free lunch: it maintains the generation quality while requiring no model retraining, as it is based on a mathematical reformulation of causal attention. We have observed significant performance improvements to a production-level system, vLLM, through integration with RelayAttention. The improvements are even more profound with longer system prompts.
Key facts. Cited by 13 papers in the map (data through 7 Oct 2026). Builds on 20 of its 38 references that are in the map. First posted on arXiv 22 Feb 2024.
Builds on
20 of 38 references.
References · 20
- 2017Attention Is All You Needcited by 59,932
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,616
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,878
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
- 2014Sequence to Sequence Learning with Neural Networkscited by 2,974
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,551
- 2022GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformerscited by 1,838
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,615
8 more
- 2023Accelerating Large Language Model Decoding with Speculative Samplingcited by 975
- 2024DeepSeek LLM: Scaling Open-Source Language Models with Longtermismcited by 621
- 2020Med-BERT: pre-trained contextualized embeddings on large-scale structured electronic health records for disease predictioncited by 368
- 2023Prompt Cache: Modular Attention Reuse for Low-Latency Inferencecited by 255
- 2018Online normalizer calculation for softmaxcited by 154
- 2021Self-attention Does Not Need O(n2) Memorycited by 152
- 2020Language Models Are An Effective Patient Representation Learning Technique For Electronic Health Record Datacited by 85
- 2023Large Language Models as Tax Attorneys: A Case Study in Legal Capabilities Emergencecited by 42
Built on by
Citing papers per year: 2024: 3; 2025: 8; 2026: 2.
13 papers.
Sort:
By area:
- 2025FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Servingcited by 248
- 2025Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruningcited by 48
- 2024Queue management for slo-oriented large language model servingcited by 36
- 2024BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batchingcited by 31
- 2024DeFT: Decoding with Flash Tree-attention for Efficient Tree-structured LLM Inferencecited by 19
- 2025Position is Power: System Prompts as a Mechanism of Bias in Large Language Models (LLMs)cited by 19
- 2025Accurate KV Cache Quantization with Outlier Tokens Tracingcited by 15
- 2025PAT: Accelerating LLM Decoding via Prefix-Aware Attention with Resource Efficient Multi-Tile Kernelcited by 5
- 2025xGR: Efficient Generative Recommendation Serving at Scalecited by 2
- 2025CaliDrop: KV Cache Compression with Calibrationcited by 1
- 2026Enabling KV Caching of Shared Prefix for Diffusion Language Modelscited by 1
- 2025TyphoonMLA: A Mixed Naive-Absorb MLA Kernel For Shared Prefixcited by 0
1 more
- 2026Crossflow: Prefill-Decode Elasticity for Agentic LLM Serving22 Sep 2026
- 2026Enabling KV Caching of Shared Prefix for Diffusion Language Models26 May 2026
- 2025xGR: Efficient Generative Recommendation Serving at Scale12 Dec 2025
- 2025PAT: Accelerating LLM Decoding via Prefix-Aware Attention with Resource Efficient Multi-Tile Kernel27 Nov 2025
- 2025TyphoonMLA: A Mixed Naive-Absorb MLA Kernel For Shared Prefix25 Sep 2025
- 2025CaliDrop: KV Cache Compression with Calibration26 Jul 2025
- 2025Position is Power: System Prompts as a Mechanism of Bias in Large Language Models (LLMs)27 May 2025
- 2025Accurate KV Cache Quantization with Outlier Tokens Tracing16 May 2025
- 2025Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruning4 Feb 2025
- 2025FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving2 Jan 2025
- 2024BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batching29 Nov 2024
- 2024Queue management for slo-oriented large language model serving5 Jun 2024
1 more
- 2025FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Servingcited by 248
- 2024Queue management for slo-oriented large language model servingcited by 36
- 2024DeFT: Decoding with Flash Tree-attention for Efficient Tree-structured LLM Inferencecited by 19
- 2025Accurate KV Cache Quantization with Outlier Tokens Tracingcited by 15
- 2025PAT: Accelerating LLM Decoding via Prefix-Aware Attention with Resource Efficient Multi-Tile Kernelcited by 5
- 2025xGR: Efficient Generative Recommendation Serving at Scalecited by 2
- 2025CaliDrop: KV Cache Compression with Calibrationcited by 1
- 2025xGR: Efficient Generative Recommendation Serving at Scale12 Dec 2025
- 2025PAT: Accelerating LLM Decoding via Prefix-Aware Attention with Resource Efficient Multi-Tile Kernel27 Nov 2025
- 2025CaliDrop: KV Cache Compression with Calibration26 Jul 2025
- 2025Accurate KV Cache Quantization with Outlier Tokens Tracing16 May 2025
- 2025FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving2 Jan 2025
- 2024Queue management for slo-oriented large language model serving5 Jun 2024
- 2024DeFT: Decoding with Flash Tree-attention for Efficient Tree-structured LLM Inference30 Mar 2024
- 2026Crossflow: Prefill-Decode Elasticity for Agentic LLM Serving22 Sep 2026
- 2025Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruningcited by 48
- 2024BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batchingcited by 31
- 2025Position is Power: System Prompts as a Mechanism of Bias in Large Language Models (LLMs)cited by 19
- 2025TyphoonMLA: A Mixed Naive-Absorb MLA Kernel For Shared Prefixcited by 0
- 2025TyphoonMLA: A Mixed Naive-Absorb MLA Kernel For Shared Prefix25 Sep 2025
- 2025Position is Power: System Prompts as a Mechanism of Bias in Large Language Models (LLMs)27 May 2025
- 2025Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruning4 Feb 2025
- 2024BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batching29 Nov 2024