Characterizing and Efficiently Accelerating Multimodal Generation Model Inference

Yejin Lee, Anna Y. Sun, Basil Hosmer, Bilge Acun, Can Balioglu, Changhan Wang, Charles David Hernandez, Christian Puhrsch, Daniel Haziza, Driss Guessous, Francisco Massa, Jacob Kahn, Jeffrey Wan, Jeremy Reizenstein, Jiaqi Zhai, Joe Isaacson, Joel Schlosser, Juan Pino, Kaushik Ram Sadagopan, Leonid Shamis, Linjian Ma, Min-Jae Hwang, Mingda Chen, Mostafa Elhoushi, Pedro Rodriguez, Ram Pasunuru, Scott Yih, Sravya Popuri, Xing Liu, Carole-Jean Wu

TL;DR

This paper dives deep into the system performance of cutting-edge multimodal generative AI models, revealing that while attention is a known bottleneck, linear operations and GPU idle time are also critical for efficient inference. By characterizing these models and applying a suite of cross-stack optimizations, the authors achieve a significant 3.88x speedup, paving the way for more scalable and accessible generative AI.

What Problem Does This Paper Address?

Generative AI, particularly multimodal models that handle text, images, and speech, is exploding in popularity. This growth, however, brings immense computational demands, making fast and efficient inference crucial for widespread adoption. Existing research often focuses on specific components like attention, but a holistic understanding of the system-level bottlenecks across diverse multimodal models is lacking. This paper aims to bridge that gap by characterizing the performance of several key multimodal models and identifying opportunities for cross-stack optimization to achieve significant inference acceleration.

Methods

The authors employ a multi-pronged approach:

  • System Performance Characterization: They conduct in-depth real-system performance analysis of four prominent multimodal generative AI models (Llama, Chameleon, Seamless, and HSTU). This involves profiling computational and memory bandwidth requirements, analyzing input/output distributions, and performing roofline analysis.
  • Cross-Stack Optimization: They apply a combination of system-level optimizations (Scaled Dot Product Attention (SDPA), torch.compile, CUDA Graph, and AutoQuant) and workload-specific algorithmic optimizations (LayerSkip).
  • System-Level: SDPA optimizes attention, torch.compile fuses operations and optimizes computation graphs, CUDA Graph enables efficient GPU kernel execution, and AutoQuant leverages quantization for improved efficiency.
  • Workload-Specific: LayerSkip is a novel technique for autoregressive models that speeds up inference by using fewer layers for draft token generation and parallel verification.
  • GPU Generation Analysis: They extend their analysis to the newer NVIDIA H100 GPU to understand how optimizations generalize across hardware generations.

Datasets

The paper utilizes a variety of datasets for training and/or evaluation, depending on the model and task:

  • Llama: HumanEval and MBPP (for coding tasks).
  • Chameleon: MSCOCO (for image captioning and text-to-image generation), Vizwiz (for visual question answering and image-text-to-text tasks).
  • Seamless: Fleurs (for speech translation tasks).
  • HSTU: A synthetically generated dataset for recommendation tasks.

The paper does not introduce new benchmarks but uses established ones to evaluate existing models.

Key Insights and Ideas

  • Beyond Attention: While attention is a known bottleneck, the paper highlights that linear operations (in feed-forward networks) and GPU idle time (due to CPU overhead) are equally critical for overall inference latency, especially in autoregressive models.
  • Autoregressive vs. Non-Autoregressive: Autoregressive models (like Llama, Chameleon, Seamless) are heavily impacted by the number of decoding steps, leading to significant latency. Non-autoregressive models (like HSTU) are much faster and less dependent on token generation.
  • CPU Overhead is a Killer: GPU kernel launch overhead and CPU waiting times can lead to significant GPU underutilization, a problem addressed by techniques like torch.compile and CUDA Graph.
  • KV Cache Management Matters: For models using beam search (like Seamless), KV cache reordering can be a substantial performance bottleneck, requiring specialized optimization.
  • Hardware vs. Software Optimization: While new hardware (like H100) offers significant improvements, the paper demonstrates that exhausting state-of-the-art software optimizations can yield substantial gains even on existing hardware.
  • No One-Size-Fits-All: The effectiveness of optimizations varies significantly across models and tasks, emphasizing the need for adaptable strategies.

Key Results

  • Overall Speedup: The paper achieves a remarkable 3.88x speedup in end-to-end inference performance by combining state-of-the-art system-level and workload-specific optimizations.
  • LayerSkip Impact: LayerSkip, a workload-specific optimization, provides an average speedup of 1.58x for autoregressive models like Llama and Chameleon.
  • System-Level Optimization Gains: SDPA, torch.compile, and AutoQuant collectively provide significant speedups, with AutoQuant alone offering an additional 1.20x to 1.57x improvement on top of torch.compile.
  • Seamless Optimization: For Seamless, torch.compile and CUDA Graph achieve up to 2.7x speedup for single-batch inference.
  • H100 vs. A100: The H100 GPU shows substantial improvements, particularly in linear operations (6.82x speedup), shifting performance bottlenecks and demonstrating diminishing returns for software optimizations on newer hardware.

Limitations and Future Work

  • LayerSkip Requirements: LayerSkip requires continuous model pretraining and access to the original training corpus, making it resource-intensive. It's also primarily beneficial for autoregressive models.
  • AutoQuant Tuning: AutoQuant's effectiveness for recommendation models (HSTU) was not pursued due to the need for careful tuning and the fact that linear operations are not the primary bottleneck.
  • Hardware-Software Co-design: The paper suggests that future hardware accelerators should prioritize flexibility and adaptability to accommodate diverse computational patterns and optimization knobs. Increased on-chip memory and enhanced communication are also crucial for large-scale generative models.
  • Further Optimization: The authors believe there's untapped potential in existing hardware by further exploring and combining optimization techniques. The diversity of model architectures and modalities necessitates flexible and adaptable optimization strategies.

Summary updated

Abstract

Generative artificial intelligence (AI) technology is revolutionizing the computing industry. Not only its applications have broadened to various sectors but also poses new system design and optimization opportunities. The technology is capable of understanding and responding in multiple modalities. However, the advanced capability currently comes with significant system resource demands. To sustainably scale generative AI capabilities to billions of users in the world, inference must be fast and efficient. This paper pinpoints key system design and optimization opportunities by characterizing a family of emerging multi-modal generation models on real systems. Auto-regressive token generation is a critical latency performance bottleneck, typically dominated by GPU idle time. In addition to memory-intensive attention across the generative AI models, linear operations constitute significant inference latency due to the feed forward networks in Transformer-based models. We demonstrate that state-of-the-art optimization levers, spanning from applications to system software and hardware, set a 3.88x better baseline.
BibTeX
@inproceedings{lee2024characterizing,
  author = {Yejin Lee and Anna Y. Sun and Basil Hosmer and Bilge Acun and Can Balioglu and Changhan Wang and Charles David Hernandez and Christian Puhrsch and Daniel Haziza and Driss Guessous and Francisco Massa and Jacob Kahn and Jeffrey Wan and Jeremy Reizenstein and Jiaqi Zhai and Joe Isaacson and Joel Schlosser and Juan Pino and Kaushik Ram Sadagopan and Leonid Shamis and Linjian Ma and Min-Jae Hwang and Mingda Chen and Mostafa Elhoushi and Pedro Rodriguez and Ram Pasunuru and Scott Yih and Sravya Popuri and Xing Liu and Carole-Jean Wu},
  title = {{Characterizing and Efficiently Accelerating Multimodal Generation Model Inference}},
  booktitle = {OpenReview Archive Direct Upload},
  year = {2024},
  url = {https://openreview.net/forum?id=H4dZmm0PQL},
}
Figure