Efficient and Economic Large Language Model Inference with Attention Offloading

Shaoyuan Chen, Yutong Lin, Mingxing Zhang, Yongwei WuarXiv 2024 · DOI

Abstract

Large Language Model (LLM) decoding is often inefficient due to the mismatch between compute-heavy linear layers and memory-bound attention operations. This paper presents Lamina, a system that disaggregates these tasks across heterogeneous hardware pools. By offloading memory-intensive KV caches to cheaper, memory-optimized devices while keeping compute-heavy tasks on high-end accelerators, Lamina achieves up to 90.1% higher throughput within the same cost budget.

The Inefficiency of LLM Decoding

In Large Language Model (LLM) serving, the "decoding" phase—generating text one token at a time—is notoriously inefficient. This stems from a fundamental mismatch between software requirements and hardware capabilities. Modern GPUs like the NVIDIA H100 are designed as "all-rounders," providing massive compute power (TFLOPS) alongside high-bandwidth memory (HBM).

However, decoding alternates between two distinct operations:

  1. Linear Transformations: Compute-bound tasks that benefit from high TFLOPS and large batch sizes.
  2. Attention Operators: Memory-bound tasks that require reading a massive "KV cache" (previous token memory) for every new token.

Because the KV cache is so large, it quickly consumes GPU memory, forcing systems to use small batch sizes. This leaves expensive compute units idle (often below 20% utilization). Conversely, optimizing for memory often sacrifices the compute power needed for linear layers.

Lamina: Model-Attention Disaggregation

The authors propose Model-Attention Disaggregation, implemented in the Lamina system. Instead of a single GPU handling the entire workload, Lamina splits the tasks across specialized hardware pools.

The Lamina architecture disaggregates prefill/decode and model/attention tasks across heterogeneous GPU pools.

System Components

  • Heterogeneous Pools: "Model Workers" (e.g., H100s) handle compute-heavy linear layers, while "Attention Workers" (e.g., cheaper, memory-optimized NVIDIA H20 or TPU v6e) store KV caches and perform attention math.
  • Fully Host-Bypassed Network (FHBN): To overcome the "communication wall" of disaggregation, Lamina uses a custom stack allowing GPUs to communicate directly with Network Interface Cards (NICs) via PCIe P2P, reducing round-trip latency by 50%.
  • Automated Model Converter: This tool uses symbolic execution to find the "minimum weighted cut" in a model's computation graph, automatically slicing it for distribution.
  • Rotational Staggered Pipelining: Lamina runs multiple batches concurrently. While one batch undergoes computation on a Model Worker, another performs attention on an Attention Worker, ensuring high device utilization.

Evaluation and Key Results

Lamina was evaluated using popular open-source models (LLaMA-33B, 65B, and LLaMA3-70B) and production request traces from Microsoft Azure and Kimi services.

  • Throughput Gains: Compared to vLLM, Lamina achieved 16.1% to 90.1% higher throughput for the same hardware budget.
  • Batch Size Increase: Lamina enabled an average of 2.39x larger batch sizes by offloading the KV cache from compute-optimized GPUs.
  • Network Efficiency: The FHBN stack achieved a round-trip time of just 33.0 µs, a 50.5% reduction compared to standard NCCL.

Specialization and Hardware Economics

The core insight of Lamina is leveraging hardware cost disparities. For example, an NVIDIA H20 offers significant memory bandwidth at a lower price point than an H100, despite having less compute power. By pairing these devices, the system achieves a superior balance of performance and cost.

Comparison of memory bandwidth utilization (MBU) and execution time across different batch sizes for H100 and H20 GPUs.

While disaggregation introduces minor networking latency per token, the massive gains in throughput far outweigh the millisecond-level increase in individual response times for most web-scale applications.

Limitations and Future Work

Lamina's rotational pipelining requires migrating batch execution contexts, which increases in complexity with more concurrent batches. Additionally, while it meets typical Service Level Objectives (SLOs), it may not be suitable for ultra-low-latency applications where cost is secondary. Future work may explore Processing-in-Memory (PIM) devices as even more efficient "Attention Workers" due to their high bandwidth-to-cost ratios.

Summary updated

BibTeX
@misc{chen2024efficient,
  author = {Shaoyuan Chen and Yutong Lin and Mingxing Zhang and Yongwei Wu},
  title = {{Efficient and Economic Large Language Model Inference with Attention Offloading}},
  year = {2024},
  eprint = {2405.01814},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.01814},
}
Figure