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:
- 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.
- Embedding Layer Pruning: Analysis of the UNIMO model’s 12,800-dimension embedding layer revealed rarely used vocabulary, which was subsequently trimmed.
- 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.
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.
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