Authors: Yang Zhang, Er Jin, Wenzhong Liang, Yanfei Dong, Ashkan Khakzar, Philip Torr, Johannes Stegmaier, Kenji Kawaguchi
Official implementation of ICLR2026 "Learnable Sparsity for Vision Generative Models" - a novel approach for memory efficient diffusion model pruning.
TL;DR: A model-agnostic structural pruning framework that achieves up to 20% parameter reduction with minimal performance loss through differentiable mask learning and time step gradient checkpointing.
Table of Contents
EcoDiff introduces a model-agnostic structural pruning framework that learns differentiable masks to sparsify diffusion models. Key innovations include:
- β¨ Model-agnostic pruning for various diffusion architectures
- π§ͺ Differentiable mask learning allowing end-to-end optimization
- π§΅ Time step gradient checkpointing for memory-efficient training
- π Up to 20% parameter reduction with minimal performance loss
- Python 3.10+
- Anaconda or Miniconda
- CUDA-compatible GPU
# Create conda environment
conda create -n sdib python=3.10 -y
conda activate sdib
# Clone repository
git clone https://github.com/your-repo/ecodiff.git
cd ecodiff
# Install dependencies
pip install -e .[core,loggers,test]Create a .env file:
PYTHON=/path/to/miniconda3/envs/sdib/bin/python
RESULTS_DIR=/path/to/ecodiff/results
CONFIG_DIR=/path/to/ecodiff/configs# SDXL pruning
make visual cfg=sdxl
# FLUX pruning
make visual cfg=flux# Generate configurations
python scripts/utils/hyperparameter_tuning.py --config configs/sdxl.yaml --task gen
# Run tuning
python scripts/utils/hyperparameter_tuning.py --task run --max_job 2# Semantic evaluation
python scripts/evaluation/semantic_eval.py -sp <checkpoint_path> --task all
# Mask analysis
python scripts/evaluation/binary_mask_eval.py --ckpt <checkpoint_path> -lt 0.001# Direct training script
python scripts/train.py
# Development/debugging mode
make visual cfg=sdxl
make visual cfg=flux# Generate configuration files
python scripts/utils/hyperparameter_tuning.py \
--config configs/sdxl.yaml \
--output_dir configs/param_sdxl_tuning \
-lr 0.1 0.2 \
-mask "hard_discrete" \
-re ".*" \
-lreg 1 0 \
-lrec 1 2 \
-b 0.1 0.01 \
-d 2 \
-pn sdxl_pruning \
--task gen
# Run tuning jobs
python scripts/utils/hyperparameter_tuning.py \
--output_dir configs/param_sdxl_tuning \
--task run \
--max_job 2# Generate semantic evaluation
python scripts/evaluation/semantic_eval.py -sp <checkpoint_path> --task gen
# Run all semantic evaluations
python scripts/evaluation/semantic_eval.py -sp <checkpoint_path> --task all
# Binary mask evaluation with threshold
python scripts/evaluation/binary_mask_eval.py --ckpt <checkpoint_path> -lt 0.001# SDXL LoRA fine-tuning
bash scripts/retraining/train_text_to_image_lora_sdxl.sh 30 0
# FLUX LoRA fine-tuning
bash scripts/retraining/train_text_to_image_lora_flux.sh 30 0python scripts/load_pruned_model.pyThe framework uses YAML configuration files located in the configs/ directory:
configs/
βββ dit.yaml # Diffusion Transformers configuration
βββ flux.yaml # FLUX.1 Schnell model configuration
βββ flux_dev.yaml # FLUX.1 Dev model configuration
βββ sd2.yaml # Stable Diffusion v2 configuration
βββ sd3.yaml # Stable Diffusion 3 configuration
βββ sdxl.yaml # Stable Diffusion XL configuration
For developers contributing to the project:
# Install development dependencies
pip install pre-commit && pre-commit install
# Run tests
make test
# Format code
make format
# Clean generated files
make cleansrc/sdib/- Core pruning frameworkscripts/- Training and evaluation scriptsconfigs/- Model configuration files
- SDXL: Stable Diffusion XL
- FLUX.1: FLUX diffusion models
These models are currently experimental implementations. They may require additional hyperparameter tuning for optimal performance.
- DiT: Diffusion Transformers
- SD2: Stable Diffusion v2
- SD3: Stable Diffusion 3
Pre-trained pruned models and retrained weights are available on HuggingFace:
| Model | Type | Link |
|---|---|---|
| SDXL | Pruned | EcoDiff-SDXL-Pruned |
| FLUX (Schnell & Dev) | Pruned | EcoDiff-FLUX-Pruned |
| SDXL | Retrained (Full & LoRA) | EcoDiff-SDXL-Retrain-Weights |
| FLUX | Retrained (LoRA) | EcoDiff-FLUX-Retrain-Weights |
@inproceedings{zhang2026learnable,
title={Learnable Sparsity for Vision Generative Models},
author={Zhang, Yang and Jin, Er and Liang, Wenzhong and Dong, Yanfei and Khakzar, Ashkan and Torr, Philip and Stegmaier, Johannes and Kawaguchi, Kenji},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=9pNWZLVZ4r}
}This project is licensed under the MIT License - see the LICENSE file for details.
- Built on Diffusers library
- Supports models from Stability AI and Black Forest Labs

