Overview

5 Shaping model architectures via width pruning

Width pruning reshapes a transformer by trimming the MLP’s expansion layer rather than removing entire blocks, making it a more surgical alternative to depth pruning. The chapter shows how to reduce the intermediate width of GLU-based modules by identifying less useful neurons and rebuilding the affected layers so the model keeps its original input and output interfaces intact. It begins with a simple, static strategy that scores neuron pairs using the range of their weights in the gate and up projections, then keeps the most important pairs and copies their weights into smaller layers.

The results show that this kind of pruning can significantly cut parameters and speed up inference, but not without trade-offs. A 40% reduction in the expansion ratio removes a large portion of parameters while preserving depth, yet it sharply harms perplexity, reasoning, and broad knowledge tasks. At the same time, some behaviors improve unexpectedly: the pruned model becomes more concise, more instruction-following, and often less prone to confident hallucinations. This reveals that pruning does not simply make a model worse; it changes the balance of capabilities, sometimes favoring precision over creativity.

The chapter then advances to a data-driven method that combines structural weight information with real activation patterns gathered through PyTorch hooks. By capturing the L2 norm of activations at the input to the down projection during calibration, the pruning process can preserve neurons that are both structurally important and actually used by the chosen dataset. This makes it possible to create specialized variants, such as models better suited to WikiText or SMS, while retaining the same physical architecture and efficiency gains. The overall message is that width pruning is not just compression—it is a way to deliberately shape model behavior for a target domain and deployment constraint.

The complete GLU structure. Information enters with dimension hidden_size (2048 in Llama-3.2-1B) and expands to intermediate_size (8192) via gate_proj and up_proj. The gate_proj output, modulated by SiLU, is element-wise multiplied with up_proj’s output. The result is contracted back to hidden_size by down_proj.
Impact of width pruning on perplexity (PPL). Since this is a metric where "lower is better," the bars on the right show severe degradation: removing 40% of the expansion neurons causes perplexity to spike, indicating that the model has lost much of its ability to predict text sequences fluently.
Degradation across reasoning and knowledge benchmarks. Mathematical reasoning (GSM8K -68.9%) and common sense understanding (HellaSwag -41.3%) suffer the most severe losses, while reading comprehension tasks (BoolQ -1.9%, WinoGrande -4.8%) remain relatively stable.
Unexpected performance gains in instruction-following and truthfulness benchmarks. The pruned model dramatically improves at following precise instructions (IFEval +46.5%) and multi-step reasoning under constraints (MUSR +26.1%), while also becoming more truthful and less prone to generating plausible but incorrect answers (TruthfulQA +13.9% on MC2).
Hybrid importance calculation in GLU architecture. The static component combines weight ranges from gate_proj, up_proj, and down_proj. The dynamic component captures activation norms at the input of down_proj, where gated information flows. Both components multiply to produce the final importance score.
Hybrid importance combines structural capacity with activation patterns. Neuron [0] survives with moderate weights (0.9) but high activation (32). Neurons [1] and [2] are removed despite having identical or higher structural scores due to low activations (0.7 and 0.2).
Activation capture pipeline. The hooks registered in down_proj (1-2) are automatically triggered during the forward pass (3-4), intercept X_d, calculate L2 norms and accumulate them in CPU (5), finally returning an importance dictionary per layer (6-7).
Model surgery using hybrid importance. The update_model function (Listing 5.7) iterates over each layer (1-2), calls prune_neuron_pairs (3) that calculates hybrid scores by multiplying structural magnitudes by activation norms (4), selects the top-K neurons and creates new layers (5), replaces the original layers (6), and returns the specialized model (7).
The dichotomy visualized in Llama-3.2-3B. Panel A shows the progressive collapse of fragile capabilities (knowledge and reasoning) as the expansion ratio decreases. Panel B reveals the paradox: robust capabilities (instruction-following and truthfulness) improve dramatically, with IFEval reaching a peak of 174% of baseline at 1.6x expansion (40% pruning). Performance is normalized to the base model (2.67x expansion = 100%).

Summary

  • Our width pruning technique modifies LLMs by removing specific neurons from MLP expansion layers in GLU architectures, offering more fine-grained control than depth pruning's aggressive block elimination. This technique can reshape model behavior without destroying all capabilities.
  • In GLU architectures, the gate_proj and up_proj layers work as a synchronized pair. Neurons must be pruned simultaneously in both projections based on a combined importance score.
  • The reconstruction process creates new, smaller Linear layers while preserving connections with attention modules. By maintaining hidden_size dimensions at module boundaries, the surgery remains internal to the MLP block without breaking the Transformer architecture.
  • Data-driven neuron selection combines structural importance (weight magnitudes) with dynamic importance (activation norms). This hybrid approach multiplies a neuron's structural score by its actual usage during calibration, ensuring only neurons that are both structurally significant and actively used survive.
  • PyTorch hooks capture activations at down_proj's input, after the gating mechanism but before dimensionality reduction, using register_forward_hook(). The L2 norm measures activation intensity, rewarding specialist neurons with sharp peaks over those with constant low-level noise.
  • Domain-specialized models emerge from identical pruning percentages applied with different calibration data. A WikiText-calibrated model preserves neurons for formal text processing, while an SMS-calibrated model retains neurons for conversational language, despite sharing the same architecture externally.
  • The efficiency gains from width pruning are most visible in compute-bound scenarios.
  • Energy efficiency gains result from architectural changes, not behavioral modifications. However, width pruning's benefits are limited by the attention module bottleneck.
  • Aligning the resulting intermediate_size to be divisible by 64, 128, or 256 maximizes GPU Tensor Core utilization in compute-bound scenarios. This optimization matters most in production deployments with high traffic on modern GPUs (A100/H100).
  • Research papers "Fragile Knowledge, Robust Instruction-Following" (Martra, 2025) and "CFSP" (Wang et al., 2024) validate the dichotomy between degrading and improving capabilities, and the effectiveness of activation-based importance metrics. The practical implementation adapts their core insights into a simpler hybrid approach that combines structural capacity with dynamic usage.

FAQ

What is width pruning in an LLM?Width pruning is a structural optimization technique that reduces the model’s MLP expansion width by removing neurons from the intermediate layer. In this chapter, it is applied to the GLU-based MLP modules while keeping the model’s overall depth intact.
Why does this chapter focus on pruning the MLP width instead of the attention layers?The MLP width is easier to reduce without breaking the Transformer block’s external interfaces. By shrinking the intermediate_size inside the MLP, the model still outputs the same hidden_size expected by the next layers, so the architecture remains compatible.
How are neurons selected for static width pruning?Static pruning ranks neuron pairs using a magnitude-based importance score derived from the weight ranges of gate_proj and up_proj. Neurons with the smallest combined range are considered least expressive and are removed first.
Why must gate_proj and up_proj neurons be pruned together?In a GLU structure, gate_proj and up_proj work as a synchronized pair. If one neuron is removed from one projection, its counterpart must also be removed from the other, otherwise the gating mechanism becomes inconsistent and the MLP block is broken.
What is the role of down_proj in width pruning?down_proj contracts the expanded intermediate representation back to hidden_size. When pruning, its weights must be sliced to match the neurons kept in gate_proj and up_proj, preserving the input-output compatibility of the MLP block.
How is the hybrid, data-driven neuron selection different from static pruning?The hybrid method combines weight-based structural importance with activation norms captured from real calibration data. Instead of selecting neurons only by magnitude, it keeps neurons that are both structurally strong and actually active on the target dataset.
Why are PyTorch hooks used in the data-driven method?Hooks are used to capture activations during the forward pass without changing the model’s execution. In this chapter, they intercept the input to down_proj, compute L2 norms, and accumulate those values on the CPU for later neuron scoring.
Why is the L2 norm used for activation capture?The L2 norm measures activation intensity while avoiding cancellation effects that occur with simple sums. It also emphasizes stronger activation peaks, helping preserve neurons that are especially important for the calibration data.
What kind of behavioral changes can width pruning cause?Width pruning can reduce reasoning and broad knowledge performance while sometimes improving instruction-following, precision, and truthfulness. The chapter shows that pruning can make the model less creative but more constrained and focused.
What are the main practical benefits of width pruning?Width pruning can reduce parameter count, speed up inference, lower energy use, and specialize a model for a particular domain. It is especially useful when you want a smaller, more disciplined model for tasks like structured extraction, tool calling, or domain-specific generation.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Rearchitecting LLMs ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Rearchitecting LLMs ebook for free