The Lazy Neuron Phenomenon: On Emergence of Activation Sparsity in Transformers

Zonglin Li, Chong You, Srinadh Bhojanapalli, Daliang Li, Ankit Singh Rawat, Sashank J. Reddi, Ke Ye, Felix Chern, Felix Yu, Ruiqi Guo, Sanjiv Kumar · DOI

Abstract

This paper studies the curious phenomenon for machine learning models with Transformer architectures that their activation maps are sparse. By activation map we refer to the intermediate output of the multi-layer perceptrons (MLPs) after a ReLU activation function, and by sparse we mean that on average very few entries (e.g., 3.0% for T5-Base and 6.3% for ViT-B16) are nonzero for each input to MLP. Moreover, larger Transformers with more layers and wider MLP hidden dimensions are sparser as measured by the percentage of nonzero entries. Through extensive experiments we demonstrate that the emergence of sparsity is a prevalent phenomenon that occurs for both natural language processing and vision tasks, on both training and evaluation data, for Transformers of various configurations, at layers of all depth levels, as well as for other architectures including MLP-mixers and 2-layer MLPs. We show that sparsity also emerges using training datasets with random labels, or with random inputs, or with infinite amount of data, demonstrating that sparsity is not a result of a specific family of datasets. We discuss how sparsity immediately implies a way to significantly reduce the FLOP count and improve efficiency for Transformers. Moreover, we demonstrate perhaps surprisingly that enforcing an even sparser activation via Top-k thresholding with a small value of k brings a collection of desired but missing properties for Transformers, namely less sensitivity to noisy training data, more robustness to input corruptions, and better calibration for their prediction confidence.

Introduction

Artificial deep neural networks (DNNs) are typically conceptualized as dense computational engines where every neuron contributes to every inference. This stands in stark contrast to the biological brain, which operates with extreme energy efficiency through sparse neural firing. Recent research has identified the "Lazy Neuron Phenomenon": the observation that Transformers naturally develop high levels of activation sparsity during training, even without explicit regularization. This study investigates the origins, prevalence, and potential applications of this emergent sparsity.

Methodology

The investigation focuses on the Multi-Layer Perceptron (MLP) blocks within Transformer architectures such as T5 and Vision Transformers (ViT). Specifically, the authors analyze the intermediate output of the MLP after the ReLU activation function.

To explore the utility of this phenomenon, the researchers introduced "Top-k Transformers." In this modified architecture, the standard ReLU is replaced with a Top-k thresholding operation that retains only the $k$ largest activations, setting all others to zero. This explicitly enforces the sparsity observed naturally. The study further isolates the drivers of sparsity by training models on synthetic datasets featuring random labels and random pixel inputs.

The Emergence of Sparsity

A primary finding is that sparsity is not a static property but an emergent one. As training progresses, the percentage of nonzero activations decreases significantly across all layers, typically stabilizing within the first few thousand steps.

Figure 1: Percentage of nonzero activations over training steps for T5 Encoder and Decoder layers. Sparsity emerges rapidly during the initial phase of training and stabilizes at low levels.

This emergence occurs regardless of the task (NLP or Vision) or the specific data distribution. Experiments with random noise suggest that sparsity is a fundamental byproduct of the gradient-based optimization process rather than a simple adaptation to natural data statistics.

Scaling and Robustness

The degree of sparsity is strongly correlated with model scale. Larger models—those with more layers and wider hidden dimensions—exhibit significantly higher levels of sparsity than their smaller counterparts. For instance, T5-3B is consistently sparser than T5-Small across all layers.

Figure 3: Activation sparsity across different model scales and data settings. Larger models (e.g., T5-3B, ViT-H14) consistently show lower percentages of nonzero activations across their layers.

Beyond efficiency, enforcing sparsity via Top-k thresholding yields several benefits:

  • Robustness: Top-k models show superior performance when trained on noisy data (e.g., ImageNet with 80% corrupted labels).
  • Calibration: These models are less prone to overconfidence, showing improved Expected Calibration Error (ECE).
  • Efficiency: Sparsity in the second MLP layer allows for a direct reduction in FLOPs, potentially leading to significant wall-time speedups on specialized hardware.

Discussion and Limitations

While the theoretical potential for speedup is vast (often exceeding 90%), current hardware like GPUs and TPUs is optimized for dense matrix operations. Realizing these gains requires the development of efficient sparse kernels or hardware designed for unstructured sparsity. Additionally, while the second MLP layer is easily optimized, the first layer requires efficient Nearest Neighbor Search (NNS) techniques to avoid redundant computations. Future work will focus on these hardware-software co-design challenges and a more complete theoretical characterization of the training dynamics.

Summary updated

BibTeX
@inproceedings{li2023lazy,
  author = {Zonglin Li and Chong You and Srinadh Bhojanapalli and Daliang Li and Ankit Singh Rawat and Sashank J. Reddi and Ke Ye and Felix Chern and Felix Yu and Ruiqi Guo and Sanjiv Kumar},
  title = {{The Lazy Neuron Phenomenon: On Emergence of Activation Sparsity in Transformers}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=TJ2nxciYCk-},
}
Figure