Abstract
Large Language Models (LLMs) face significant deployment challenges due to high computational and I/O demands. While sparse computation offers a solution, modern non-ReLU models like LLaMA lack exact zeros, complicating traditional sparsity methods. This paper redefines sparsity through neuron output magnitudes, demonstrating that models using SwiGLU are naturally sparse. We evaluate various activation functions and identify ReLU² as the optimal choice, providing high performance, superior predictability, and hardware affinity. ReLU² enables approximately 90% sparsity with minimal performance loss and a 92% reduction in I/O overhead.
Introduction
The deployment of Large Language Models (LLMs) in low-resource environments is hindered by their immense computational requirements. Sparse computation—skipping inactive neurons during inference—is a promising mitigation strategy. Traditionally, this relied on the ReLU activation function, which produces exact zeros. However, state-of-the-art models like LLaMA utilize Gated Linear Unit (GLU) variants (e.g., SwiGLU) that do not produce exact zeros, raising questions about their inherent sparsity and the optimal activation function for efficient deployment.
Methodology: Redefining Sparsity
The authors propose a generalized definition of sparsity based on neuron output magnitude. A neuron is considered "inactive" if its output magnitude falls below a specific threshold, rather than requiring an exact zero. This approach reveals that even non-ReLU models exhibit a "long-tail" distribution where most neurons contribute minimally to the final output.
To quantify the impact of pruning these low-magnitude neurons, the researchers introduced the Cumulative Errors of Tail Truncation (CETT) metric. This framework evaluates activation functions across three dimensions: the sparsity-performance trade-off, predictivity (the ease of identifying active neurons beforehand), and hardware affinity (alignment with memory and compute patterns).
The Superiority of ReLU²
Through systematic evaluation of 1.3B parameter models trained from scratch and analysis of LLaMA-2 checkpoints (7B to 70B), ReLU² ($max(0, x)^2$) emerged as the most effective activation function. It successfully bridges the gap between the high performance of GLU variants and the high sparsity/predictability of ReLU.
Key Performance Insights
- Sparsity and Accuracy: ReLU² models achieve a 90% sparsity ratio with less than a 0.1% drop in accuracy.
- Predictability: Activation patterns in ReLU² are significantly easier for lightweight predictor networks to identify compared to SwiGLU, which is essential for achieving real-world inference speedups.
- Training Dynamics: As shown in Figure 6, ReLU² maintains competitive performance and loss profiles throughout the training process compared to other popular activation functions.
Hardware Affinity and Efficiency
ReLU² exhibits strong "token-to-token" overlap, meaning consecutive tokens often activate similar sets of neurons. This hardware-friendly pattern allows active weights to remain in fast memory (SRAM/Cache) longer, leading to an estimated 92% reduction in I/O overhead for feed-forward networks. Furthermore, the use of efficient predictors with ReLU² can lead to a 56% reduction in total FLOPs for a 1B parameter model without sacrificing performance.
Conclusion
This research demonstrates that sparsity is a universal property of LLMs, regardless of whether they use ReLU. By adopting ReLU², developers can leverage this natural sparsity to drastically reduce the resource footprint of LLMs. Future work will explore "sparsity-aware" training recipes to further enhance the hardware-friendly co-activation patterns identified in this study.
Summary updated