mlsanityData to 7 Oct 2026

Prepacking: A Simple Method for Fast Prefilling and Increased Throughput in Large Language Models

arXiv 2404.09529 ↗First posted 15 Apr 2024cs.LG cs.AI cs.CLcited by 10

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

  1. 2017Attention Is All You Needcited by 59,932
  2. 2023GPT-4 Technical Reportcited by 18,132
  3. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  4. 2020Measuring Massive Multitask Language Understandingcited by 7,768
  5. 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
  6. 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,634
  7. 2023Mistral 7Bcited by 3,065
  8. 2016Pointer Sentinel Mixture Modelscited by 2,992
  9. 2022Fast Inference from Transformers via Speculative Decodingcited by 1,615
  10. 2022SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Modelscited by 1,338
  11. 2024Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Headscited by 821
  12. 2020Aligning AI With Shared Human Valuescited by 706
13 more
  1. 2024DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Servingcited by 595
  2. 2023FlexGen: High-Throughput Generative Inference of Large Language Models with a Single GPUcited by 567
  3. 2019SAMSum Corpus: A Human-annotated Dialogue Dataset for Abstractive Summarizationcited by 530
  4. 2024Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Servecited by 507
  5. 2021Intriguing Properties of Vision Transformerscited by 446
  6. 2023Sheared LLaMA: Accelerating Language Model Pre-training via Structured Pruningcited by 408
  7. 2022DeepSpeed Inference: Enabling Efficient Inference of Transformer Models at Unprecedented Scalecited by 403
  8. 2023Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Timecited by 247
  9. 2023GPTs are GPTs: An Early Look at the Labor Market Impact Potential of Large Language Modelscited by 174
  10. 2023Towards Efficient Generative Large Language Model Serving: A Survey from Algorithms to Systemscited by 101
  11. 2023Response Length Perception and Sequence Scheduling: An LLM-Empowered LLM Inference Pipelinecited by 86
  12. 2024Analysing The Impact of Sequence Composition on Language Model Pre-Trainingcited by 22
  13. 2021The CoRa Tensor Compiler: Compilation for Ragged Tensors with Minimal Paddingcited by 17

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 1; 2025: 7; 2026: 2.

10 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024CORM: Cache Optimization with Recent Message for Large Language Model Inference
  2. 2024A Method for Building Large Language Models with Predefined KV Cache Capacity
  3. 2026Prefilling-dLLM: Predictive Prefilling for Long-Context Inference in Diffusion Language Models
  4. 2024Layer-Condensed KV Cache for Efficient Inference of Large Language Models
  5. 2026Decode-Branch Transformers: Decoupling the Primary Prefill Path from Additional Decode Computation
  6. 2024An Efficient Inference Framework for Early-exit Large Language Models
  7. 2026POP: Prefill-Only Pruning for Efficient Large Model Inference
  8. 2025PromptDistill: Query-based Selective Token Retention in Intermediate Layers for Efficient Large Language Model Inference