🚀 svdq-int4-flux.1-depth-dev
svdq-int4-flux.1-depth-dev
是基于文本描述生成图像的模型,它以给定输入图像的结构为基础进行图像生成。该模型是 FLUX.1-Depth-dev
的 INT4 量化版本,可节省约 4 倍的内存,并且运行速度比原始的 BF16 模型快 2 - 3 倍。

✨ 主要特性
- 基于
FLUX.1-Depth-dev
进行 INT4 量化,节省约 4 倍内存。
- 运行速度比原始的 BF16 模型快 2 - 3 倍。
- 能够根据文本描述并结合给定输入图像的结构生成图像。
🔧 技术细节
量化方法 -- SVDQuant
SVDQuant 的概述:
- 阶段 1:最初,激活 X 和权重 W 都包含离群值,这使得 4 位量化具有挑战性。
- 阶段 2:将离群值从激活迁移到权重,得到更新后的激活和权重。此时激活更容易量化,而权重则变得更难量化。
- 阶段 3:SVDQuant 进一步使用奇异值分解(SVD)将权重分解为低秩分量和残差。这样,低秩分支以 16 位精度运行,从而缓解了量化难度。
Nunchaku 引擎设计

- (a)在 Down Projection 中额外读取 16 位输入以及在 Up Projection 中额外写入 16 位输出,会导致以秩 32 简单运行低秩分支时引入 57% 的延迟开销。Nunchaku 通过内核融合优化了这一开销。
- (b)Down Projection 和 Quantize 内核使用相同的输入,而 Up Projection 和 4 - Bit Compute 内核共享相同的输出。为了减少数据移动开销,将前两个和后两个内核融合在一起。
📦 安装指南
Diffusers
请按照 mit-han-lab/nunchaku 中的说明设置环境。此外,安装一些 ControlNet 依赖项:
pip install git+https://github.com/asomoza/image_gen_aux.git
pip install controlnet_aux mediapipe
📚 详细文档
模型描述
属性 |
详情 |
开发者 |
MIT、NVIDIA、CMU、普林斯顿大学、加州大学伯克利分校、上海交通大学和 Pika Labs |
模型类型 |
INT W4A4 模型 |
模型大小 |
6.64GB |
模型分辨率 |
像素数量需为 65,536 的倍数 |
许可证 |
Apache - 2.0 |
使用方法
Diffusers
设置好环境并安装依赖项后,你可以使用以下代码运行模型:
import torch
from diffusers import FluxControlPipeline
from diffusers.utils import load_image
from image_gen_aux import DepthPreprocessor
from nunchaku.models.transformer_flux import NunchakuFluxTransformer2dModel
transformer = NunchakuFluxTransformer2dModel.from_pretrained("mit-han-lab/svdq-int4-flux.1-depth-dev")
pipe = FluxControlPipeline.from_pretrained(
"black-forest-labs/FLUX.1-Depth-dev",
transformer=transformer,
torch_dtype=torch.bfloat16,
).to("cuda")
prompt = "A robot made of exotic candies and chocolates of different kinds. The background is filled with confetti and celebratory gifts."
control_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/robot.png")
processor = DepthPreprocessor.from_pretrained("LiheYoung/depth-anything-large-hf")
control_image = processor(control_image)[0].convert("RGB")
image = pipe(
prompt=prompt, control_image=control_image, height=1024, width=1024, num_inference_steps=30, guidance_scale=10.0
).images[0]
image.save("flux.1-depth-dev.png")
Comfy UI
正在开发中,敬请期待!
📄 许可证
本模型使用 Apache - 2.0 许可证。
引用
如果您发现此模型对您的研究有用,请引用以下文献:
@inproceedings{
li2024svdquant,
title={SVDQuant: Absorbing Outliers by Low-Rank Components for 4-Bit Diffusion Models},
author={Li*, Muyang and Lin*, Yujun and Zhang*, Zhekai and Cai, Tianle and Li, Xiuyu and Guo, Junxian and Xie, Enze and Meng, Chenlin and Zhu, Jun-Yan and Han, Song},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025}
}
⚠️ 重要提示
- 该模型仅可在具有 sm_86(安培架构:RTX 3090、A6000)、sm_89(阿达架构:RTX 4090)和 sm_80(A100)架构的 NVIDIA GPU 上运行。更多详细信息请参阅 此问题。
- 您可能会观察到与 BF16 模型在细节上存在一些细微差异。