TL;DR
PackInfer is a new kernel-level optimization framework that solves the "straggler" problem in batched LLM serving. By intelligently packing requests of different lengths into load-balanced execution groups and reorganizing memory layouts for better I/O, it boosts throughput by 20% and cuts latency by up to 20% compared to state-of-the-art methods like FlashAttention.
What Problem Does This Paper Address?
In the real world, LLM servers don't just handle one request at a time; they batch them together to maximize throughput. However, these requests are often "heterogeneous"—one user might ask a three-word question while another asks for a ten-page summary.
Current attention kernels (like FlashAttention) are designed for uniform workloads. When forced to handle a batch of mixed lengths, they typically use padding to make every request look as long as the longest one. This is incredibly wasteful: GPUs end up performing "ghost" computations on empty space, and certain hardware units (Streaming Multiprocessors or SMs) finish early and sit idle while waiting for one or two long requests to finish. This "straggler effect" leads to poor hardware utilization and high tail latency.
Methods
PackInfer introduces a two-pronged strategy to fix this imbalance at the kernel level:
- Packed Computation: Instead of treating each request as a separate entity, PackInfer partitions and packs them into "execution groups." Short requests are bundled together to fill up a single kernel launch, while very long requests are split across multiple groups. A lightweight greedy algorithm (Algorithm 1) ensures these groups have nearly identical total token counts, synchronizing their completion times and keeping the GPU fully occupied.
- Packed I/O: Memory access is often the bottleneck in LLM decoding. PackInfer reorganizes the Key-Value (KV) cache into a "prefix-first" contiguous layout. This allows multiple requests sharing the same system prompt to fetch that data once rather than multiple times. It also uses a "proactive allocation" strategy, reserving a bit of extra space (headroom) for future tokens so that the system doesn't have to reshuffle memory every single time a new word is generated.
- Adaptive Regrouping: As an LLM generates text, the lengths of requests change. PackInfer monitors this "drift" and selectively triggers a regrouping of requests only when the imbalance becomes severe enough to outweigh the cost of the reorganization.
Datasets
The authors evaluated PackInfer using three diverse, real-world request traces:
- Alpaca: General instruction-following tasks.
- LMSYS: Realistic, multi-turn ChatGPT-style workloads.
- Text2SQL: Query generation tasks.
These were tested across several models, including Qwen3-4B, Mistral-7B, and a Mixture-of-Experts (MoE) model, Qwen3-30B-A3B.
Key Insights and Ideas
- The "Aha" Moment on Padding: The paper points out that more than 60% of real-world requests are shorter than the standard 128-token tile size used by many kernels. This means a huge portion of GPU cycles is literally spent calculating zeros.
- Joint Optimization: Most prior work tries to fix either computation or memory access. PackInfer’s "aha" is that these must be solved together. If you balance the computation but leave the memory fragmented, the "pointer chasing" required to find KV blocks will still slow you down.
- Heuristics over Perfection: Finding the mathematically "perfect" way to pack requests is an NP-hard problem (the bin-packing problem). PackInfer uses a fast greedy heuristic that runs in milliseconds, making it practical for real-time serving where every millisecond counts.
Key Results
Compared to the industry-standard FlashAttention:
- Throughput: Increased by 9.3% to 24.9% across different workloads.
- Latency: Time-between-tokens (TBT) was reduced by 13.0% to 20.1%.
- TTFT: Time-to-first-token improved by up to 18.6%.
- Hardware Efficiency: Tensor Core utilization jumped from 18% to 33%, and SM instruction throughput increased from 17% to 25%.
- Scalability: The benefits persisted across different hardware (A100, H200, A40) and scaled gracefully in multi-GPU distributed settings.
Limitations and Future Work
While PackInfer shows impressive gains, there are a few areas for further exploration:
- Regrouping Overhead: Although the paper mentions the regrouping cost is amortized, in extremely high-pressure, low-latency environments, even a small pause for regrouping might be felt.
- Integration Complexity: While the authors state it only requires a few lines of API changes, deep integration into complex, custom serving stacks might require more engineering effort than a standard drop-in library.
- Future Work: The authors suggest that their packing logic could be extended to other parts of the LLM pipeline beyond just the attention layer, potentially leading to a fully "packed" end-to-end inference engine.
Summary updated