File size: 20,284 Bytes
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
d58e062
baa0a0e
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
 
baa0a0e
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d58e062
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d58e062
baa0a0e
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85e2c6a
baa0a0e
 
 
85e2c6a
baa0a0e
 
 
 
 
85e2c6a
baa0a0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
---
license: other
license_name: qwen-research
license_link: LICENSE
base_model: Qwen/Qwen-Image-2.1-Turbo
base_model_relation: finetune
pipeline_tag: text-to-image
language:
  - en
tags:
  - qwen
  - qwen-image
  - text-to-image
  - image-generation
  - image-editing
  - decoder-free
  - vae-free
  - dwd
  - pruna-ai
---
<!-- header start -->
<p align="center">
  <img src="assets/P-Q-Image-2.1-DWD.jpg" width="800">
</p>
<!-- header end -->

<p align="center">
  <a href="https://github.com/PrunaAI/pruna">
    <img src="https://img.shields.io/badge/GitHub-PrunaAI-9334E9?style=plastic&logo=github&logoColor=white" alt="GitHub">
  </a>
  &nbsp;
  <a href="https://twitter.com/PrunaAI">
    <img src="https://img.shields.io/badge/Twitter%2FX-@PrunaAI-9334E9?style=plastic&logo=x&logoColor=white" alt="Twitter/X">
  </a>
  &nbsp;
  <a href="https://www.linkedin.com/company/pruna-ai">
    <img src="https://img.shields.io/badge/LinkedIn-PrunaAI-9334E9?style=plastic&logo=linkedin&logoColor=white" alt="LinkedIn">
  </a>
  &nbsp;
  <a href="https://discord.com/invite/JFQmtFKCjd">
    <img src="https://img.shields.io/badge/Discord-Join%20us-9334E9?style=plastic&logo=discord&logoColor=white" alt="Discord">
  </a>
  &nbsp;
  <a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=org_card&utm_campaign=hf_traffic">
    <img src="https://img.shields.io/badge/Performance%20Models-Try%20them%20now-9334E9?style=plastic&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MTEiIGhlaWdodD0iNDc3IiBmaWxsPSJub25lIj48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMjMuNzAzIDMwMC41MzJjLTEuODQyLS42NzQtNC4xNDItMS4wNTctNS43MDMtMi4wMjktMTIuNTU4LTcuODQ2LTguODM3LTI1LjE3MiA1LjI1NS0yOC4zNjFhLjY2LjY2IDAgMCAwIC4zNDgtLjIwMS42LjYgMCAwIDAgLjE1Ni0uMzZxNi40OS04MS45ODYgNjguNTc3LTEzNC42MjlhLjM0LjM0IDAgMCAwIC4wOTItLjEyNS4zMy4zMyAwIDAgMC0uMDI2LS4zLjMzLjMzIDAgMCAwLS4xMTItLjEwOGMtNC4xMTUtMi40OTctOC42NC00Ljc1LTEyLjM1My03LjQ0M2ExOTAgMTkwIDAgMCAxLTE4Ljc5NC0xNS41MjJjLTIuOTM2LTIuNzY4LTMuNzAzLTUuODkxLjU4LTcuNzdhLjUuNSAwIDAgMCAuMjgtLjYwOEM1MyA3NS45NSA0OC40MTcgNDguNTk5IDQ1LjUxOCAxOS42NXEtLjM5My0zLjg1Mi0uMjcxLTYuMzJhLjc1Ljc1IDAgMCAxIC4xMzQtLjQuNy43IDAgMCAxIC4zMjQtLjI1NXEyLjEwNC0uODQyIDUuODQ0LTEuNDMxYzU4LjExNC05LjEzN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4xMTgtMS45MjYgMjEuMzgzLTIuNjAzLjc3LS4xMjMgMS4zODUtLjE5OSAxLjg3OC0uMjM3LS4zNCAxMy44NDMtMTIuODkzIDI3LjcxLTI3Ljg2OCAyNy43MS0xNS4xNzIgMC0yNy44NzYtMTMuODM1LTI3Ljg3Ni0yOC44MTEgMC0uMzU3LjAyOS0uNTk2LjA1Ny0uNzQ0WiIvPjwvc3ZnPg==" alt="Performance Models">
  </a>
</p>
<div align="center">

<h1 style="color: #9334E9;">⚡ P-Q-Image-2.1-DWD</h1>

<h2>Qwen-Image-2.1-Turbo without the VAE decode</h2>

<h3>
  <span style="color: #9334E9;">No VAE decode</span>
  &nbsp;·&nbsp;
  <span style="color: #9334E9;">Up to 1.16x faster</span>
  &nbsp;·&nbsp;
  <span style="color: #9334E9;">24 GB less memory at 2K</span>
  &nbsp;·&nbsp;
  Text-to-image and image editing
</h3>

</div>

**Built with Qwen.**

**P-Q-Image-2.1-DWD** is a decoder-free pixel head for
[`Qwen/Qwen-Image-2.1-Turbo`](https://huggingface.co/Qwen/Qwen-Image-2.1-Turbo). At the end of the model's 8
sampling steps, a fine-tuned copy of the transformer's last 4 blocks and a small linear head write the image's pixels
directly, so the last Euler step and the VAE decode never run. Steps 1 to 7 are the stock model, unchanged. It is our
replication of DWD, *Decoding Without a Decoder* by Chen et al.
([arXiv 2611.22287](https://arxiv.org/abs/2611.22287)), on Qwen-Image-2.1-Turbo.

This repository holds the weights and the `pq_image_dwd` Python package for text-to-image and image editing. For
ComfyUI, see [PrunaAI/P-Q-Image-2.1-DWD-Comfy](https://huggingface.co/PrunaAI/P-Q-Image-2.1-DWD-Comfy).

| | |
|---|---|
| **Tasks** | Text-to-image and image editing (one or more condition images) |
| **Sampling** | The Turbo model's 8 steps, no CFG; the head replaces the last step |
| **Resolution** | Trained at about 1 MP; evaluated at about 1 MP and at the model's 2K sizes |
| **Weights** | `dwd_tail.safetensors`: 0.98B parameters, 1.95 GB (bf16) |
| **VAE** | Decoder not needed; the encoder is used for editing only |

## Quickstart

Needs a **CUDA GPU**. The base model is downloaded from
[`Qwen/Qwen-Image-2.1-Turbo`](https://huggingface.co/Qwen/Qwen-Image-2.1-Turbo) on first use (bf16 transformer
14.2 GB and text encoder 16.3 GB); the head adds 1.95 GB.

```bash
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/PrunaAI/P-Q-Image-2.1-DWD
cd P-Q-Image-2.1-DWD
pip install -e .
```

The package pins `diffusers==0.41.0` and `transformers==5.23.0`, the versions it was tested with, and needs
PyTorch 2.6 or newer (tested with 2.12.1).

```python
from PIL import Image
from pq_image_dwd import DWDPipeline

pipe = DWDPipeline.from_pretrained("PrunaAI/P-Q-Image-2.1-DWD")  # base: Qwen/Qwen-Image-2.1-Turbo

# Text-to-image
image = pipe("a red fox standing in fresh snow at sunrise", width=2048, height=2048, seed=0)
image.save("fox.png")

# Image editing
edited = pipe("Add gently falling snow to the whole scene.", image=Image.open("photo.jpg"), seed=0)
edited.save("snow.png")

# The stock VAE image for the same seed, for comparison (loads the VAE decoder)
dwd, vae = pipe("a red fox standing in fresh snow at sunrise", seed=0, return_vae=True)

# Optional: torch.compile the transformer blocks (one compile per resolution)
pipe.enable_compile()
```

Or from the command line:

```bash
python scripts/generate.py --prompt "a red fox standing in fresh snow at sunrise" --width 2048 --height 2048 --out fox.png
python scripts/generate.py --prompt "Add gently falling snow to the whole scene." --image photo.jpg --out snow.png
```

Add `--compare` to also write the stock VAE image as `<out>_vae.png`. Width and height must be multiples of 32.
Full options, the latency benchmark, the weight export and the tests are described in [docs/usage.md](docs/usage.md).

## Examples

Stock Qwen-Image-2.1-Turbo with its VAE decode next to P-Q-Image-2.1-DWD, with the same prompt and seed. Panels
are downscaled; the PSNR in each caption compares the two full-size images. Prompts, sizes and seeds are in
[assets/examples/examples.json](assets/examples/examples.json).

### Text-to-image at 2K

![Elderly fisherman portrait, VAE decode vs DWD head](assets/examples/t2i_0.jpg)

*"a close-up portrait of an elderly fisherman with a grey beard, soft window light, 85mm photo", 2048 × 2048, 34.7 dB*

![Bird of paradise flower, VAE decode vs DWD head](assets/examples/t2i_1.jpg)

*"bird of paradise flower", 2528 × 1696, 39.7 dB*

<table>
  <tr>
    <td width="55%"><img src="assets/examples/t2i_2.jpg" alt="Red fox in snow, VAE decode vs DWD head" width="100%"></td>
    <td width="45%"><img src="assets/examples/t2i_4.jpg" alt="Futuristic city street after rain, VAE decode vs DWD head" width="100%"></td>
  </tr>
  <tr>
    <td><em>"a red fox standing in fresh snow at sunrise, professional wildlife photograph", 1696 × 2528, 33.2 dB</em></td>
    <td><em>"a futuristic city street after rain with neon reflections, cinematic film still", 1536 × 2752, 35.4 dB</em></td>
  </tr>
</table>

![Ice cream shop, VAE decode vs DWD head](assets/examples/t2i_3.jpg)

*"a purple and white ice cream shop with a purple and white striped awning", 2752 × 1536, 34.7 dB*

![Stone wall with plants, VAE decode vs DWD head](assets/examples/t2i_5.jpg)

*"a stone wall with plants and flowers in it", 2048 × 2048, 29.7 dB: dense fine texture is where the head differs most*

### Image editing at 1 MP

Input, stock VAE image and DWD head image. The input images were generated with the stock model.

![Harbor turned into a watercolor](assets/examples/edit_0.jpg)

*"Turn this photo into a watercolor painting with soft washes and visible paper texture.", 1344 × 768, 31.2 dB*

![Living room as a vintage 1970s photograph](assets/examples/edit_1.jpg)

*"Make it look like a faded vintage 1970s photograph.", 1152 × 896, 33.3 dB*

![Lake with a red hot-air balloon added](assets/examples/edit_2.jpg)

*"Add a small red hot-air balloon in the upper part of the image.", 1024 × 1024, 31.3 dB*

![Tram street with falling snow](assets/examples/edit_3.jpg)

*"Add gently falling snow to the whole scene.", 896 × 1152, 33.0 dB*

### 1:1 crops

512 × 512 pixel crops at full resolution, stock VAE decode (left) vs DWD head (right).

<table>
  <tr>
    <td width="50%"><img src="assets/examples/crop_portrait.png" alt="Portrait crop" width="100%"></td>
    <td width="50%"><img src="assets/examples/crop_fox.png" alt="Fox fur crop" width="100%"></td>
  </tr>
  <tr>
    <td width="50%"><img src="assets/examples/crop_street.png" alt="City street crop" width="100%"></td>
    <td width="50%"><img src="assets/examples/crop_edit_snow.png" alt="Snow edit crop" width="100%"></td>
  </tr>
</table>

## Benchmark

### Speed

One NVIDIA B200, bf16, batch size 1, 8 steps, text-to-image. End to end: prompt encoding, the 8 steps and the decode,
until the uint8 image is on the host. Both paths run interleaved on the same GPU with the same code; median of 10
runs, and the saving is the median of paired differences with a bootstrap 95% interval. PyTorch 2.12.1 (CUDA 13.0),
diffusers 0.41.0, transformers 5.23.0. Measured with
[scripts/benchmark_latency.py](scripts/benchmark_latency.py); raw results in
[assets/benchmark.json](assets/benchmark.json).

| Mode | Resolution | With VAE decode | P-Q-Image-2.1-DWD | Saved (95% CI) | Speedup |
|---|---|---:|---:|---:|---:|
| eager | 1024 × 1024 | 767 ms | 696 ms | 67 ms (58–80) | **1.10x** |
| eager | 2048 × 2048 | 3500 ms | 3213 ms | 282 ms (273–298) | **1.09x** |
| `torch.compile` | 1024 × 1024 | 597 ms | 513 ms | 82 ms (78–88) | **1.16x** |
| `torch.compile` | 2048 × 2048 | 2797 ms | 2500 ms | 293 ms (290–310) | **1.12x** |

`torch.compile` compiles every transformer block (stock and tail); the VAE runs eager. The VAE decode alone takes
72 ms at 1024 × 1024 and 283 ms at 2048 × 2048. The DWD last step takes 87 ms and 407 ms (eager), against 160 ms and
691 ms for the stock last step plus the VAE decode. For reference, the diffusers `QwenImage21Pipeline` itself takes
796 ms and 3604 ms (eager) on the same GPU.

### Memory

Peak activation memory during one text-to-image run (peak allocated minus the resident weights), same setup:

| Mode | Resolution | With VAE decode | P-Q-Image-2.1-DWD |
|---|---|---:|---:|
| eager | 1024 × 1024 | 7.06 GB | **0.69 GB** |
| eager | 2048 × 2048 | 28.19 GB | **2.71 GB** |
| `torch.compile` | 1024 × 1024 | 9.21 GB | **2.53 GB** |
| `torch.compile` | 2048 × 2048 | 36.78 GB | **10.09 GB** |

Resident weights: transformer 14.23 GB and text encoder 16.29 GB (both needed either way), plus 1.95 GB for the
head; the 0.52 GB VAE decoder is not loaded (editing loads the 0.16 GB VAE encoder). Net, the peak at 2048 × 2048
eager is about 24 GB lower.

### Fidelity to the stock VAE image

Same prompt, seed and steps 1 to 7; the DWD image compared with the stock VAE image. 64 cases per set; the edit sets
are edits of real photos. Higher PSNR and lower LPIPS mean closer to the VAE image.

| Set | PSNR ↑ | LPIPS (VGG) ↓ | LPIPS (AlexNet) ↓ |
|---|---:|---:|---:|
| Text-to-image, 1 MP | 34.79 dB | 0.045 | 0.021 |
| Text-to-image, 2K | 35.93 dB | 0.046 | 0.018 |
| Editing, 1 MP | 35.30 dB | 0.048 | 0.029 |
| Editing, 2K | 36.50 dB | 0.057 | 0.033 |

Colour and tone stay with the VAE image; the main difference is in the finest texture, where the head is slightly
softer.

## How it works

- **Steps 1 to 7** run on the stock Qwen-Image-2.1-Turbo, unchanged: the same noise, sigmas, prefix KV cache and
  Euler updates as the stock pipeline, so every latent up to the last step is the stock one.
- **Last step.** The stock input embeddings and first 28 blocks run as usual. A fine-tuned copy of the last 4 blocks,
  with its own time embedding, modulation, and output norm, takes over on the whole sequence (text and condition-image
  tokens included).
- **Head.** A `Linear(4096 → 768)` turns each image token into a 16 × 16 pixel tile in normalized Oklab, which is
  converted to sRGB. No output projection, no last Euler step, no VAE decode.
- **Editing.** Condition images enter exactly as in the stock pipeline (VAE-encoded latents and Qwen3-VL image
  tokens), so editing needs the VAE encoder but never the decoder.
- **Training.** About 18,000 runs of the stock model at about 1 MP (16,000 text-to-image and 2,000 edits), with the
  stock VAE image of each run as the target. The released weights are an EMA, stored in bf16; they give exactly the
  images of the full-precision weights under bf16 autocast.

## Limitations

- **Close to, not identical with, the VAE image.** The head is slightly softer than the VAE in the finest texture;
  dense texture (stone, fur, foliage) differs most.
- **Heavy restyles can drift further.** Edits that re-texture the whole image strongly scored lower than the
  averages above in our spot checks (about 27 to 28 dB on crisp generated inputs).
- **RGB only.** The head outputs no alpha channel, so there is no transparency output.
- **Trained sizes.** Trained at about 1 MP and evaluated at 1024 × 1024, 1152 × 896, 896 × 1152, 1344 × 768,
  768 × 1344 and at 2048 × 2048, 2528 × 1696, 1696 × 2528, 2752 × 1536, 1536 × 2752. Other sizes run but were not
  evaluated. Width and height must be multiples of 32.
- **Turbo sampler only.** The head is trained for the last of the 8 Turbo steps. No CFG and no negative prompt.
- **LoRAs are untested.** A LoRA on the last 4 blocks, the time embedding, the modulation or the output norm will not
  carry over to the last step.
- **Benchmarked on one B200** with bf16 and batch size 1; speed and memory vary with hardware, resolution, batch
  size, and software.

## License

The end model is based on Qwen-Image-2.1-Turbo.

P-Q-Image-2.1-DWD is a derivative of Qwen-Image-2.1-Turbo and its weights (`dwd_tail.safetensors`) are
distributed under the **Qwen RESEARCH LICENSE AGREEMENT**, see [LICENSE](LICENSE) and [NOTICE](NOTICE). Review its use
restrictions before using or redistributing the weights.

The code in `src/`, `scripts/` and `tests/` is released under the Apache License 2.0, see
[LICENSE-APACHE](LICENSE-APACHE).

Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026
Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.

## Citation

If you use this model, please cite the DWD paper and this release.

```bibtex
@article{chen2026dwd,
  title   = {Decoding Without a Decoder: Direct Pixel Prediction from Diffusion Transformers},
  author  = {Chen, Hansheng and Cai, Shengqu and Ackermann, Jan and Zirvi, Rayhan and Wetzstein, Gordon
             and Yan, Xinchen and Guibas, Leonidas},
  journal = {arXiv preprint arXiv:2611.22287},
  year    = {2026}
}

@software{pruna2026pqimagedwd,
  title   = {P-Q-Image-2.1-DWD: Decoding Without a Decoder for Qwen-Image-2.1-Turbo},
  author  = {{Pruna AI}},
  year    = {2026},
  version = {0.1.0},
  url     = {https://huggingface.co/PrunaAI/P-Q-Image-2.1-DWD}
}
```

## What's next?

- **Use P-Q-Image-2.1-DWD to generate and edit images with Qwen-Image-2.1-Turbo without the VAE decode.**
- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a ⭐️ for more efficiency!
- Want to use our optimized image models right away? Check [P-Image-Ideogram](https://www.pruna.ai/p-image-ideogram) and [P-Image-Edit](https://www.pruna.ai/p-image-edit).

<style>
.model-button {
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;

  padding: 8px 20px;
  border: none;
  border-radius: 8px;

  background: #9334e9;
  color: #ffffff;

  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;

  box-sizing: border-box;
  overflow: visible;
  opacity: 1;
}
</style>

<a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=model_card&utm_campaign=hf_traffic" class="model-button">Try our models</a>