Skip to the shelves

Meta Enhances GEM Training Efficiency with Advanced LLM-Scale Innovations

Date due card
Shelf AI & ML
Date in
Readers793

Meta's Generative Ads Recommendation Model (GEM) training has achieved a twofold increase in efficiency, leveraging unique architectural advancements and innovative training techniques.

Meta Enhances GEM Training Efficiency with Advanced LLM-Scale Innovations

Introduction to GEM and Its Architectural Significance

Meta’s Generative Ads Recommendation Model (GEM) serves as the backbone for ad recommendations on platforms like Facebook and Instagram. With training now conducted on a large language model (LLM) scale, the infrastructure behind GEM has seen significant innovations. By utilizing several thousand of the latest-generation GPUs, Meta has recently accomplished a remarkable increase in training efficiency: doubling end-to-end (E2E) training efficiency to an effective 20–25% Model FLOPs Utilization (MFU), while simultaneously expanding the training FLOPs by four times over the span of a year.

The engineering challenges residing at the intersection of recommendation systems and LLMs are profound, producing unique operational demands due to the model’s hybrid architecture. This architecture is characterized by a combination of trillions of sparse embedding parameters and billions of dense parameters, each requiring distinct handling during training.

Overview of Training Challenges

Training GEM introduces multifaceted engineering challenges that are substantially different from traditional LLMs:

Challenge 1: Achieving High Per-GPU Utilization

The standard GPU architecture and associated software are primarily optimized for LLM tasks, presenting challenges when applied to GEM’s unique recommendation workloads. The characteristics of these workloads, influenced by user interactions and diverse signal patterns, hinder the traditional approaches to ensuring high GPU compute utilization.

  • Jagged Inputs: The variability in user activity sequences results in training samples that differ vastly in length. Applying padding to a maximum length could waste over 50% of available computational resources.
  • Diverse Interaction Patterns: GEM faces issues related to self-attention mechanisms on extensive user histories and the corresponding interaction with ad representations, complicating efficient compute utilization.
  • Memory-Bound Operations: Design decisions regarding the embedding dimensions and normalization processes lead certain compute units to remain underutilized, further straining efficiency.
  • Numerical Sensitivity: The optimization tasks performed within GEM, such as click-through and conversion rate predictions, exhibit high sensitivity to numerical variations, presenting quality regression risks when utilizing low-precision training methods.

Challenge 2: Scaling Across Thousands of GPUs

Efficiently scaling GEM across a vast number of GPUs while ensuring performance improvements is essential. The correlation between the number of GPUs and speedup is not linear. High-density computations necessitate substantial communication management; thus, E2E latency is dictated by the maximum time taken across the GPU ranks:

E2E Latency = Max across GPU Rank (Max(Local Compute Time, Communication Time))

Achieving near-linear scaling requires adhering to four pivotal conditions:

  • Total compute time should significantly exceed total communication time.
  • Communication should be effectively hidden behind compute processes without contention.
  • Minimal recomputation must arise from memory pressures.
  • Load balancing across ranks must be optimized.

Framework for Enhancing Efficiency

The structural challenges necessitated the formulation of a coherent efficiency framework, focusing on turning a complex co-design effort into manageable technical optimizations. The training efficiency is measured via E2E MFU, expressed as:

E2E MFU = Local MFU (compute efficiency) × Scaling Ratio (scaling efficiency)

Each component—local MFU and scaling ratio—addresses distinct optimization problems:

  • Local MFU: It evaluates how effectively a single GPU's computational resources are employed, factoring in kernel design and numerical precision.
  • Scaling Ratio: This metric indicates how well single-GPU performance sustains its efficiency across distributed GPU setups, influenced by communication overhead and load imbalance.

Leveraging Compute Efficiency through Customized Kernels

To tackle workload-specific challenges, Meta developed tailored kernel libraries and low-precision training techniques aimed directly at recommendation workloads. Key components include:

  • Jagged Flash Attention (JFA): This innovative approach mitigates large compute waste from padding and adapts to variable-length inputs, allowing for maximized compute utilization.
  • BlockAttention: This modular design decreases the complexity of handling long user-history interactions, transitioning from a full attention framework to one utilizing windows to improve efficiency.
  • Generalized Dot-Product Attention (GDPA): This kernel consolidates the diverse attention mechanisms within GEM, catering to production-level efficiency across mixed workloads.
  • Mixed Ultra-Low-Precision Training: Utilizing MXFP8 attention and MLP, it fosters a method to accelerate training throughput while ensuring precision quality for sensitive tasks.

Exploring the Customized Kernel Library

Jagged Sequence Flash Attention (JFA)

JFA is pivotal for accommodating variable-length user sequences while reducing computational overhead. This kernel smartly adjusts to jagged sequences, eliminating padding waste and introducing custom attention mechanisms tailored to the recommendation domain.

Generalized Dot-Product Attention (GDPA)

The GDPA kernel surpasses standard FlashAttention outcomes for the tasks specific to GEM, improving its performance across irregular input sequences while achieving up to 2.6 times increased forward speed and a 3.5x enhancement over FlashAttention 4 in practical applications.

BlockAttention

By moving from quadratic to linear complexity within self-attentions for user history, BlockAttention allows for scalable performance across extensive user history sequences, optimizing computation while maintaining essential model quality benchmarks.

Implementing Ultra-Low-Precision Methods

The adoption of low-precision methodologies helps unlock substantial increases in computational throughput on cutting-edge hardware. Strategies include:

  • Quantization Techniques: This involves fusing quantization into preceding normalization steps, thus minimizing the overhead typically associated with additional processing stages.
  • Numerical Stability Enhancements: Addressing concerns about quantization errors and stability through outlier mitigation and detailed recipe tuning ensures that low-precision frameworks do not compromise model quality.

Improving Scaling Efficiency: Networking, Memory, and Load Balancing

Scaling GEM effectively was further achieved by addressing communication demands and optimizing memory usage. One notable technique involves:

  • 5D Parallelism: A topology-aware parallelism strategy, thinking through the communication patterns and maximizing its efficient execution.
  • Automatic Activation Checkpointing: This allows for dynamic memory allocation to adjust to regions of highest computational payoff, enabling high model performance without the full memory load.

Networking Efficiency and Load Balancing

GEM adopts a robust networking strategy that seeks to offload tasks away from streaming multiprocessors (SMs), thus capitalizing on dedicated hardware for communication tasks. Concurrently, load balancing is evaluated through Base Batch Shuffling (BBS) techniques, which effectively pairs heavier workloads with lighter ones without incurring cross-rank communication overhead.

Conclusion: The Path Forward

Meta’s concerted efforts in enhancing GEM not only provide a template for achieving substantial gains in training efficiency and scalability but also serve as a call to the wider community to explore similar optimization pathways within their respective workloads. The expectation for future advancements is poised on further automating optimization cycles and leveraging improved hardware developments to sustain substantial gains in AI model training.

Source: James Brown · engineering.fb.com

Readers also borrowed