This repository contains code for the paper Compressing LLMs with MoP: Mixture of pruners. Models are available at: https://huggingface.co/collections/c2d-usp/compressing-llms-with-mop-mixture-of-pruners
MoP (Mixture of Pruners) is a method that combines the strengths of both depth and width pruning to reduce the size of large language and vision-language models while also speeding-up inference.
Comparison between the original (unpruned) LLaVA-1.5 (7.06B parameters) and the pruned version using MoP (5.71B parameters):
demo_llava_mop.mp4
Comparison between the original (unpruned) LLaMA-3-8B and the 40% pruned version using MoP (4.74B parameters):
demo_llama3_mop.mp4
This repo is split into three independent folders:
Llama2/: LLaMA-2 experimentsLlama3/: LLaMA-3 experimentsLlava/: LLaVA experiments
Each folder is self-contained (scripts, pruning code, and outputs live inside that folder).
MoP consists of three steps:
- Pruning
- Recovery fine-tuning
- Evaluation (EleutherAI LM Evaluation Harness,
lm_eval, installed viarequirements.txt)
Ready-to-run bash scripts.
- Full MoP pipeline (runs all iterations up to 18: pruning → recovery fine-tuning → evaluation):
bash Llama2/run_mop_llama2.sh
- Extremes / baselines (single-path pruning instead of mixing; e.g., only depth or only width):
bash Llama2/run_extremes_llama2.sh
- Minimal script (faster run to reproduce only the 20% and 30% compression points):
bash Llama3/run_mop_llama3_minimal.sh
- Full MoP pipeline (runs all iterations up to 18: pruning → recovery fine-tuning → evaluation):
bash Llama3/run_mop_llama3.sh
- Extremes / baselines (single-path pruning instead of mixing):
bash Llama3/run_extremes_llama3.sh
GPU (or equivalent) with at least 24GB of VRAM. Pruning should take just a few minutes, and the fine-tuning of a single model checkpoint takes about 2 hours on an RTX 4090.
We thank Instituto de Ciência e Tecnologia Itaú (ICTi) for the technical support, resources, and financial aid in the development of the research project. The authors would also like to thank the Programa de Bolsas Itaú (PBI) of the Centro de Ciência de Dados (C2D), supported by Itaú Unibanco S.A.