The Solution for the AIGC Inference Performance Optimization Competition

Sishun Pan, Haonan Xu, Zhonghua Wan, Yang YangarXiv 2024 · DOI

Abstract

This paper presents a multi-layered optimization strategy designed to accelerate the inference of Baidu’s Ernie (Wenxin) generative models, specifically the UNIMO-text architecture. By integrating model-level pruning, half-precision (FP16) computation, and a novel multi-process parallel processing pipeline, the authors achieved an 8.96x speedup over standard baselines. These optimizations were validated in the AIGC Inference Performance Optimization Competition, where the solution secured first place.

Introduction

As Large Language Models (LLMs) like ChatGPT and Ernie become central to commercial AI-Generated Content (AIGC), the "inference tax"—the computational cost and latency of running these models—has become a major bottleneck. High latency degrades user experience, while high computational overhead inflates server costs. This work targets the UNIMO-text architecture, addressing challenges related to redundant parameters in embedding layers and sequential data processing bottlenecks where GPU resources often sit idle.

Optimization Methodology

Model-Level Optimizations

The authors employed several techniques to streamline the model's computational graph and memory usage:

  1. Faster Transformer & FP16: Kernel fusion and tensorization were utilized to reduce memory bandwidth requirements. Switching from FP32 to FP16 (half-precision) allowed the use of GPU Tensor Cores for faster arithmetic with a significantly smaller memory footprint.
  2. Embedding Layer Pruning: Analysis of the UNIMO model’s 12,800-dimension embedding layer revealed rarely used vocabulary, which was subsequently trimmed.
  3. KV Caching: Intermediate attention results were stored to avoid redundant calculations during the auto-regressive generation process.

Data-Driven Pruning

A key insight came from analyzing the sequence length distribution of actual user data. While the model was originally designed to handle up to 512 tokens, empirical data showed that most inputs were significantly shorter.

Sequence length distribution diagram

By pruning the positional embedding matrix from 512x1024 down to 128x1024, the authors achieved significant efficiency gains without sacrificing accuracy for the target use case.

Framework and Pipeline Parallelism

Beyond model weights, the authors optimized the execution framework. Using the Paddle Inference framework, they implemented operator (OP) fusion to merge adjacent mathematical operations, reducing the number of kernel launches on the GPU.

Furthermore, they addressed the bottleneck of sequential processing. In standard implementations, the GPU often waits for the CPU to complete tokenization and preprocessing. By decoupling these steps into four parallel processes, the system can preprocess the next batch while the GPU is busy with the current inference task.

Multi-process Parallel Processing Pipeline

Results

The cumulative effect of these optimizations resulted in a massive throughput increase. Starting from a baseline speed of 16.11, the integration of Faster Transformer, embedding pruning, and multi-process parallelism pushed the final speed to 144.45, representing an 8.96x improvement.

Method Speed Cumulative Improvement
Baseline 16.11 1.0x
+ Faster Transformer 98.46 ~6.1x
+ Embedding Pruning 125.32 ~7.8x
+ Multi-process Parallelism 144.45 8.96x

Conclusion

This work demonstrates that significant inference speedups can be achieved by looking beyond neural network weights. Practical insights, such as pruning input structures based on real-world data distributions and hiding latency through multi-process pipelining, are essential for deploying large-scale AIGC models efficiently. Future work will explore more aggressive quantization (INT8/FP8) and dynamic batching to further maximize hardware utilization.

Summary updated

Abstract

In recent years, the rapid advancement of large-scale pre-trained language models based on transformer architectures has revolutionized natural language processing tasks. Among these, ChatGPT has gained widespread popularity, demonstrating human-level conversational abilities and attracting over 100 million monthly users by late 2022. Concurrently, Baidu's commercial deployment of the Ernie Wenxin model has significantly enhanced marketing effectiveness through AI-driven technologies. This paper focuses on optimizing high-performance inference for Ernie models, emphasizing GPU acceleration and leveraging the Paddle inference framework. We employ techniques such as Faster Transformer for efficient model processing, embedding layer pruning to reduce computational overhead, and FP16 half-precision inference for enhanced computational efficiency. Additionally, our approach integrates efficient data handling strategies using multi-process parallel processing to minimize latency. Experimental results demonstrate that our optimized solution achieves up to an 8.96x improvement in inference speed compared to standard methods, while maintaining competitive performance.
BibTeX
@misc{pan2024solution,
  author = {Sishun Pan and Haonan Xu and Zhonghua Wan and Yang Yang},
  title = {{The Solution for the AIGC Inference Performance Optimization Competition}},
  year = {2024},
  eprint = {2407.04991},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.04991},
}
Figure