Mixed-precision quantization scheme (16/8/4bit mixed quantization) for the Wan2.2-Animate-14B model. Compresses the original 35GB base model to 17GB, balancing inference performance and model size.
This project is the quantization compression for the Wan-AI/Wan2.2-Animate-14B model. You need to download the code and pre-trained model in advance:
- Download the code: Wan2.2 repository
- Download the pre-trained model: Wan2.2-Animate-14B on Hugging Face
| Quantization Category | Specific Targets | 16/8/4bit Mixed Quantization (17.3G) | 16/8bit Mixed Quantization (18.3G) |
|---|---|---|---|
| 1. Image Branch Weights | cross_attn.k_img.weightcross_attn.v_img.weight |
4bit Quantization (with compensation + packing) |
8bit Quantization |
| 2. FFN Weights | blocks.*.ffn.0.weightblocks.*.ffn.2.weight |
8bit Quantization Biases: 16bit |
8bit Quantization Biases: 16bit |
| 3. KQV Attention Weights | All self_attn and cross_attn weights (except image branch) |
cross_attn.q, cross_attn.o → 16bitOthers → 8bit |
cross_attn.q, cross_attn.o → 16bitOthers → 8bit |
| 4. Face-Related Weights | face_encoder.*.weightface_adapter.*.weight |
8bit Quantization (except sensitive layers) |
8bit Quantization (except sensitive layers) |
| 5. All Other Weights | All weights not in above categories (modulation, norm, embedding, etc.) |
Keep 16bit | Keep 16bit |
- Image Branch Weights (only 2 layers):
- 16/8/4bit Scheme: 4bit quantization with statistical compensation and packing
- 16/8bit Scheme: Standard 8bit quantization
- Other Layers: Identical quantization strategies
- Compression Ratio: 34.5G → 17.3G (50% reduction) vs 34.5G → 18.3G (47% reduction)
- FFN Weights: 8bit for weights, 16bit for biases
- Shallow Q/O Layers:
cross_attn.qandcross_attn.oweights remain 16bit - Face Sensitive Layers: Specific sensitive weights remain 16bit
- All Biases: All bias terms remain 16bit
- Other Modules: All other components remain 16bit
Original Model (34.5G) | Mixed-Precision Quantized Model (17.3G)
Click the image to play the video
Original Model (34.5G) | Mixed-Precision Quantized Model (17.3G)
Click the image to play the video
- Download the original Wan2.2 repository:
git clone https://github.com/Wan-Video/Wan2.2.gitDownload the pre-trained Wan2.2-Animate-14B model from Hugging Face.
Replace the original files with our quantized versions:
# Replace animate.py with our quantized version
cp /animate.py Wan2.2/wan/animate.py
# Replace generate.py with our quantized version
cp /generate.py Wan2.2/generate.pyRun the 16/8/4bit mixed quantization script:
python quantization_with_4bit.pyThis will create a quantized/ folder in Wan2.2-Animate-14B/ containing:
quantized/
├── diffusion_pytorch_model-00001-of-00004.safetensors
├── diffusion_pytorch_model-00002-of-00004.safetensors
├── diffusion_pytorch_model-00003-of-00004.safetensors
├── diffusion_pytorch_model-00004-of-00004.safetensors
├── diffusion_pytorch_model.safetensors.index.json
├── advanced_quantization_info.json
└── quantization_info.jsonRun the 16/8bit mixed quantization script:
python quantization_with_8bit.pyThis will also create a quantized/ folder with the quantized model files.
After quantization, follow the original Wan2.2 instructions to generate videos. The quantized model will be automatically loaded.