NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ReplaceMe: Network Simplification via Depth Pruning and Transformer Block Linearization

Dmitriy Shopkhoev, Ammar Ali, Magauiya Zhussip, Valentin Malykh, Stamatios Lefkimmiatis, Nikos Komodakis, Sergey Zagoruyko

Large Language Models (LLMs) are transformative, but their sheer size makes them a nightmare to deploy on consumer hardware. While pruning—the process of removing redundant parts of a model—is a popular solution, "structured" pruning (removing entire layers) usually breaks the model's internal logic. To fix this, researchers typically rely on a "healing" process: expensive, time-consuming fine-tuning to recover lost performance.

The authors of ReplaceMe propose a radically different path. What if you didn't just delete layers, but replaced them with a simple mathematical "shortcut" that requires zero retraining?

The Problem with Traditional Pruning

Modern transformers are often "over-deep," containing layers that perform nearly identical operations. Depth pruning aims to remove these redundant layers to speed up inference and reduce memory usage.

However, simply yanking out layers creates a "jump" in the model's internal representations, leading to immediate performance collapse. Existing state-of-the-art methods like UIDL solve this by fine-tuning the remaining model (often using LoRA). This healing phase is computationally expensive, requires significant GPU time, and generates a substantial carbon footprint, making it inaccessible for many users. ReplaceMe seeks to achieve similar results with zero training.

The ReplaceMe Method

The ReplaceMe pipeline consists of three main steps designed to seamlessly bridge the gap left by removed layers:

  1. Layer Selection: The algorithm identifies a contiguous block of $n$ layers to remove. It does this by calculating the cosine distance between activations before and after potential "cuts" using a small calibration dataset. The goal is to find the "quietest" part of the model where removing layers causes the least disruption.
  2. Linearization: Instead of leaving a hole, ReplaceMe estimates an optimal linear transformation matrix that approximates what the removed blocks were doing. This matrix is calculated to minimize the distance between the output of the original block and the new shortcut.
  3. Weight Fusion: Because the shortcut is a simple linear operation, it can be algebraically merged into the weights of the preceding layer (specifically the MLP's down-projection).
The ReplaceMe architecture: replacing $n$ blocks with a single linear transform fused into the $i^*$-th block.

The result is a pruned model with fewer layers and a standard architecture, but with "smarter" weights that compensate for the missing pieces—all without adding any new parameters.

Key Insights

  • Transformers are "Secretly Linear": The core insight of ReplaceMe is that sequences of transformer blocks are often linear enough that a single matrix can mimic their behavior surprisingly well.
  • Cosine Distance is King: The paper finds that cosine distance is a far more effective metric for identifying redundant layers than standard Euclidean ($L_2$) distance. $L_2$ tends to focus on magnitude, while cosine distance captures the actual "meaning" or direction of the data.
  • Instruction Tuning Matters: For models that have been instruction-tuned, using instruction-style calibration data yields significantly better pruning results than using plain web text.
  • Scaling is Scaling: The method works better as models get larger. A 70B model can be pruned more aggressively than a 7B model while maintaining the same relative performance.

Key Results

ReplaceMe was validated across a wide range of models (including LLaMA-2, LLaMA-3, Qwen 2.5, and Falcon) and consistently outperformed other training-free methods, rivaling those that require expensive retraining.

  • Efficiency: Compared to the state-of-the-art UIDL (which requires healing), ReplaceMe is over 100x faster to apply and produces negligible CO2 emissions.
  • Performance: On models like Llama-2-7B, ReplaceMe (using Cosine distance) maintains 92.5% of baseline accuracy at a 25% compression rate, slightly outperforming UIDL's 90.3% despite requiring zero fine-tuning.
ReplaceMe achieves massive efficiency gains in time and emissions while maintaining competitive relative accuracy compared to UIDL.

Limitations and Future Work

While impressive, ReplaceMe isn't a silver bullet for extreme compression. Performance begins to drop more sharply once you prune more than ~25-30% of the model. For "extreme" pruning (e.g., 50%), some form of healing or fine-tuning remains necessary. Additionally, the authors noted a slight trade-off where regularization can improve benchmark accuracy but slightly hurt the model's perplexity.

Future directions include exploring non-consecutive layer pruning and more complex "non-linear" shortcuts that could still be fused into existing weights, potentially pushing the boundaries of training-free compression even further.

Summary updated

BibTeX
@inproceedings{shopkhoev2025replaceme,
  author = {Dmitriy Shopkhoev and Ammar Ali and Magauiya Zhussip and Valentin Malykh and Stamatios Lefkimmiatis and Nikos Komodakis and Sergey Zagoruyko},
  title = {{ReplaceMe: Network Simplification via Depth Pruning and Transformer Block Linearization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=zEj1FSYCRn},
}
Figure