Official codebase for the paper EVAR: Edge Visual Autoregressive Models via Principled Pruning (ECCV 2026).
EVAR combines:
- Pyramid-Aware Optimal Brain Surgeon (OBS) for structured pruning of VAR models
- Scale-aware distillation for post-pruning fine-tuning
.
βββ README.md
βββ requirements.txt
βββ models/ # Shared VAR / VQVAE model definitions
βββ utils/ # Shared training and data utilities
βββ prune/
β βββ prune.py # Main Pyramid-Aware OBS pruning entrypoint
β βββ pruning.bash # Example pruning launcher
β βββ evar_utils/
β βββ pyramid_aware_obs.py
βββ train/
βββ train.py # Standard VAR fine-tuning / training entrypoint
βββ trainer.py # Core trainer
βββ dist.py # Distributed training helpers
βββ distill/
βββ train_distill.py
βββ distillation_trainer.py
βββ distillation_losses.py
βββ distill_utils.py
βββ train_normal.bash
βββ train_aware.bash
βββ README.md
The pruning pipeline is implemented in:
prune/prune.pyprune/evar_utils/pyramid_aware_obs.py
Core idea:
- accumulate Hessian statistics over the VAR token pyramid,
- normalize each scale by its token count,
- upweight coarse scales to preserve global structure,
- apply OBS-style analytical compensation during structured pruning.
The distillation pipeline is implemented in:
train/distill/train_distill.pytrain/distill/distillation_trainer.pytrain/distill/distillation_losses.py
Supported distillation modes:
normalscale_awareboth
We recommend Python 3.10+ and CUDA-enabled PyTorch.
pip install -r requirements.txtDepending on your environment, you may need to install a CUDA-matched PyTorch build manually.
Before running pruning or training, prepare:
- a pretrained VQ-VAE checkpoint
- a pretrained VAR checkpoint or a pruned student checkpoint
- ImageNet data (or your compatible dataset layout)
Most scripts expose these paths through command-line arguments such as:
--vae_path/--vae_ckpt--var_path/--var_ckpt--teacher_model_path--data_path--imagenet_dir
Example:
cd prune
python prune.py \
--model_depth 16 \
--vae_ckpt /path/to/vae.pth \
--var_ckpt /path/to/var.pth \
--num_samples 5000 \
--sparsity 0.4 \
--use_images \
--imagenet_dir /path/to/imagenet \
--save_dir ./pruned_models \
--model_name evar_d16_0.4_pyramid_obs.pthOr use the provided launcher:
cd prune
bash pruning.bashExample:
cd train
torchrun --nproc_per_node=8 train.py \
--depth=16 \
--bs=256 \
--ep=40 \
--fp16=1 \
--var_path /path/to/pruned_student.pth \
--vae_path /path/to/vae.pth \
--data_path /path/to/imagenet \
--local_out_dir_path /path/to/outputExample scale-aware distillation:
cd train
torchrun --nproc_per_node=8 distill/train_distill.py \
--enable_distillation=1 \
--teacher_model_path /path/to/teacher.pth \
--teacher_depth 16 \
--distill_type scale_aware \
--depth=16 \
--bs=256 \
--ep=40 \
--fp16=1 \
--var_path /path/to/pruned_student.pth \
--vae_path /path/to/vae.pth \
--data_path /path/to/imagenet \
--local_out_dir_path /path/to/output| Model | Parameters | Pruning | FIDβ | ISβ | Precisionβ | Recallβ |
|---|---|---|---|---|---|---|
| VAR-d16 | 310M | - | 3.55 | 274.4 | 0.84 | 0.51 |
| EVAR (20%) | 270M | 20% | 3.67 | 267.5 | 0.81 | 0.51 |
| EVAR (40%) | 230M | 40% | 3.91 | 259.1 | 0.81 | 0.51 |
This project builds upon and references the following excellent works:
- VAR: Visual Autoregressive Modeling - Scalable Image Generation via Next-Scale Prediction
- DepGraph: Towards Any Structural Pruning
- Optimal Brain Compression: A Framework for Accurate Post-Training Quantization and Pruning
- SlimGPT: Layer-wise Structured Pruning for Large Language Models
We extend our gratitude to the authors for their outstanding contributions to the community.
This project is released under the MIT License. See the LICENSE file for details.
If you use this code, please cite the EVAR paper:
@inproceedings{wang2026evar,
title={EVAR: Edge Visual Autoregressive Models via Principled Pruning},
author={Wang, Zefang and Li, Ying and Li, Yanyu and Su, Mingluo and Xu, Simin and Tian, Guanzhong and Wang, Huan},
booktitle={ECCV},
year={2026}
}