Update README.md
Browse files
README.md
CHANGED
@@ -1,16 +1,82 @@
|
|
1 |
---
|
2 |
license: other
|
3 |
license_name: flux-1-dev-non-commercial-license
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
language:
|
5 |
- en
|
6 |
base_model:
|
7 |
- black-forest-labs/FLUX.1-dev
|
8 |
-
|
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: other
|
3 |
license_name: flux-1-dev-non-commercial-license
|
4 |
+
tags:
|
5 |
+
- text-to-image
|
6 |
+
- SVDQuant
|
7 |
+
- FLUX.1-dev
|
8 |
+
- INT4
|
9 |
+
- FLUX.1
|
10 |
+
- Diffusion
|
11 |
language:
|
12 |
- en
|
13 |
base_model:
|
14 |
- black-forest-labs/FLUX.1-dev
|
15 |
+
pipeline_tag: text-to-image
|
16 |
+
datasets:
|
17 |
+
- mit-han-lab/svdquant-datasets
|
18 |
+
library_name: diffusers
|
19 |
---
|
20 |
|
21 |
+
<p align="center" style="border-radius: 10px">
|
22 |
+
<img src="https://github.com/mit-han-lab/nunchaku/raw/refs/heads/main/assets/logo.svg" width="50%" alt="logo"/>
|
23 |
+
</p>
|
24 |
+
<h4 style="display: flex; justify-content: center; align-items: center; text-align: center;">Quantization Library: <a href='https://github.com/mit-han-lab/deepcompressor'>DeepCompressor</a>   Inference Engine: <a href='https://github.com/mit-han-lab/nunchaku'>Nunchaku</a>
|
25 |
+
</h4>
|
26 |
+
|
27 |
+
|
28 |
+
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
|
29 |
+
<a href="https://arxiv.org/abs/2411.05007">[Paper]</a> 
|
30 |
+
<a href='https://github.com/mit-han-lab/nunchaku'>[Code]</a> 
|
31 |
+
<a href='https://hanlab.mit.edu/projects/svdquant'>[Website]</a> 
|
32 |
+
<a href='https://hanlab.mit.edu/blog/svdquant'>[Blog]</a>
|
33 |
+
</div>
|
34 |
+
![teaser](https://github.com/mit-han-lab/nunchaku/raw/refs/heads/main/assets/teaser.jpg)
|
35 |
+
SVDQuant is a post-training quantization technique for 4-bit weights and activations that well maintains visual fidelity. On 12B FLUX.1-dev, it achieves 3.6× memory reduction compared to the BF16 model. By eliminating CPU offloading, it offers 8.7× speedup over the 16-bit model when on a 16GB laptop 4090 GPU, 3× faster than the NF4 W4A16 baseline. On PixArt-∑, it demonstrates significantly superior visual quality over other W4A4 or even W4A8 baselines. "E2E" means the end-to-end latency including the text encoder and VAE decoder.
|
36 |
+
|
37 |
+
## Method
|
38 |
+
#### Quantization Method -- SVDQuant
|
39 |
+
|
40 |
+
![intuition](https://github.com/mit-han-lab/nunchaku/raw/refs/heads/main/assets/intuition.gif)
|
41 |
+
Overview of SVDQuant. Stage1: Originally, both the activation ***X*** and weights ***W*** contain outliers, making 4-bit quantization challenging. Stage 2: We migrate the outliers from activations to weights, resulting in the updated activation and weight. While the activation becomes easier to quantize, the weight now becomes more difficult. Stage 3: SVDQuant further decomposes the weight into a low-rank component and a residual with SVD. Thus, the quantization difficulty is alleviated by the low-rank branch, which runs at 16-bit precision.
|
42 |
+
|
43 |
+
#### Nunchaku Engine Design
|
44 |
+
|
45 |
+
![engine](https://github.com/mit-han-lab/nunchaku/raw/refs/heads/main/assets/engine.jpg) (a) Naïvely running low-rank branch with rank 32 will introduce 57% latency overhead due to extra read of 16-bit inputs in *Down Projection* and extra write of 16-bit outputs in *Up Projection*. Nunchaku optimizes this overhead with kernel fusion. (b) *Down Projection* and *Quantize* kernels use the same input, while *Up Projection* and *4-Bit Compute* kernels share the same output. To reduce data movement overhead, we fuse the first two and the latter two kernels together.
|
46 |
+
|
47 |
+
## Model Description
|
48 |
+
|
49 |
+
- **Developed by:** MIT, NVIDIA, CMU, Princeton, UC Berkeley, SJTU and Pika Labs
|
50 |
+
- **Model type:** INT W4A4 model
|
51 |
+
- **Model size:** 6.64GB
|
52 |
+
- **Model resolution:** The number of pixels need to be a multiple of 65,536.
|
53 |
+
- **License:** Apache-2.0
|
54 |
+
|
55 |
+
## Usage
|
56 |
+
|
57 |
+
### Diffusers
|
58 |
+
|
59 |
+
Please follow the instructions in [mit-han-lab/nunchaku](https://github.com/mit-han-lab/nunchaku) to set up the environment. Then you can run the model with
|
60 |
+
|
61 |
+
```python
|
62 |
+
import torch
|
63 |
+
|
64 |
+
from nunchaku.pipelines import flux as nunchaku_flux
|
65 |
+
|
66 |
+
pipeline = nunchaku_flux.from_pretrained(
|
67 |
+
"black-forest-labs/FLUX.1-dev",
|
68 |
+
torch_dtype=torch.bfloat16,
|
69 |
+
qmodel_path="mit-han-lab/svdq-int4-flux.1-dev", # download from Huggingface
|
70 |
+
).to("cuda")
|
71 |
+
image = pipeline("A cat holding a sign that says hello world", num_inference_steps=50, guidance_scale=3.5).images[0]
|
72 |
+
image.save("example.png")
|
73 |
+
```
|
74 |
+
|
75 |
+
### Comfy UI
|
76 |
+
|
77 |
+
Work in progress.
|
78 |
+
|
79 |
+
## Limitations
|
80 |
+
|
81 |
+
- The model is only runnable on NVIDIA GPUs with architectures sm_86 (Ampere: RTX 3090, A6000), sm_89 (Ada: RTX 4090), and sm_80 (A100). See this [issue](https://github.com/mit-han-lab/nunchaku/issues/1) for more details.
|
82 |
+
- You may observe some slight differences from the BF16 models in details.
|