Skip to content

Latest commit

Β 

History

69 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Uncovering the Redundancy in Transformers via a Unified Study of Layer Dropping

TMLR OpenReview arXiv Hugging Face Project Page License Python

Shwai He*, Guoheng Sun*, Zheyu Shen, Ang Li
CASE Lab, University of Maryland, College Park
* Equal contribution

🌐 Project Page β€’ πŸ† News & Awards β€’ 🌟 Highlights β€’ πŸ“ Taxonomy β€’ 🧰 Model Zoo β€’ βš™οΈ Installation β€’ πŸš€ Quickstart β€’ πŸ“Š Benchmarks β€’ πŸ“„ Citation


Note

This is the official repository for the paper Uncovering the Redundancy in Transformers via a Unified Study of Layer Dropping, published in Transactions on Machine Learning Research (TMLR 2026) (Early version: What Matters in Transformers? Not All Attention Is Needed).


πŸ† News & Recognition

  • [Feb 2026] πŸ“„ Published in Transactions on Machine Learning Research (TMLR 2026)!
  • [May 2025] πŸ† Won the Qualcomm Innovation Fellowship (QIF) North America 2025 for the proposal "Less Attention, Much Faster: Toward a Future of Efficiency-Optimized Transformer Architectures."
  • [Nov 2024] πŸš€ Added support for more foundation model families (Gemma-2, DeepSeek, Yi, Baichuan, Solar).
  • [Sep 2024] πŸ€— Released dropped-model checkpoints on Hugging Face.
  • [Jun 2024] πŸ’‘ Released initial arXiv preprint and complete codebase.

🌟 Key Highlights

  • ⚑ Significant Speedup & Memory Savings: Achieves up to 2.1Γ— inference speedup and over 40% KV cache memory reduction without requiring specialized hardware kernels.
  • 🧩 Unified Dropping Taxonomy: Systematically dissects and compares Block Drop, Attention-Layer Drop, MLP-Layer Drop, and Joint Layer Drop under a standardized framework.
  • 🎯 High Performance Retention: Retains >95–98% of core reasoning and general language capabilities (MMLU, GSM8K, ARC-c, HellaSwag) through importance-aware layer selection.
  • πŸ—œοΈ Orthogonal Quantization Synergy: Easily pairs with post-training 4-bit quantization (AWQ / GPTQ) for compounding latency and memory benefits.
  • πŸ”Œ Plug-and-Play Hugging Face Integration: Output models use standard auto_map configurations for seamless loading via AutoModelForCausalLM.

πŸ“– Overview

Standard Transformer architectures treat every layer and sublayer identically throughout the network depth. However, deep representations exhibit profound asymmetric redundancy:

  1. Attention Redundancy vs. MLP Redundancy: In deeper layers, attention mechanisms often collapse into static routing patterns, whereas MLPs continue to perform knowledge retrieval and feature transformation.
  2. Sublayer Granularity: Dropping full blocks can cause catastrophic representational collapse; in contrast, selectively dropping attention or MLP sublayers provides fine-grained Pareto-optimal compression frontiers.

LLM-Drop Unified Framework
Figure: Overview of LLM-Drop framework showing Block Drop, Sublayer Drop (Attention / MLP), Joint Dropping, and Quantization.


πŸ“ Methodology & Taxonomy

Strategy Dropped Components Target Redundancy Memory / KV Cache Saving Latency Speedup Recommended Use Case
Block Drop Full Transformer Block (MHA + MLP) Inter-block similarity 🟒 High (Weights + KV) πŸš€ High High-throughput batch serving
Attention Drop Self-Attention / MHA Layers Redundant query-key routing ⚑ 40%+ KV Cache ⚑ High (Prefill & Decode) Long-context & memory-bound generation
MLP Drop Feed-Forward (FFN/MLP) Layers Parameter/computation bloat 🟒 High (Weight footprint) πŸš€ High (Compute-heavy) Compute-bound environments
Joint Layer Drop Hybrid Attention + MLP schedule Compound depth redundancy πŸ”₯ Maximum flexibility ⚑ Best Pareto curve Custom hardware budget constraints
Drop + Quant Dropped model + 4-bit AWQ/GPTQ Intra- & Inter-layer redundancy πŸ’Ž Ultra-compact πŸ”₯ Maximum efficiency Edge & on-device deployment

🧰 Model Zoo & Checkpoints

Pre-dropped model checkpoints are available in our Hugging Face Collection:

Model Base Dropping Configuration Hugging Face Checkpoint Base Size Dropped Size
Mistral-7B-v0.1 Attention-Drop (4 Attn dropped) LLM-Drop/Mistral-7B-drop-attn4 7.2B ~6.5B
Mistral-7B-v0.1 MLP-Drop (4 MLP dropped) LLM-Drop/Mistral-7B-drop-mlp4 7.2B ~5.8B
Mistral-7B-v0.1 Block-Drop (4 Blocks dropped) LLM-Drop/Mistral-7B-drop-block4 7.2B ~5.1B
Llama-2-7B Joint-Drop (6 Attn + 2 MLP) LLM-Drop/Llama-2-7B-joint-drop 6.7B ~5.3B
Llama-3-8B Attention-Drop (4 Attn dropped) LLM-Drop/Llama-3-8B-drop-attn4 8.0B ~7.2B
Gemma-2-9B Attention-Drop (6 Attn dropped) LLM-Drop/Gemma-2-9B-drop-attn6 9.2B ~8.1B
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load directly from Hugging Face with trust_remote_code
model_id = "LLM-Drop/Mistral-7B-drop-attn4"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True, device_map="auto")

βš™οΈ Installation

# 1. Create and activate a clean conda environment
conda create -n llm-drop python=3.10 -y
conda activate llm-drop

# 2. Clone the repository
git clone https://github.com/CASE-Lab-UMD/LLM-Drop.git
cd LLM-Drop

# 3. Install core dependencies and LLM-Drop package
pip install -e .
pip install flash-attn --no-build-isolation

# 4. Optional: Install Quantization dependencies (AutoAWQ & AutoGPTQ)
cd src/llmtuner/compression/quantization/AutoAWQ
pip install -e .
cd AutoAWQ_kernels && pip install -e . && cd ..

cd ../AutoGPTQ
pip install -vvv --no-build-isolation -e .
cd ../../../../..

πŸš€ Quickstart & Usage

1️⃣ Model Configuration Setup

To load dropped models with standard Hugging Face AutoModelForCausalLM, add the auto_map and drop lists to config.json:

{
  "drop_mlp_list": [],
  "drop_attn_list": [25, 26, 24, 22],
  "auto_map": {
    "AutoConfig": "configuration_dropped_mistral.MistralConfig",
    "AutoModelForCausalLM": "modeling_dropped_mistral.MistralForCausalLM"
  }
}

Drop list formats:

  • Drop Attention Layers: "drop_mlp_list": [], "drop_attn_list": [25, 26, 24, 22]
  • Drop MLP Layers: "drop_mlp_list": [26, 27, 25, 24], "drop_attn_list": []
  • Drop Full Blocks: "drop_mlp_list": [26, 25, 24, 27], "drop_attn_list": [26, 25, 24, 27]

2️⃣ Run Dropping Pipelines

# Block Dropping
bash scripts/dropping/block_drop.sh

# Sublayer Dropping (Attention or MLP)
bash scripts/dropping/layer_drop.sh

# Joint Layer Dropping
bash scripts/dropping/layer_drop_joint.sh

# Iterative Dropping
bash scripts/dropping/layer_drop_iterative.sh

3️⃣ Benchmark Task Performance

Evaluate dropped checkpoints on standard NLP and reasoning benchmarks with EleutherAI/lm-evaluation-harness:

bash scripts/benchmark/benchmark_lm_eval.sh

4️⃣ Measure Speed & KV Cache Savings

bash scripts/benchmark/benchmark_speed.sh

5️⃣ Post-Training Quantization (AWQ / GPTQ)

# 4-bit AWQ Quantization on Dropped Model
bash scripts/quantization/awq.sh

# 4-bit GPTQ Quantization on Dropped Model
bash scripts/quantization/gptq.sh

πŸ“Š Benchmark Results

Mistral-7B-v0.1 Dropping Performance

Model Variant Strategy # Dropped MMLU (5-shot) GSM8K (8-shot) ARC-c (25-shot) HellaSwag (10-shot) Relative Speedup KV Cache Saving
Dense Base β€” 0 64.2% 37.8% 60.1% 83.3% 1.00Γ— 0%
LLM-Drop (Attn) Attention Drop 4 63.8% 37.1% 59.6% 82.9% 1.22Γ— -12.5%
LLM-Drop (Attn) Attention Drop 8 62.5% 35.4% 58.2% 81.7% 1.45Γ— -25.0%
LLM-Drop (MLP) MLP Drop 4 63.1% 36.2% 58.9% 82.4% 1.28Γ— 0%
LLM-Drop (Block) Block Drop 4 62.7% 35.0% 58.4% 81.9% 1.32Γ— -12.5%
LLM-Drop + AWQ-4b Attn Drop + AWQ 4 Attn 63.2% 36.5% 59.0% 82.1% 2.14Γ— -12.5%

πŸ“¦ Repository Layout

LLM-Drop/
β”œβ”€β”€ docs/                   # GitHub Pages project website
β”‚   β”œβ”€β”€ index.html          # Interactive project homepage
β”‚   └── static/images/      # Figures and SVG assets
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ dropping/           # Block, layer, joint & iterative dropping scripts
β”‚   β”œβ”€β”€ benchmark/          # LM-Eval & inference speed benchmarks
β”‚   └── quantization/       # AWQ and GPTQ quantization scripts
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ compress.py         # Main entry point for importance estimation & dropping
β”‚   β”œβ”€β”€ benchmark_speed.py  # Inference latency & throughput measurement
β”‚   └── llmtuner/           # Core model definitions, dropping modules & pruning
β”œβ”€β”€ Layer_Drop.svg          # Architectural overview diagram
β”œβ”€β”€ setup.py                # Package setup script
└── requirements.txt        # Base dependencies

πŸ“„ Citation

If you find this work, repository, or released checkpoints helpful in your research, please cite our papers:

@article{he2026uncovering,
  title={Uncovering the Redundancy in Transformers via a Unified Study of Layer Dropping},
  author={He, Shwai and Sun, Guoheng and Shen, Zheyu and Li, Ang},
  journal={Transactions on Machine Learning Research},
  issn={2835-8856},
  year={2026},
  url={https://openreview.net/forum?id=1I7PCbOPfe}
}

@article{he2024what,
  title={What Matters in Transformers? Not All Attention Is Needed},
  author={He, Shwai and Sun, Guoheng and Shen, Zheyu and Li, Ang},
  journal={arXiv preprint arXiv:2406.15786},
  year={2024}
}

πŸ“¬ Contact & Support

For questions, collaborations, or issues:

About

The official implementation of the paper "Uncovering the Redundancy in Transformers via a Unified Study of Layer Dropping (TMLR)".

Topics

Resources

Security policy

Stars

191 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages