DeepSpeed- Inference: Enabling Efficient Inference of Transformer Models at Unprecedented Scale

Reza Yazdani Aminabadi, Samyam Rajbhandari, Ammar Ahmad Awan, Cheng Li, Du Li, Elton Zheng, Olatunji Ruwase, Shaden Smith, Minjia Zhang, Jeff Rasley, Yuxiong He

TL;DR

This paper introduces DeepSpeed-Inference, a comprehensive system designed to tackle the growing challenges of efficiently inferring massive transformer models. It offers both a multi-GPU solution for optimized latency and throughput, and a heterogeneous CPU/NVMe/GPU approach for models exceeding GPU memory, enabling unprecedented scale and accessibility for large-scale AI.

What Problem Does This Paper Address?

The world of transformer models is exploding in size and complexity. We're seeing models with hundreds of billions, even trillions, of parameters. These models are also becoming more diverse, with techniques like Mixture-of-Experts (MoE) introducing sparsity, and application needs varying wildly from ultra-low latency to high throughput. This diversity, coupled with the limitations of current hardware (single GPUs, limited memory), makes it incredibly difficult to deploy these models efficiently in production. Existing inference systems often struggle with:

  • Latency: Small batch sizes, common in real-time applications, are bottlenecked by memory bandwidth.
  • Throughput: Achieving high throughput requires different optimizations than training, especially for generative models with sequential dependencies.
  • Model Size: Models too large to fit into aggregate GPU memory pose a significant deployment hurdle.
  • Hardware Heterogeneity: Systems can range from single GPUs to massive multi-node clusters with varying interconnects.

DeepSpeed-Inference aims to provide a unified, performant, and scalable solution that addresses these multifaceted challenges.

Methods

DeepSpeed-Inference is built on two core components:

  1. DeepSpeed Transformer: This is a multi-GPU solution designed for models that do fit within the aggregate GPU memory. It employs a three-layered system:
  2. Single-GPU Kernels: Optimized for both low-batch latency (memory bandwidth focus) and high-batch throughput (compute utilization focus).
  3. Many-GPU Dense Transformer Layer: Utilizes tensor parallelism for latency reduction and inference-optimized pipeline parallelism for throughput maximization.
  4. Massive-GPU Sparse Transformer Layer: Specifically designed for MoE models, combining expert, data, and tensor parallelism with novel communication and sparse kernel optimizations to scale to hundreds of GPUs.
  5. ZeRO-Inference: This is a heterogeneous solution for models that exceed aggregate GPU memory. It leverages CPU and NVMe storage alongside GPU memory and compute. Key strategies include:
  6. Memory Offloading: Streaming model weights from DRAM/NVMe into GPU memory layer by layer, enabling larger batch sizes.
  7. Prefetching: Overlapping the loading of future layers with the computation of the current one.
  8. PCIe Bandwidth Utilization: Optimizing communication between CPU/NVMe and GPUs, and between GPUs themselves, to maximize data transfer efficiency.

Both components incorporate Deep-Fusion, a technique that fuses multiple operations (beyond just element-wise) into a single kernel to reduce kernel launch overhead and data movement. They also introduce SBI-GeMM, a custom GeMM kernel optimized for small batch sizes to improve memory bandwidth utilization.

Datasets

Not explicitly discussed in the paper. The evaluation focuses on various transformer-based language models (e.g., GPT-style models, MoE models) with different parameter counts and architectures.

Key Insights and Ideas

  • Inference is Fundamentally Different from Training: The paper highlights that optimizations for training (e.g., maximizing compute utilization at large batch sizes) are often suboptimal for inference, which frequently deals with small batches and is memory-bandwidth bound.
  • Fusion is Key for Latency: Techniques like Deep-Fusion, which fuse more complex operations than previously possible, are crucial for reducing kernel launch and data movement overheads, especially at small batch sizes.
  • Heterogeneous Memory is Essential for Scale: ZeRO-Inference demonstrates that by intelligently offloading model weights to CPU/NVMe, it's possible to infer models that are orders of magnitude larger than what fits in GPU memory alone, democratizing access to massive AI.
  • Specialized Kernels for Sparse Models: MoE models require a different set of optimizations, particularly around managing the communication overhead of expert parallelism, which DeepSpeed-Inference addresses with novel parallelism coordination.
  • Hybrid Scheduling for Pipeline Parallelism: Recognizing that prompt processing and token generation have different performance characteristics, a hybrid scheduling approach optimizes both phases in autoregressive models.

Key Results

  • Latency Reduction: Up to 7.3x lower latency for latency-oriented scenarios compared to state-of-the-art.
  • Throughput Increase: Over 1.5x higher throughput for throughput-oriented scenarios.
  • Unprecedented Scale: Enables trillion-parameter scale inference under real-time latency constraints using hundreds of GPUs.
  • Model Size Democratization: ZeRO-Inference allows inference of models 25x larger than GPU-only solutions on resource-constrained systems.
  • High Throughput: Achieves 84 TFLOPS, over 50% of A6000 peak performance, with ZeRO-Inference.
  • MoE Performance: DeepSpeed-MoE shows significant latency reduction (up to 7.2x) and improved throughput for sparse models, enabling trillion-parameter models to be served under 25ms.

Limitations and Future Work

  • Future Work: The paper mentions that while hybrid scheduling shows promise for prompt processing latency, there's an outstanding issue with PyTorch's AllReduce kernel that needs further investigation.
  • Limitations: The paper focuses on transformer-based decoder models for evaluation. While the techniques are broadly applicable, specific performance gains might vary for other architectures. The ZeRO-Inference component is primarily geared towards throughput-oriented scenarios, with latency being a secondary consideration.

Summary updated

BibTeX
@inproceedings{aminabadi2022deepspeed,
  author = {Reza Yazdani Aminabadi and Samyam Rajbhandari and Ammar Ahmad Awan and Cheng Li and Du Li and Elton Zheng and Olatunji Ruwase and Shaden Smith and Minjia Zhang and Jeff Rasley and Yuxiong He},
  title = {{DeepSpeed- Inference: Enabling Efficient Inference of Transformer Models at Unprecedented Scale}},
  booktitle = {SC},
  year = {2022},
  url = {https://openreview.net/forum?id=i8fKmrBBveL},
}
Figure