TL;DR
This paper introduces Stochastic Activations (StochA), a novel training strategy that randomly alternates between SiLU and ReLU activation functions based on a Bernoulli draw. By pairing this technique with activation fine-tuning (Swi+FT), the authors successfully train Large Language Models that benefit from SiLU's superior optimization during training, while unlocking the 80–90% computational sparsity of ReLU at inference time—yielding up to a 1.65x speedup without sacrificing model performance.
What Problem Does This Paper Address?
In Large Language Models (LLMs), the Feed-Forward Network (FFN) layers hold the vast majority of the parameters. The choice of activation function within these layers creates a classic trade-off between training trainability and inference efficiency:
- ReLU (Rectified Linear Unit) is highly efficient at inference time. Because it maps all negative inputs to exactly zero, it induces sparsity. This allows hardware to skip computations, turning dense matrix operations into much faster sparse operations. However, ReLU is notoriously difficult to optimize due to the "dying ReLU" problem, where neurons get stuck in the negative region with zero gradient flow, halting learning.
- SiLU (Sigmoid Linear Unit) allows gradients to flow smoothly even for negative values, leading to significantly better downstream accuracy. Unfortunately, SiLU does not produce zero values, meaning it completely lacks inference-time sparsity.
The authors set out to bridge this gap: How can we train an LLM with the optimization advantages of a smooth activation function like SiLU, but deploy it with the high sparsity and computational speed of ReLU?
Methods
The authors propose two core, complementary strategies to achieve activation-level flexibility:
- Stochastic Activations (StochA): During training, for any negative input ($x < 0$), the network randomly selects between ReLU (with probability $1-p$) and SiLU (with probability $p$). For positive inputs ($x \ge 0$), it acts deterministically. This stochastic blending ensures that gradients continue to flow through the negative domain during the critical phases of training, bypassing the flat-gradient problem of pure ReLU.
- Activation Fine-Tuning (Swi+FT): The model is pre-trained for the majority of its schedule (e.g., 90–95% of iterations) using an optimization-friendly activation function (like SiLU or StochA). For the final 5–10% of training steps, the activation function is switched entirely to ReLU. This allows the model weights to smoothly adapt to a sparse regime before deployment.
Additionally, the authors explore using StochA at test time. By keeping the activation function probabilistic during inference, they introduce a new way to inject randomness into sequence generation, serving as an alternative to traditional token-level temperature sampling.
Datasets
The methods were evaluated by training dense, decoder-only transformers from scratch at two scales: LM1.5B (trained on 47 billion tokens) and LM3B (trained on 80 billion tokens). The pre-training corpus consisted of a diverse mix of English natural language and source code.
Downstream performance was measured across a robust suite of standard benchmarks:
- Code Generation: HumanEval+, MBPP
- Common Sense & Reasoning: HellaSwag, ARC (Easy and Challenge), PIQA, OBQA, WinoGrande, NaturalQuestions (NQ), RACE, TriviaQA (TQA), and GSM8K.
Key Insights and Ideas
- Eradicating "Dead Neurons": Vanilla ReLU training leaves a massive fraction of the FFN network completely unused—essentially creating dead weight. Pre-training with SiLU or StochA prevents these neurons from dying early on. Even after fine-tuning the model down to pure ReLU via Swi+FT, the neurons remain active and useful.
- The Power of Synergy: Simply switching from SiLU to ReLU at the end of training (Swi+FT alone) causes a massive, unrecoverable spike in loss. The model must be primed with StochA during pre-training to make the network compatible with the impending sparse regime.
- Activation-Level Diversity: When StochA is utilized at test time, the randomness introduced at the hidden-layer level naturally produces highly diverse text sequences. This provides a completely orthogonal method to increase generation variety without relying solely on modifying output token probabilities.
Key Results
- High Sparsity at Zero Cost: Models trained with StochA + Swi+FT achieved between 84% and 88% activation sparsity at inference time. Despite this massive reduction in active neurons, they delivered downstream benchmark performance virtually on par with pure SiLU models, significantly outperforming vanilla ReLU baselines.
- Substantial Hardware Speedups: By exploiting this 90% sparsity threshold to avoid unnecessary memory reads, the authors demonstrated a 1.65x speedup for FFN layer inference on CPUs and a 1.5x speedup on NVIDIA H100 GPUs.
Limitations and Future Work
- System-Level Bottlenecks: While FFN layer computation scales down beautifully with sparsity, overall end-to-end inference speedups on GPUs are currently bottlenecked by non-sparse overheads, such as KV-cache management, attention masking, and RoPE positional encodings. The authors note that highly optimized software stacks or larger model scales will be required to fully realize these gains.
- Test-Time Accuracy Trade-offs: While using StochA at inference time successfully boosts text diversity, its raw accuracy on certain strict question-answering datasets (like TriviaQA) was slightly lower than the standard SiLU + temperature sampling baseline. Further tuning of the probability parameter $p$ at test time remains an open area of exploration.
Summary updated