BlendServe: Optimizing Offline Inference for Auto-regressive Large Models with Resource-aware Batching

Yilong Zhao, Shuo Yang, Kan Zhu, Lianmin Zheng, Baris Kasikci, Yang Zhou, Jiarong Xing, Ion Stoica · OpenReview

TL;DR

This paper introduces BlendServe, a novel system for optimizing offline inference of large language models (LLMs). By intelligently batching requests with diverse compute and memory demands, BlendServe significantly boosts throughput, achieving up to 1.44x speedup over existing methods and nearing optimal performance.

What Problem Does This Paper Address?

Offline batch inference is gaining traction for cost-effective LLM processing in latency-insensitive applications. The core challenge lies in maximizing throughput, which requires high utilization of both compute and memory resources. However, modern LLM applications generate a wide variety of requests with vastly different resource needs (e.g., compute-intensive for text generation vs. memory-intensive for video processing). Naively batching these diverse requests leads to underutilization of hardware. Existing optimization techniques, like prefix sharing (which reuses computations for common prompt prefixes), can conflict with strategies for balancing compute and memory resource usage, leading to suboptimal overall throughput. BlendServe aims to harmonize these competing optimization goals.

Methods

BlendServe's core innovation is a resource-aware prefix tree that captures both shared prefixes among requests and their estimated compute/memory demands. This tree is then used to guide a dual scanning algorithm for request scheduling.

Here's a breakdown of the key techniques:

  • Performance Model: The authors develop a model to estimate the compute and memory resource demands of individual requests based on their input/output lengths and model parameters.
  • Resource-Aware Prefix Tree: This data structure extends traditional prefix trees (Tries) by incorporating compute density information at each node. This allows for a structured representation of request relationships and resource needs.
  • Output Length Estimation: Since output lengths are unknown during offline inference, BlendServe uses a sampling-based approach during a warm-up phase to estimate them, which is crucial for compute density calculation.
  • Dual Scanning Algorithm: This heuristic algorithm scans the resource-aware prefix tree from both ends (compute-intensive and memory-intensive requests) simultaneously. It dynamically partitions GPU memory and selects requests to form batches that balance resource utilization and maintain high prefix sharing.
  • Conditional Node Splitting: To handle outliers in compute density within the prefix tree, a technique is employed to relocate them, potentially incurring a small cost in prefix sharing for better resource balancing.

Datasets

The paper synthesizes workloads from several existing open-source inference traces to represent diverse LLM applications:

  • Chatbot Traces: WildChat, ShareGPT
  • API Service Traces: Azure-Trace, BurstGPT
  • Video Generation: OpenVid
  • Benchmark: MMLU
  • Math Traces: LIMO

These traces are combined in various ratios to create synthetic multi-modal workloads with different compute densities and prefix sharing ratios, allowing for comprehensive evaluation.

Key Insights and Ideas

  • Resource Diversity is Key: The paper highlights that the increasing diversity of LLM applications leads to requests with vastly different compute and memory demands, which is a significant untapped opportunity for throughput optimization in offline inference.
  • Conflicting Optimizations: A crucial insight is that maximizing compute-memory overlap and maximizing prefix sharing are often conflicting goals. BlendServe's novelty lies in its ability to find a sweet spot between these two.
  • Batching as a Balancing Act: The relaxed latency of offline inference allows for intelligent reordering of requests within batches. BlendServe leverages this by "blending" compute- and memory-intensive requests to keep both GPU compute and memory bandwidth busy.
  • Prefix Tree as a Unified Abstraction: The resource-aware prefix tree effectively combines structural information (shared prefixes) with performance characteristics (compute density), providing a powerful tool for scheduling.

Key Results

  • Throughput Improvement: BlendServe achieves up to 1.44x throughput speedup compared to widely-used frameworks like vLLM and SGLang.
  • Near-Optimal Performance: BlendServe reaches an average of 86.55% (up to 90%) of the achievable optimal throughput, demonstrating its effectiveness in balancing competing optimization goals.
  • Resource Utilization: The system consistently maintains high and balanced utilization of both compute and memory resources, as visualized in performance plots.
  • Prefix Sharing Preservation: BlendServe achieves 97% of the maximal prefix sharing ratio, ensuring that the benefits of prefix sharing are largely retained.
  • Generality: The approach shows consistent performance improvements across various LLM models (Llama-3, Qwen-2.5, Llama-2) and hardware configurations.

Limitations and Future Work

  • Output Length Estimation Variance: The paper notes that while the sampling strategy for output length estimation works well, large variances in output length within certain workloads (like ShareGPT and WildChat) can lead to slightly sub-optimal performance. The authors suggest this as a direction for future work.
  • Heuristic Nature: The dual scanning algorithm is a heuristic approach to an NP-hard problem. While effective, it doesn't guarantee absolute optimality.
  • CPU Overhead: While the paper focuses on GPU performance, it acknowledges that CPU overheads (tokenization, scheduling) exist but are generally considered negligible compared to GPU inference time. Further investigation into optimizing these could be beneficial.

Summary updated

BibTeX
@misc{zhao2024blendserve,
  author = {Yilong Zhao and Shuo Yang and Kan Zhu and Lianmin Zheng and Baris Kasikci and Yang Zhou and Jiarong Xing and Ion Stoica},
  title = {{BlendServe: Optimizing Offline Inference for Auto-regressive Large Models with Resource-aware Batching}},
  year = {2024},
  eprint = {2411.16102},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.16102},
}
Figure