TL;DR
This paper introduces "layered prefill," a novel scheduling technique for serving large language models (LLMs), particularly Mixture-of-Experts (MoE) models. By treating model layers as scheduling units instead of tokens, layered prefill significantly reduces latency, energy consumption, and improves throughput compared to existing methods, especially for long-context workloads.
What Problem Does This Paper Address?
Serving large language models (LLMs) efficiently in production is a critical challenge. The primary goals are to minimize time-to-first-token (TTFT) and time-between-tokens (TBT) while maximizing throughput, all within fixed hardware constraints. LLM inference involves two stages: prefill (processing the entire input prompt) and decode (generating tokens one by one). Prefill is typically compute-bound, while decode is memory-bound.
Modern LLM serving systems use techniques like "chunked prefill" to handle long prompts by splitting them into smaller chunks and interleaving their processing with decoding. This helps stabilize TBT. However, for MoE models, chunked prefill leads to significant inefficiencies: redundant loading of expert weights across chunks increases memory traffic and energy consumption. This paper addresses this specific bottleneck in MoE serving, aiming to improve efficiency without sacrificing stall-free decoding.
Methods
The core contribution is layered prefill, a new scheduling paradigm that shifts the scheduling axis from tokens to transformer layers. Instead of processing input chunks along the token dimension, the model is vertically partitioned into contiguous layer groups.
The key idea is a one-group-per-iteration rule: in each iteration, only one designated layer group handles both prefill (for newly admitted requests) and decode, while all other layer groups perform decode only. This ensures that prefill progresses group by group across iterations, completing the prefill of a request in a number of iterations equal to the number of layer groups ($N_{ig}$). This approach guarantees stall-free decoding and, crucially, ensures that each layer group is traversed only once during prefill, eliminating the redundant expert weight reloads inherent in chunked prefill.
The authors also discuss how layered prefill can be combined with chunked prefill for very long sequences, leveraging the benefits of both.
Datasets
The paper evaluates its approach using two datasets:
- ShareGPT: This dataset consists of multi-turn conversations and exhibits a wide range of input lengths, from hundreds to over 10,000 tokens.
- arXiv Summarization: This dataset is used for summarization tasks and features significantly longer input prompts, with an average input length approximately forty times the output length.
Key Insights and Ideas
- Layers as Scheduling Units: The fundamental insight is that for MoE models, aligning scheduling with model architecture (layers) rather than input processing (tokens) can unlock significant efficiency gains.
- Eliminating Redundant MoE Reloads: Layered prefill directly tackles the costly redundant loading of MoE expert weights that plagues chunked prefill, especially for long contexts.
- Sparsity Erosion: Chunked prefill can inadvertently "erode" the sparsity benefits of MoE models by forcing many experts to be loaded even if only a few are activated per token, leading to memory-bound bottlenecks. Layered prefill mitigates this.
- TTFT-TBT Pareto Frontier: The paper demonstrates that layered prefill consistently improves the trade-off between TTFT, TBT, and throughput, pushing the Pareto frontier for MoE serving.
- Energy Efficiency: By reducing memory traffic and redundant computations, layered prefill offers substantial energy savings per output token.
Key Results
Layered prefill consistently outperforms chunked prefill across various metrics:
- Latency Reduction:
- TTFT reduced by up to 70%.
- End-to-end latency reduced by up to 41%.
- Energy Savings: Per-token energy reduced by up to 22%.
- Throughput Improvement: Achieved higher request rates and token generation rates.
- SLO Attainment: Layered prefill sustains higher SLO attainment (near 100%) at elevated request rates compared to chunked prefill. For example, on arXiv, layered prefill sustains 100% SLO attainment up to 1.7 req/s, while chunked prefill collapses at 1.5 req/s.
- Expert Load Traffic Reduction: Reduced total expert weight loads by up to 39% on long-context workloads (arXiv).
Limitations and Future Work
- Model Architecture Dependence: Layered prefill's effectiveness is tied to the layered structure of Transformer models. Its benefits might be less pronounced in models with significantly different architectures.
- Adaptive Grouping: The paper mentions that future work could explore adaptive layer grouping strategies, particularly for models where the layer count is not an even multiple of the group count.
- Data-Center Scale Optimization: The authors suggest further research could jointly optimize for throughput, latency, and energy efficiency at a data-center scale, potentially combining layered prefill with other techniques.
- Non-MoE Models: The paper notes that for dense (non-MoE) models, layered prefill can be slower than chunked prefill because dense models already achieve high GPU utilization, and layered prefill's benefits are primarily from MoE-specific reuse.
Summary updated