Prepacking: A Simple Method for Fast Prefilling and Increased Throughput in Large Language Models
Not on the map. Why?
Abstract (arXiv)
During inference for transformer-based large language models (LLM), prefilling is the computation of the key-value (KV) cache for input tokens in the prompt prior to autoregressive generation. For longer input prompt lengths, prefilling will incur a significant overhead on decoding time. In this work, we highlight the following pitfall of prefilling: for batches containing high-varying prompt lengths, significant computation is wasted by the standard practice of padding sequences to the maximum length. As LLMs increasingly support longer context lengths, potentially up to 10 million tokens, variations in prompt lengths within a batch become more pronounced. To address this, we propose Prepacking, a simple yet effective method to optimize prefilling computation. To avoid redundant computation on pad tokens, prepacking combines prompts of varying lengths into a sequence and packs multiple sequences into a compact batch using a bin-packing algorithm. It then modifies the attention mask and positional encoding to compute multiple prefilled KV-caches for multiple prompts within a single sequence. On standard curated dataset containing prompts with varying lengths, we obtain a significant speed and memory efficiency improvements as compared to the default padding-based prefilling computation within Huggingface across a range of base model configurations and inference serving scenarios.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). Builds on 25 of its 35 references that are in the map. First posted on arXiv 15 Apr 2024.
Builds on
25 of 35 references.
References · 25
- 2017Attention Is All You Needcited by 59,932
- 2023GPT-4 Technical Reportcited by 18,132
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,634
- 2023Mistral 7Bcited by 3,065
- 2016Pointer Sentinel Mixture Modelscited by 2,992
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,615
- 2022SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Modelscited by 1,338
- 2024Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Headscited by 821
- 2020Aligning AI With Shared Human Valuescited by 706
13 more
- 2024DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Servingcited by 595
- 2023FlexGen: High-Throughput Generative Inference of Large Language Models with a Single GPUcited by 567
- 2019SAMSum Corpus: A Human-annotated Dialogue Dataset for Abstractive Summarizationcited by 530
- 2024Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Servecited by 507
- 2021Intriguing Properties of Vision Transformerscited by 446
- 2023Sheared LLaMA: Accelerating Language Model Pre-training via Structured Pruningcited by 408
- 2022DeepSpeed Inference: Enabling Efficient Inference of Transformer Models at Unprecedented Scalecited by 403
- 2023Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Timecited by 247
- 2023GPTs are GPTs: An Early Look at the Labor Market Impact Potential of Large Language Modelscited by 174
- 2023Towards Efficient Generative Large Language Model Serving: A Survey from Algorithms to Systemscited by 101
- 2023Response Length Perception and Sequence Scheduling: An LLM-Empowered LLM Inference Pipelinecited by 86
- 2024Analysing The Impact of Sequence Composition on Language Model Pre-Trainingcited by 22
- 2021The CoRa Tensor Compiler: Compilation for Ragged Tensors with Minimal Paddingcited by 17
Built on by
Citing papers per year: 2024: 1; 2025: 7; 2026: 2.
10 papers.
- 2024A Declarative System for Optimizing AI Workloadscited by 35
- 2025KVCOMM: Online Cross-context KV-cache Communication for Efficient LLM-based Multi-agent Systemscited by 35
- 2025Prefill-level Jailbreak: A Black-Box Risk Analysis of Large Language Modelscited by 9
- 2025SwiftSpec: Ultra-Low Latency LLM Decoding by Scaling Asynchronous Speculative Decodingcited by 9
- 2025Enabling Autoregressive Models to Fill In Masked Tokenscited by 7
- 2026Thousand-GPU Large-Scale Training and Optimization Recipe for AI-Native Cloud Embodied Intelligence Infrastructurecited by 3
- 2025OverFill: Two-Stage Models for Efficient Language Model Decodingcited by 2
- 2025AccLLM: Accelerating Long-Context LLM Inference Via Algorithm-Hardware Co-Designcited by 1
- 2025AI Compute Architecture and Evolution Trendscited by 1
- 2026PackInfer: Compute- and I/O-Efficient Attention for Batched LLM Inferencecited by 1
- 2026Thousand-GPU Large-Scale Training and Optimization Recipe for AI-Native Cloud Embodied Intelligence Infrastructure11 Mar 2026
- 2026PackInfer: Compute- and I/O-Efficient Attention for Batched LLM Inference3 Feb 2026
- 2025KVCOMM: Online Cross-context KV-cache Communication for Efficient LLM-based Multi-agent Systems14 Oct 2025
- 2025AI Compute Architecture and Evolution Trends29 Aug 2025
- 2025OverFill: Two-Stage Models for Efficient Language Model Decoding11 Aug 2025
- 2025SwiftSpec: Ultra-Low Latency LLM Decoding by Scaling Asynchronous Speculative Decoding12 Jun 2025
- 2025Prefill-level Jailbreak: A Black-Box Risk Analysis of Large Language Models28 Apr 2025
- 2025AccLLM: Accelerating Long-Context LLM Inference Via Algorithm-Hardware Co-Design7 Apr 2025
- 2025Enabling Autoregressive Models to Fill In Masked Tokens9 Feb 2025
- 2024A Declarative System for Optimizing AI Workloads23 May 2024
Similar, not cited
Close in wording, no citation either way
- 2024CORM: Cache Optimization with Recent Message for Large Language Model Inference
- 2024A Method for Building Large Language Models with Predefined KV Cache Capacity
- 2026Prefilling-dLLM: Predictive Prefilling for Long-Context Inference in Diffusion Language Models
- 2024Layer-Condensed KV Cache for Efficient Inference of Large Language Models
- 2026Decode-Branch Transformers: Decoupling the Primary Prefill Path from Additional Decode Computation
- 2024An Efficient Inference Framework for Early-exit Large Language Models
- 2026POP: Prefill-Only Pruning for Efficient Large Model Inference
- 2025PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inference