Text-to-Image
Diffusers
Safetensors
QwenImagePipeline
nvidia
ModelOpt
AutoModel
qwen-image
dmd2
few-step
jingyuX commited on
Commit
cbe1753
·
1 Parent(s): be31de3

Finalize Qwen-Image-Flash model card

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/qwen-image-flash-showcase.jpg filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -21,9 +21,13 @@ tags:
21
 
22
  ## Description:
23
 
24
- The NVIDIA Qwen-Image-Flash model generates images from text prompts using a four-step, DMD2-distilled version of [Qwen/Qwen-Image](https://huggingface.co/Qwen/Qwen-Image). The model was distilled using [NVIDIA Model Optimizer](https://github.com/NVIDIA/Model-Optimizer) and [NVIDIA AutoModel](https://github.com/NVIDIA-NeMo/Automodel) while retaining the base model architecture. The packaged scheduler is configured for the four-step, shift-3 trajectory.
25
 
26
- Qwen-Image-Flash is a full BF16 [Diffusers](https://github.com/huggingface/diffusers) pipeline. The checkpoint is designed for exactly four deterministic ODE/FlowMatch Euler transformer evaluations.
 
 
 
 
27
 
28
  This model is ready for commercial or non-commercial use.
29
 
@@ -94,9 +98,10 @@ Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated sys
94
 
95
  **Supported Runtime Engine(s):**
96
 
97
- - [Hugging Face Diffusers](https://github.com/huggingface/diffusers) 0.38.0
98
- - [PyTorch](https://pytorch.org/)
99
- - [Transformers](https://github.com/huggingface/transformers) 5.5.0
 
100
 
101
  **Supported Hardware Microarchitecture Compatibility:**
102
 
@@ -139,16 +144,16 @@ Qwen-Image-Flash was distilled with NVIDIA Model Optimizer 0.45.0.
139
 
140
  ## Evaluation Dataset:
141
 
142
- **Link:** MTBench, for more details, see [here](https://github.com/lm-sys/FastChat/tree/main/fastchat/llm_judge)
143
- **Data Collection Method by dataset:** Hybrid: Manually-collected, Synthetic
144
- **Labeling Method by dataset:** Hybrid: manually-labelled, Synthetic
145
- **Properties:** 3,300 multi-turn dialogue sequences.
146
 
147
  ## Inference:
148
 
149
- **Acceleration Engine:** Hugging Face Diffusers with PyTorch
150
 
151
- **Test Hardware:** NVIDIA Hopper H100
152
 
153
  ## DMD2 Distillation
154
 
@@ -158,102 +163,101 @@ The teacher target used classifier-free guidance (CFG) 4.0 during distillation.
158
 
159
  ## Usage
160
 
161
- Use Python 3.10 or newer and first install a CUDA-enabled PyTorch build compatible with the system's NVIDIA driver by following the [PyTorch installation instructions](https://pytorch.org/get-started/locally/). Then install the library versions used to produce and test the artifact, together with Accelerate and Safetensors:
162
 
163
- ```bash
164
- pip install "diffusers==0.38.0" "transformers==5.5.0" accelerate safetensors
165
- ```
166
 
167
  ```python
168
  import torch
169
  from diffusers import QwenImagePipeline
170
 
171
- model_id = "nvidia/Qwen-Image-Flash"
172
-
173
  pipe = QwenImagePipeline.from_pretrained(
174
- model_id,
175
  torch_dtype=torch.bfloat16,
176
  ).to("cuda")
177
 
178
- prompt = (
179
- 'A cinematic photograph of a small coffee shop. A chalkboard clearly reads '
180
- '"Qwen Coffee — open in a flash", detailed natural lighting, Ultra HD, 4K.'
181
- )
182
-
183
  image = pipe(
184
- prompt=prompt,
185
  width=1024,
186
  height=1024,
187
  num_inference_steps=4,
188
  true_cfg_scale=1.0,
 
 
189
  generator=torch.Generator(device="cuda").manual_seed(42),
190
  ).images[0]
191
 
192
- image.save("qwen-image-flash.png")
193
- ```
194
-
195
- For lower accelerator-memory use, construct the pipeline without `.to("cuda")`, then enable model CPU offload:
196
-
197
- ```python
198
- pipe = QwenImagePipeline.from_pretrained(
199
- model_id,
200
- torch_dtype=torch.bfloat16,
201
- )
202
- pipe.enable_model_cpu_offload()
203
  ```
204
 
205
- Model CPU offload still requires enough accelerator memory for the approximately 40.86 GB BF16 transformer plus activations. `pipe.enable_sequential_cpu_offload()` lowers accelerator-memory use further at the cost of additional transfer overhead and slower inference.
206
-
207
- **Required Inference Settings:**
208
-
209
- - Use `num_inference_steps=4`.
210
- - Use `true_cfg_scale=1.0` and omit `negative_prompt`; the student has already internalized the teacher's CFG target.
211
- - Keep the packaged static shift-3 scheduler and do not pass custom `sigmas`.
212
 
 
213
 
 
 
 
214
 
215
- ## Evaluation
216
 
217
- We report **acceptance length (AL)** — the mean number of tokens emitted per decoding step (the accepted draft tokens plus the one bonus token from the target model). Higher is better; with draft length *d* the maximum is *d*+1.
218
 
219
- Measurement setup: vLLM DFlash speculative decoding, greedy decoding (temperature 0), target `Qwen/Qwen-Image`, tensor-parallel 1 on **NVIDIA Hopper H100**. We list two draft lengths — **3** (for comparison with other published speculative-decoding cards) and **7** (DFlash `block_size` − 1, the recommended serving configuration).
 
 
 
220
 
221
- Acceptance length on [MT-Bench](https://huggingface.co/spaces/lmsys/mt-bench) (80 prompts):
 
 
 
 
222
 
 
223
 
224
- | Category | MT Bench Acceptance Rate |
225
- | ------------------- | ------------------------ |
226
- | writing | 2.93 |
227
- | roleplay | 2.54 |
228
- | reasoning | 3.09 |
229
- | math | 4.54 |
230
- | coding | 3.42 |
231
- | extraction | 4.13 |
232
- | stem | 2.77 |
233
- | humanities | 2.43 |
234
- | **Overall Average** | **3.23** |
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
- Acceptance length on [SPEED-Bench](https://huggingface.co/datasets/nvidia/SPEED-Bench) (qualitative subset, 880 prompts):
238
 
239
 
240
- | Category | SPEED-Bench Acceptance Rate |
241
- | ------------------- | --------------------------- |
242
- | coding | 3.46 |
243
- | humanities | 2.80 |
244
- | math | 3.29 |
245
- | multilingual | 4.01 |
246
- | qa | 2.94 |
247
- | rag | 3.74 |
248
- | reasoning | 3.31 |
249
- | roleplay | 2.34 |
250
- | stem | 2.88 |
251
- | summarization | 3.54 |
252
- | writing | 2.70 |
253
- | **Overall Average** | **3.18** |
254
 
 
255
 
 
256
 
 
 
 
 
 
257
 
258
  ## Ethical Considerations
259
 
 
21
 
22
  ## Description:
23
 
24
+ The NVIDIA Qwen-Image-Flash model generates images from text prompts using a four-step, DMD2-distilled version of [Qwen/Qwen-Image](https://huggingface.co/Qwen/Qwen-Image). The distillation used DMD2 from [NVIDIA FastGen](https://github.com/NVlabs/FastGen), [NVIDIA Model Optimizer](https://github.com/NVIDIA/Model-Optimizer), and [NVIDIA AutoModel](https://github.com/NVIDIA-NeMo/Automodel) while retaining the base model architecture. The packaged scheduler is configured for the four-step, shift-3 trajectory.
25
 
26
+ ## Showcase
27
+
28
+ ![Qwen-Image-Flash showcase](./assets/qwen-image-flash-showcase.jpg)
29
+
30
+ All showcase images were generated with [nvidia/Qwen-Image-Flash](https://huggingface.co/nvidia/Qwen-Image-Flash).
31
 
32
  This model is ready for commercial or non-commercial use.
33
 
 
98
 
99
  **Supported Runtime Engine(s):**
100
 
101
+ - [Hugging Face Diffusers](https://github.com/huggingface/diffusers) 0.38.0 with Transformers 5.12.1
102
+ - [SGLang Diffusion](https://github.com/sgl-project/sglang): `lmsysorg/sglang:nightly-dev-cu13-20260721-8905cbd4`
103
+ - [vLLM-Omni](https://github.com/vllm-project/vllm-omni): `vllm/vllm-omni:v0.24.0`
104
+ - [TensorRT-LLM VisualGen](https://github.com/NVIDIA/TensorRT-LLM): `nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc21`
105
 
106
  **Supported Hardware Microarchitecture Compatibility:**
107
 
 
144
 
145
  ## Evaluation Dataset:
146
 
147
+ **Link:** [Qwen-Image-Bench](https://arxiv.org/abs/2605.28091), [OneIG-Bench-EN](https://oneig-bench.github.io/)
148
+ **Data Collection Method by dataset:** Manually-collected
149
+ **Labeling Method by dataset:** Qwen-Image-Bench: Automated (Q-Judger with professional human supervision); OneIG-Bench-EN: Automated benchmark metrics
150
+ **Properties:** Qwen-Image-Bench: 1,000 prompts; OneIG-Bench-EN: 1,120 English prompts across five categories.
151
 
152
  ## Inference:
153
 
154
+ **Acceleration Engine:** Hugging Face Diffusers, SGLang Diffusion, vLLM-Omni, and TensorRT-LLM VisualGen
155
 
156
+ **Test Hardware:** NVIDIA GB200
157
 
158
  ## DMD2 Distillation
159
 
 
163
 
164
  ## Usage
165
 
166
+ ### Diffusers
167
 
168
+ **Tested container:** `vllm/vllm-omni:v0.24.0` (`diffusers==0.38.0`, `transformers==5.12.1`)
 
 
169
 
170
  ```python
171
  import torch
172
  from diffusers import QwenImagePipeline
173
 
 
 
174
  pipe = QwenImagePipeline.from_pretrained(
175
+ "nvidia/Qwen-Image-Flash",
176
  torch_dtype=torch.bfloat16,
177
  ).to("cuda")
178
 
 
 
 
 
 
179
  image = pipe(
180
+ prompt="A red fox in a snowy pine forest at golden hour, photorealistic, sharp focus, soft bokeh",
181
  width=1024,
182
  height=1024,
183
  num_inference_steps=4,
184
  true_cfg_scale=1.0,
185
+ guidance_scale=None,
186
+ negative_prompt=None,
187
  generator=torch.Generator(device="cuda").manual_seed(42),
188
  ).images[0]
189
 
190
+ image.save("qwen-image-flash-diffusers.png")
 
 
 
 
 
 
 
 
 
 
191
  ```
192
 
193
+ ### SGLang Diffusion
 
 
 
 
 
 
194
 
195
+ **Tested container:** `lmsysorg/sglang:nightly-dev-cu13-20260721-8905cbd4`
196
 
197
+ ```bash
198
+ docker run --rm --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -e HF_TOKEN -v qwen-image-hf-cache:/root/.cache/huggingface -v "$PWD:/workspace" -w /workspace lmsysorg/sglang:nightly-dev-cu13-20260721-8905cbd4 sglang generate --model-path nvidia/Qwen-Image-Flash --prompt "A red fox in a snowy pine forest at golden hour, photorealistic, sharp focus, soft bokeh" --width 1024 --height 1024 --num-inference-steps 4 --guidance-scale 1.0 --true-cfg-scale 1.0 --seed 42 --save-output --output-file-path qwen-image-flash-sglang.png
199
+ ```
200
 
201
+ ### vLLM-Omni
202
 
203
+ **Tested container:** `vllm/vllm-omni:v0.24.0`
204
 
205
+ ```bash
206
+ # Server
207
+ docker run --rm --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -e HF_TOKEN -p 8091:8091 -v qwen-image-hf-cache:/root/.cache/huggingface vllm/vllm-omni:v0.24.0 vllm serve nvidia/Qwen-Image-Flash --omni --host 0.0.0.0 --port 8091
208
+ ```
209
 
210
+ ```bash
211
+ # Client
212
+ curl -fsS http://127.0.0.1:8091/v1/images/generations -H 'Content-Type: application/json' -d '{"prompt":"A red fox in a snowy pine forest at golden hour, photorealistic, sharp focus, soft bokeh","n":1,"size":"1024x1024","response_format":"b64_json","num_inference_steps":4,"true_cfg_scale":1.0,"guidance_scale":1.0,"seed":42}' -o qwen-image-flash-vllm-omni-response.json
213
+ set -o pipefail; jq -er '.data[0].b64_json' qwen-image-flash-vllm-omni-response.json | base64 --decode > qwen-image-flash-vllm-omni.png
214
+ ```
215
 
216
+ ### TensorRT-LLM
217
 
218
+ **Tested container:** `nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc21`
 
 
 
 
 
 
 
 
 
 
219
 
220
+ ```python
221
+ from tensorrt_llm import VisualGen
222
+
223
+
224
+ def main():
225
+ visual_gen = VisualGen(model="nvidia/Qwen-Image-Flash")
226
+ try:
227
+ params = visual_gen.default_params
228
+ params.width = 1024
229
+ params.height = 1024
230
+ params.num_inference_steps = 4
231
+ params.guidance_scale = 1.0
232
+ params.negative_prompt = None
233
+ params.seed = 42
234
+
235
+ output = visual_gen.generate(
236
+ inputs="A red fox in a snowy pine forest at golden hour, photorealistic, sharp focus, soft bokeh",
237
+ params=params,
238
+ )
239
+ output.save("qwen-image-flash-tensorrt-llm.png")
240
+ finally:
241
+ visual_gen.shutdown()
242
+
243
+
244
+ if __name__ == "__main__":
245
+ main()
246
+ ```
247
 
 
248
 
249
 
250
+ ## Evaluation
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
+ The following results compare Qwen-Image-Flash with Qwen-Image and Qwen-Image-Lightning:
253
 
254
+ Evaluation was performed at 1024 × 1024 resolution on an NVIDIA B200 GPU.
255
 
256
+ | Model | [Qwen-Image-Bench](https://arxiv.org/abs/2605.28091) | [OneIG-Bench-EN](https://oneig-bench.github.io/) |
257
+ | --- | ---: | ---: |
258
+ | Qwen-Image | 49.070 | 0.886 |
259
+ | [Qwen-Image-Lightning](https://huggingface.co/lightx2v/Qwen-Image-Lightning) | 46.980 | 0.887 |
260
+ | **Qwen-Image-Flash (Ours)** | **47.080** | **0.885** |
261
 
262
  ## Ethical Considerations
263
 
assets/qwen-image-flash-showcase.jpg ADDED

Git LFS Details

  • SHA256: 5495fd114d2f94fe736da8aaacb31eeec56029a6eaf3752f4ceda902c049c580
  • Pointer size: 132 Bytes
  • Size of remote file: 3.76 MB