Instructions to use wavespeed/Qwen-Image-e4m3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use wavespeed/Qwen-Image-e4m3 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("wavespeed/Qwen-Image-e4m3", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Add model card metadata: base_model, license, pipeline_tag, tags
Browse files
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen-Image
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
pipeline_tag: text-to-image
|
| 6 |
+
tags:
|
| 7 |
+
- qwen-image
|
| 8 |
+
- text-to-image
|
| 9 |
+
- quantized
|
| 10 |
+
- fp8
|
| 11 |
+
- e4m3
|
| 12 |
+
- diffusers
|
| 13 |
+
base_model_relation: quantized
|
| 14 |
+
---
|
| 15 |
+
# Qwen-Image-e4m3
|
| 16 |
+
|
| 17 |
+
FP8 (e4m3) dynamically-quantized [Qwen-Image](https://huggingface.co/Qwen/Qwen-Image),
|
| 18 |
+
saved as a complete `QwenImagePipeline`.
|
| 19 |
+
|
| 20 |
+
## What was changed
|
| 21 |
+
|
| 22 |
+
All 60 blocks of the `QwenImageTransformer2DModel` are quantized to
|
| 23 |
+
`e4m3_e4m3_dynamic` — `float8_e4m3fn` weights with dynamically scaled
|
| 24 |
+
`float8_e4m3fn` activations. The Qwen2.5-VL text encoder, the VAE and the
|
| 25 |
+
transformer's non-block tensors are untouched and stay in bf16. The transformer
|
| 26 |
+
drops from ~40.9 GB to ~20.5 GB.
|
| 27 |
+
|
| 28 |
+
Quantization was done with WaveSpeed's `xelerate.ao.quantize`. Weights are
|
| 29 |
+
stored as pickled `.bin` shards, so loading requires `use_safetensors=False`.
|
| 30 |
+
|
| 31 |
+
FP8 matmul needs Hopper (H100/H200) or newer to be faster than bf16; on older
|
| 32 |
+
GPUs the weights are dequantized on the fly and you only get the memory saving.
|
| 33 |
+
|
| 34 |
+
One caveat worth repeating from our own testing: on Qwen-Image, running fp8
|
| 35 |
+
*weight-and-activation* matmul under a fully fused fast path produces visible
|
| 36 |
+
quality loss. The configuration published here — dynamic per-tensor activation
|
| 37 |
+
scaling with bf16 accumulation — is the one that holds up.
|
| 38 |
+
|
| 39 |
+
## Usage
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import torch
|
| 43 |
+
from diffusers import QwenImagePipeline
|
| 44 |
+
|
| 45 |
+
pipe = QwenImagePipeline.from_pretrained(
|
| 46 |
+
"wavespeed/Qwen-Image-e4m3",
|
| 47 |
+
torch_dtype=torch.bfloat16,
|
| 48 |
+
use_safetensors=False,
|
| 49 |
+
).to("cuda")
|
| 50 |
+
|
| 51 |
+
image = pipe("a chalkboard menu written in neat cursive").images[0]
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## License
|
| 55 |
+
|
| 56 |
+
Apache-2.0, inherited from Qwen-Image.
|