Structured Pruning › Width Pruning
Language AI HandbookAll chapters Structured Pruning › Width PruningOne section · Sections in this chapter5 / 13 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Width pruning targets the internal dimensions of individual layers rather than removing entire heads or layers. In transformer feedforward sublayers, the input dimension is projected up to an intermediate dimension (often 4 times larger), passed through a nonlinearity, then projected back down. Width pruning removes neurons from this intermediate dimension, making the feedforward sublayer smaller while keeping the layer itself in the architecture.
Width pruning is more fine-grained than layer or head pruning, which allows you to tune the compression ratio with greater precision. Instead of choosing between keeping or removing an entire layer (which jumps the parameter count by a large discrete amount), you can remove neurons one at a time, finding the exact tradeoff between size and quality that meets your deployment constraints.
Feedforward Neuron Importance
For the feedforward sublayer, each intermediate neuron receives input from the first linear layer and sends output through the second. Neuron in the feedforward sublayer of layer has activation for input . A natural importance score is the mean absolute activation:
where:
- is the importance score for neuron in feedforward sublayer
- is the activation value of neuron for input after the first linear projection and nonlinearity
- is the expectation over the calibration dataset
Neurons that are consistently near zero contribute little to the computation. A threshold determines which neurons to remove: all neurons with are eliminated.
The choice of nonlinearity affects how well this criterion works. With ReLU activations, neurons that are dead (always outputting zero) have zero importance by definition. With GELU or SiLU activations, which are smooth and only approach zero asymptotically, you need the mean absolute activation criterion to identify low-importance neurons because no neuron is ever exactly zero. In modern language models that use GELU or SiLU, mean absolute activation is the standard criterion for feedforward width pruning.
The mechanics of width pruning are similar to head pruning. The first feedforward projection has its columns pruned, and the second projection has its rows pruned correspondingly. Removing neurons shrinks both matrices and reduces FLOPs proportionally. The bias terms (if present) must also be updated consistently: the bias of the first layer loses entries, and if the second layer has a bias, it remains unchanged in dimension because it is added to the -dimensional output rather than the intermediate dimension.
For models using gated linear units (such as the SwiGLU variant used in Llama), the feedforward sublayer has two parallel projections instead of one. Both projections must be pruned consistently: removing neuron requires removing column from both the gate projection and the value projection, and row from the output projection. The paired nature of gated feedforward layers means you need to be careful to prune both projections together.
Attention Head Width Pruning
Width pruning can also target the head dimension within attention heads. Rather than removing entire heads, you reduce the dimensionality of each head by eliminating less-important dimensions of the query, key, and value projections. This is a finer-grained form of pruning that allows more gradual size reduction.
For attention head , the query projection can be pruned by removing columns whose corresponding activations have low importance. The same columns must be removed from and to maintain dimensional consistency, and the corresponding rows from the output projection must also be removed. Note that the attention score computation divides by , so after reducing , you must update this scaling factor accordingly.
Head dimension pruning is less commonly applied in practice than feedforward width pruning because the attention head dimensions are already relatively small (often 64 or 128), and reducing them further tends to hurt quality more than removing entire low-importance heads. Feedforward neurons are more numerous and more unevenly used, making them better targets for width pruning.
Hidden Dimension Pruning
The most aggressive form of width pruning targets the model dimension itself, reducing the embedding size used throughout the entire model. This affects every weight matrix in the architecture simultaneously and requires careful identification of which dimensions to prune.
Principal component analysis on the activations at each layer can identify dimensions with low variance across inputs. These low-variance dimensions carry little information and are candidates for removal. You compute the covariance matrix of the activations across your calibration dataset, find the eigenvectors with the smallest eigenvalues, and remove the corresponding dimensions from all weight matrices simultaneously. This is related to the idea of intrinsic dimensionality: large language models often operate in a much lower-dimensional subspace than their nominal parameter count suggests.
Hidden dimension pruning is substantially harder to implement correctly than feedforward or head pruning because it requires coordinated changes to all weight matrices in the model. Every embedding matrix, every query, key, value, and output projection, every feedforward projection, and every layer normalization parameter must be updated. Small misalignments (for example, pruning the wrong corresponding rows and columns in two matrices) produce incorrect results without necessarily raising an obvious error. In practice, most practitioners use feedforward and head pruning rather than hidden dimension pruning because the former are safer to implement and still achieve substantial compression ratios.