TL;DR
This paper introduces BlendServe, a novel system for optimizing offline batch inference for Large Language Models (LLMs). BlendServe uniquely balances compute and memory resource utilization by intelligently batching requests with diverse demands, achieving significantly higher throughput than existing methods and approaching optimal performance.
What Problem Does This Paper Address?
Offline batch inference is becoming a popular and cost-effective way to run LLMs for tasks where strict latency isn't critical, like model evaluation or data processing. The main goal here is to maximize throughput – how many tokens the system can process per second. Existing systems often focus on optimizing within a single batch, but they struggle with the increasing diversity of LLM applications. These applications generate requests with vastly different resource needs: some are compute-heavy (like processing long inputs), while others are memory-heavy (like generating long outputs). When batches are filled with requests of similar resource demands, it leads to underutilization of either compute or memory resources, limiting overall throughput. This paper tackles the challenge of optimizing throughput by considering the resource demands across all requests and intelligently batching them to maximize resource overlap.
Methods
BlendServe's core innovation lies in its resource-aware prefix tree and a dual scanning algorithm.
- Resource-Aware Prefix Tree: Instead of a standard Trie for prefix sharing, BlendServe builds a prefix tree where each node stores information about the compute density of requests within its subtree. This allows the system to understand the resource demands of different request groups.
- Output Length Estimation: Since output length is unknown beforehand, BlendServe uses a sampling mechanism during a warm-up phase to estimate the output lengths of requests within sub-trees. This estimation is crucial for calculating compute density.
- Compute Density Metric: The paper defines "compute density" as the ratio of compute time to memory bandwidth usage for a request. This metric quantifies whether a request is compute-intensive or memory-intensive.
- Sorting and Splitting: The prefix tree nodes are sorted based on their compute density, aiming to place compute-intensive requests on one side and memory-intensive on the other. A "node splitting" technique is used to relocate outlier requests that don't fit the sorted pattern, balancing prefix sharing and resource overlap.
- Dual Scanning Algorithm: This algorithm scans the sorted prefix tree from both ends (compute-intensive and memory-intensive sides) concurrently. It dynamically partitions GPU memory and selects requests to form batches that maximize compute-memory overlap while preserving high prefix sharing.
Datasets
The paper uses a variety of open-source inference traces to synthesize workloads, including:
- Chatbot traces: WildChat, ShareGPT
- API service traces: Azure-Trace, BurstGPT
- Video generation datasets: OpenVid
- Benchmark traces: MMLU
- Math traces: LIMO
These traces are combined to create synthetic workloads with varying compute densities and prefix sharing ratios, reflecting diverse real-world scenarios.
Key Insights and Ideas
- The diversity of LLM applications creates requests with vastly different compute and memory demands. This heterogeneity is a major bottleneck for existing batching strategies.
- Optimizing solely for throughput within a batch is insufficient. The key to maximizing overall throughput is to strategically mix compute- and memory-intensive requests across batches.
- There's a fundamental trade-off between maximizing compute-memory overlap and maximizing prefix sharing. BlendServe's core contribution is harmonizing these two objectives.
- A resource-aware prefix tree is essential. It allows the system to capture both shared prefixes and the diverse resource demands of requests.
- Estimating output length is critical but challenging. BlendServe's sampling approach provides a practical solution that doesn't significantly impact performance.
Key Results
- BlendServe achieves up to 1.44x higher throughput compared to industry-standard systems like vLLM and SGLang.
- It outperforms NanoFlow (a state-of-the-art throughput-oriented system) by an average of 20.84%.
- BlendServe achieves an average of 86.55% (up to 90%) of the optimal throughput, demonstrating its effectiveness in balancing resource utilization and prefix sharing.
- The system maintains a high prefix sharing ratio (over 97% of maximal values), ensuring efficient reuse of computed prefixes.
- Evaluations on various models (Llama-3, Qwen-2.5) and hardware configurations show consistent performance improvements.
Limitations and Future Work
- Output length estimation variance: The paper notes that while BlendServe's sampling strategy works well for many workloads, it can be less effective for datasets with very large output length variance (e.g., ShareGPT, WildChat). Future work could explore better strategies for handling such cases.
- CPU overhead: While the paper focuses on GPU utilization, it acknowledges that CPU overhead for tasks like tokenization and scheduling exists. Further optimization in these areas could be explored.
- Real-world trace availability: The authors synthesized workloads due to the lack of publicly available offline inference traces, which might limit direct comparison with some real-world scenarios.
Summary updated