Abstract
Activation sparsity refers to the existence of considerable weakly-contributed elements among activation outputs, serving as a promising paradigm for accelerating model inference. Nevertheless, most large language models (LLMs) adopt activation functions without intrinsic activation sparsity (e.g., GELU and Swish). Some recent efforts have explored introducing ReLU or its variants as the substitutive activation function to pursue activation sparsity and acceleration, but few can simultaneously obtain high activation sparsity and comparable model performance. This paper introduces a simple and effective method named “ProSparse” to sparsify LLMs while achieving both targets. Specifically, after introducing ReLU activation, ProSparse adopts progressive sparsity regularization with a factor smoothly increasing for multiple stages. This can enhance activation sparsity and mitigate performance degradation by avoiding radical shifts in activation distributions. With ProSparse, we obtain high sparsity of 89.32% for LLaMA2-7B, 88.80% for LLaMA2-13B, and 87.89% for end-size MiniCPM-1B, respectively, with comparable performance to their original Swish-activated versions. These present the most sparsely activated models among open-source LLaMA versions and competitive end-size models. Inference acceleration experiments further demonstrate the significant practical acceleration potential of LLMs with higher activation sparsity, obtaining up to 4.52x inference speedup.
Introduction
State-of-the-art Large Language Models (LLMs), including the LLaMA and Mistral families, predominantly utilize activation functions like Swish or GELU. While effective for performance, these functions are computationally "dense," meaning nearly every neuron produces a non-zero output for every input. This density forces hardware to perform exhaustive computations, even for neurons that contribute negligibly to the final output.
"Activation sparsity"—the ability to skip weakly-contributing neurons—offers a significant opportunity for inference acceleration. While earlier architectures utilized ReLU to naturally zero out negative values, simply substituting Swish with ReLU in pre-trained LLMs typically leads to substantial performance degradation. Previous attempts to mitigate this have either failed to reach high sparsity levels or caused radical shifts in internal model distributions, leading to instability. ProSparse is designed to bridge this gap, achieving high sparsity and high performance simultaneously.
The ProSparse Framework
ProSparse employs a three-stage pipeline to convert dense models into sparse counterparts while maintaining architectural integrity.
- Activation Function Substitution: The original activation function (e.g., Swish) is replaced with ReLU. The model then undergoes initial continual training to adapt to the new non-linearity.
- Progressive Sparsity Regularization: To increase sparsity without destabilizing the model, an $L_1$ regularization penalty is applied to the activations. Rather than using a fixed penalty, ProSparse utilizes a progressive schedule where the factor $\lambda$ increases across multiple stages (warmup followed by incremental stages along a sine curve). This allows the model to gradually redistribute its "knowledge" to the remaining active neurons.
- Activation Threshold Shifting (FATReLU): In the final stage, the framework introduces "Fully Accelerated Threshold ReLU" (FATReLU). By shifting the activation threshold to a small positive value $t$ (e.g., 0.01), the model prunes away low-value, "noisy" activations that have negligible impact on the final output.
To translate these theoretical gains into real-world speed, the authors implemented custom sparse GPU kernels designed to exploit both input-side and output-side sparsity within Feed-Forward Network (FFN) layers.
Experimental Results
The ProSparse framework was evaluated using a massive mixed corpus for training, including StarCoder, Wikipedia, and The Pile, alongside instruction tuning datasets like UltraChat and Flan. Performance was measured across standard benchmarks for code generation (HumanEval), reasoning (GSM8K, BBH), and general knowledge (MMLU, AGI Eval).
Sparsity and Performance
ProSparse achieved unprecedented sparsity levels: 89.32% for LLaMA2-7B and 88.80% for LLaMA2-13B. Crucially, as shown in the performance table, these sparse models maintain benchmarks comparable to their original dense Swish-activated versions. The method also proved effective for smaller architectures, achieving 87.89% sparsity for the MiniCPM-1B model.
Inference Acceleration
Real-world speedup tests demonstrated the practical utility of high activation sparsity. Using the PowerInfer framework, the authors achieved up to a 4.52x inference speedup. Furthermore, custom accurate GPU kernels yielded up to a 2.44x speedup specifically during the FFN computation steps, which constitute the majority of LLM parameters.
Key Insights and Discussion
- Controllability: A predictable, negative exponential relationship exists between the regularization factor and final sparsity, allowing developers to target specific sparsity levels based on hardware constraints.
- Data-Dependent Sparsity: Sparsity is not uniform; models naturally become sparser when processing highly formatted data (like code) compared to natural language prose. Additionally, higher layers in the network tend to exhibit greater sparsity than lower layers.
- Orthogonality: Activation sparsity is complementary to other efficiency techniques, such as weight pruning and quantization, suggesting potential for combined optimization strategies.
Conclusion and Future Work
ProSparse demonstrates that LLMs can achieve extreme activation sparsity (~90%) without sacrificing performance, provided the transition is managed through progressive regularization. While this study focused on models up to 13B parameters and primarily optimized FFN layers, future work will explore scaling to ultra-large models (70B+) and addressing the density of Attention layers. Although the "ReLUfication" process requires additional training (approximately 2-3% of the original pre-training budget), the resulting inference efficiency offers a compelling trade-off for large-scale deployment.
Summary updated