Task Scheduling for Efficient Inference of Large Language Models on Single Moderate GPU Systems

Wenxiang Lin, Xinglin Pan, Shaohuai Shi, Xuan Wang, Xiaowen ChuarXiv 2024 · DOI

TL;DR

This paper introduces ScheInfer, a novel inference engine that significantly speeds up Large Language Model (LLM) inference on single, moderate GPU systems by intelligently partitioning model weights and tasks across CPU, GPU, and PCIe communication channels. By dynamically adapting to different inference phases and hardware capabilities, ScheInfer achieves substantial speedups without sacrificing model accuracy.

What Problem Does This Paper Address?

Large Language Models (LLMs) are incredibly powerful but notoriously resource-hungry, requiring substantial computing power and memory. This often limits their deployment to high-end data center GPUs. While techniques like quantization and pruning can reduce model size, they can also degrade accuracy. The paper addresses the challenge of running these LLMs efficiently on more accessible, moderate GPU systems (like those found in personal computers) without compromising performance or accuracy. Existing methods often focus on either CPU or GPU resources, leading to suboptimal utilization.

Methods

ScheInfer tackles this challenge with three core innovations:

  1. Model Partitioning (CC, CG, GG): The key idea is to split the weight tensors of LLM layers (specifically MLPs or MoE experts) into three parts:
  2. CC: Parameters stored and executed on the CPU.
  3. CG: Parameters stored on the CPU but executed on the GPU.
  4. GG: Parameters stored and executed on the GPU. This allows for asynchronous processing across CPU computation, GPU computation, and the communication between them (via PCIe).

  5. Adaptive Partitioning and Optimization:

    • Optimization Model: An optimization model is developed to determine the optimal "slicing rates" (how much of each weight tensor goes into CC, CG, and GG). This is crucial because the ideal split varies significantly based on the specific model and the hardware (CPU, GPU, PCIe bandwidth) of the system.
  6. Prompt vs. Generation Phase Adaptation: The inference process has distinct "prompt" and "generation" phases. ScheInfer recognizes that optimal slicing rates differ between these. For the prompt phase, it introduces a CG' partition (sharing memory with CC but executed on GPU) and a token assignment strategy. This strategy dynamically adjusts the number of tokens processed by the CPU (CC) versus those offloaded to the GPU (CG') to minimize latency during the prompt phase, where CPU computation can be a bottleneck.
  7. Task Scheduling: A sophisticated task scheduler orchestrates the execution of CPU computation, GPU computation, and CPU-GPU communication tasks. It uses four asynchronous streams to maximize overlap and parallelism, ensuring that data transfers and computations happen concurrently whenever possible.

Datasets

The paper does not mention specific datasets used for training the LLMs. However, for evaluation, they use a variety of LLMs (Mixtral, LLaMA-2, Qwen, PhiMoE) and employ workloads derived from the ChatGPT prompts.

Key Insights and Ideas

  • Holistic Resource Utilization: The most significant insight is that true efficiency comes from simultaneously leveraging CPU, GPU, and PCIe resources, rather than optimizing them in isolation.
  • Dynamic Adaptation is Key: The optimal way to split computation isn't static. It depends heavily on the specific hardware (CPU/GPU capabilities, PCIe bandwidth) and the phase of inference (prompt vs. generation).
  • Prompt Phase Bottleneck: CPU computation, particularly matrix multiplications involving prompt tokens, can become a significant bottleneck during the prompt phase. ScheInfer's CG' partition and token assignment strategy directly address this.
  • The Power of Partitioning: Breaking down model weights into CC, CG, and GG allows for a fine-grained control over where computations happen, enabling better resource balancing.

Key Results

ScheInfer demonstrates impressive performance gains across various LLMs and testbeds:

  • Overall Speedup: Achieves an overall speedup ranging from 1.25x to 2.04x compared to state-of-the-art solutions like llama.cpp and Fiddler.
  • Prompt Phase Speedup: Significant speedups in the prompt phase, ranging from 1.69x to 6.33x.
  • Generation Phase Speedup: Speedups in the generation phase range from 1.11x to 1.80x.
  • Effectiveness on Different Hardware: The system shows effectiveness across different CPU and GPU configurations, including those with limited GPU memory (e.g., 12GB).

Limitations and Future Work

  • Focus on Single GPU: The current work focuses on systems with a single moderate GPU. Extending this to multi-GPU systems or distributed environments could be a future direction.
  • LLM Attention Optimizations: The paper acknowledges that LLM attention mechanisms can also be a performance bottleneck, especially with long sequences. While ScheInfer focuses on MLP/MoE layers, integrating attention optimizations could further enhance performance.
  • Activation Sparsity: While the paper mentions activation sparsity techniques, it doesn't integrate them into ScheInfer. Exploring the synergy between sparsity and ScheInfer's partitioning could be beneficial.
  • Hardware-Specific Tuning: The optimization model requires profiling to adapt to specific hardware. While this is a strength, it implies a setup phase for each new system. Automating or further refining this profiling process could be explored.

Summary updated

BibTeX
@misc{lin2024task,
  author = {Wenxiang Lin and Xinglin Pan and Shaohuai Shi and Xuan Wang and Xiaowen Chu},
  title = {{Task Scheduling for Efficient Inference of Large Language Models on Single Moderate GPU Systems}},
  year = {2024},
  eprint = {2411.15715},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.15715},
}
Figure