TL;DR
This paper provides an in-depth system performance characterization of four diverse, industry-scale generative AI workloads (Llama, Chameleon, Seamless, and HSTU) across different GPU generations. By applying a cross-stack optimization strategy combining system-level levers (SDPA, torch.compile, CUDA Graphs, and quantization) with algorithmic enhancements (LayerSkip), the authors achieve an average 3.88× speedup, establishing a new, more rigorous baseline for future hardware and software co-design.
What Problem Does This Paper Address?
As generative AI transitions from text-only large language models (LLMs) to multimodal systems handling text, images, speech, and user histories, system resource demands are skyrocketing. To sustainably scale these capabilities to billions of users, inference must be exceptionally fast and efficient.
However, different modalities and model architectures introduce highly distinct system bottlenecks. Optimization is often hindered by a lack of comprehensive, real-system characterization across these diverse workloads. For instance, some tasks are heavily memory-bandwidth bound, while others are bottlenecked by CPU overhead or complex decoding strategies like beam search. This paper addresses this gap by profiling real-system execution to pinpoint exactly where time is spent and how to eliminate these bottlenecks.
Methods
The authors employ a cross-stack optimization approach divided into two main categories:
- Horizontal System-Level Optimizations: These are agnostic to specific algorithms and applied across the workloads:
- PyTorch Scaled Dot Product Attention (SDPA) / FlashAttention: Used to accelerate the memory-intensive attention mechanism.
torch.compileand CUDA Graphs: Deployed to eliminate CPU-bound kernel launch overheads, keeping the GPU active by scheduling successions of operations as a single graph. To overcome the limitation of static shapes required by CUDA Graphs, they implemented a static buffer for the KV cache.- Data Type Optimization (AutoQuant): Utilizes PyTorch’s
torchaolibrary to automatically determine the most efficient precision (e.g., int8 dynamic or int8 weight-only quantization) for each linear layer. - Vertical Workload-Specific Optimizations:
- LayerSkip: A self-speculative decoding technique applied specifically to auto-regressive models (Llama and Chameleon). It accelerates inference by generating draft tokens using fewer layers and verifying them in parallel with the remaining layers.
Datasets
The characterization and evaluation span four distinct model categories and their corresponding datasets:
- Text-based LLM (Llama): Evaluated on HumanEval and MBPP for code completion and instruction tasks.
- Image & Text Generation (Chameleon): Evaluated on MSCOCO (for Image-to-Text and Text-to-Image) and Vizwiz (for Image/Text-to-Text visual question answering).
- Speech & Text Translation (Seamless): Evaluated on the Fleurs (English-to-Spanish) dataset for speech-to-speech, speech-to-text, text-to-text, and text-to-speech translation.
- Generative DLRM (HSTU): Evaluated on a Synthetic user history dataset configured to match production environments for recommendation ranking and retrieval.
Key Insights and Ideas
- The Autoregressive Bottleneck: For autoregressive models, end-to-end latency is primarily dictated by the number of decoding steps rather than the prefill sequence length. Conversely, non-autoregressive models like HSTU generate all tokens simultaneously, making them significantly faster.
- Inference is Often CPU-Bound: At small batch sizes, autoregressive model inference is frequently dominated by GPU idle time. This is caused by CPU overhead delaying the launch of GPU kernels.
- Linear Operations Matter: FFNs (Feed Forward Networks) constitute a massive portion of inference latency, often dominating attention operations in models like Llama and Chameleon.
- KV Cache Reordering Overhead: Models utilizing beam search (like Seamless) spend a significant portion of runtime copying and reordering the KV cache in memory to match selected beams. Fusing these operations via
torch.compilemitigates this issue.
- Shifting Bottlenecks Across GPU Generations: Upgrading from NVIDIA A100 to H100 GPUs yields a dramatic 6.82× speedup for linear operations, effectively shifting the primary system bottleneck back to attention and miscellaneous operations.
Key Results
- Attention Acceleration: PyTorch SDPA accelerates inference by an average of 1.07× for single-batch and 1.43× for maximum-batch settings. For the attention-dominated HSTU model, manual optimizations achieved up to a 15× speedup on 8K sequences.
- GPU Utilization Gains: Adding
torch.compileand CUDA Graphs provides an additional 2.14× (single batch) and 2.16× (maximum batch) speedup on top of SDPA. - Quantization Benefits: AutoQuant delivers up to an additional 1.20× to 1.57× performance improvement for memory-bound scenarios.
- Algorithmic Speedup: LayerSkip alone delivers a geomean 1.58× speedup for autoregressive models, with minimal impact on accuracy.
- Total Cross-Stack Impact: Combining all system and algorithmic optimizations yields an overall average 3.88× speedup over unoptimized baselines.
Limitations and Future Work
- LayerSkip Overhead: LayerSkip requires continuous model pretraining with early exit loss and layer dropout, demanding significant compute resources (64 GPUs for 50K iterations) and access to the original pretraining corpus. Furthermore, it is strictly limited to auto-regressive decoder models.
- CUDA Graph Constraints: The requirement for static tensor shapes forces the use of a static KV cache buffer. In some workloads, like Seamless at maximum batch size, the computational cost of managing this large static buffer can surpass the CPU overhead savings, leading to performance degradation.
- Future Directions: The authors emphasize that hardware architects must prioritize flexibility and reconfigurability to accommodate diverse computational patterns, alongside expanding on-chip memory to handle growing network demands.
Summary updated