🚀 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 模型在細節上存在一些細微差異。