GitHub   Twitter/X   LinkedIn   Discord   Performance Models

⚑ P-Flux-2-Klein-4B-DWD

FLUX.2 [klein] 4B without a VAE decoder

Up to 1.35x faster at 1 MP  Β·  No VAE decode  Β·  4 steps  Β·  Text-to-image

P-Flux-2-Klein-4B-DWD is FLUX.2 [klein] 4B with a decoder-free head. A fine-tuned copy of the transformer's last 4 blocks and a small linear head write the image's pixels directly at the last sampling step, so the VAE decoder never runs. It is a replication of DWD, Decoding Without a Decoder: Direct Pixel Prediction from Diffusion Transformers (Chen et al., 2026). The text encoder, the first 21 transformer blocks and the 4-step schedule are the base model's.

This repository holds the Python pipeline, the trained weights and the full training code. For ComfyUI, see PrunaAI/P-Flux-2-Klein-4B-DWD-Comfy.

Task Text-to-image
Sampling 4 steps, no CFG, same schedule as FLUX.2 [klein] 4B
Decode A linear pixel head at the last step; no VAE is downloaded or run
Resolution About 1 MP, five trained sizes from 1344 Γ— 768 to 768 Γ— 1344
Weights dwd_tail.safetensors: 0.55B-parameter tail and head, 1.1 GB in bf16. The rest comes from the base model
Speed 1.35x faster end to end (eager) and 1.20x (torch.compile) at 1024 Γ— 1024 on one B200

Quickstart

Needs a CUDA GPU. Clone the repository without its large files, then install the code. The trained tail is downloaded into the Hugging Face cache on first use, and the base model from black-forest-labs/FLUX.2-klein-4B, without its VAE.

GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/PrunaAI/P-Flux-2-Klein-4B-DWD
pip install ./P-Flux-2-Klein-4B-DWD
from dwd_klein.pipeline import DWDKleinPipeline

pipe = DWDKleinPipeline.from_pretrained("PrunaAI/P-Flux-2-Klein-4B-DWD")
image = pipe("a red fox in fresh snow at sunrise", width=1024, height=1024, seed=0)
image.save("fox.png")

pipe.enable_compile()   # optional: torch.compile, one compile per resolution

Or from the command line, inside the clone:

python scripts/generate.py --prompt "a red fox in fresh snow at sunrise" --out fox.png

Width and height must be multiples of 16. Use one of the trained sizes (width Γ— height): 1024 Γ— 1024, 1152 Γ— 896, 896 Γ— 1152, 1344 Γ— 768 or 768 Γ— 1344. The pipeline is DWDKleinPipeline; the stock diffusers Flux2KleinPipeline cannot load this tail. Full usage, training and evaluation docs are in docs/usage.md.

Examples

Same prompt and seed (seed 0 for every prompt, not cherry-picked), one image at each of the five trained sizes. Left: the stock model with its VAE decode. Right: P-Flux-2-Klein-4B-DWD, with no VAE.

FLUX.2 [klein] 4B (VAE decode) ⚑ P-Flux-2-Klein-4B-DWD (no VAE)
portrait, FLUX.2 [klein] 4B with VAE decode portrait, P-Flux-2-Klein-4B-DWD
sign, FLUX.2 [klein] 4B with VAE decode sign, P-Flux-2-Klein-4B-DWD
fox, FLUX.2 [klein] 4B with VAE decode fox, P-Flux-2-Klein-4B-DWD
street, FLUX.2 [klein] 4B with VAE decode street, P-Flux-2-Klein-4B-DWD
food, FLUX.2 [klein] 4B with VAE decode food, P-Flux-2-Klein-4B-DWD
cabin, FLUX.2 [klein] 4B with VAE decode cabin, P-Flux-2-Klein-4B-DWD

The misspelled sign comes from the base model; the VAE image has it too.

A 100% crop of the portrait (384 Γ— 384 pixels, same window):

FLUX.2 [klein] 4B (VAE decode) ⚑ P-Flux-2-Klein-4B-DWD (no VAE)
portrait crop, VAE decode portrait crop, P-Flux-2-Klein-4B-DWD

Fine texture is slightly softer than with the VAE decode.

Prompts
  • 1024 Γ— 1024: a close-up portrait of an elderly fisherman with a weathered face and a grey beard, soft window light, 85mm photograph
  • 1344 Γ— 768: a hand-painted wooden storefront sign that reads "FRESH BREAD" above the door of a small village bakery, morning light
  • 1152 Γ— 896: a red fox standing in fresh snow at sunrise, professional wildlife photograph
  • 768 Γ— 1344: a narrow street in Lisbon with yellow tram, tiled facades and laundry hanging from balconies, golden hour
  • 1024 Γ— 1024: a bowl of ramen with a soft-boiled egg, sliced pork, spring onions and nori, overhead food photograph on a dark wooden table
  • 896 Γ— 1152: a cozy wooden cabin by a mountain lake at dusk, warm light in the windows, reflections on the water

Benchmark

Speed and memory

One NVIDIA B200, bf16, batch size 1, 4 steps. Timed end to end: the full Qwen3 text encoder (as the stock pipeline runs it), 4 transformer steps and the decode, until the uint8 image is on the host. Both paths run interleaved on the same GPU with the same code (scripts/benchmark_latency.py).

Mode Resolution With VAE decode P-Flux-2-Klein-4B-DWD Speedup
eager 1024 Γ— 1024 316 ms 234 ms 1.35x
eager 1440 Γ— 1440* 625 ms 453 ms 1.38x
torch.compile 1024 Γ— 1024 186 ms 155 ms 1.20x
torch.compile 1440 Γ— 1440* 358 ms 291 ms 1.23x

* Outside the trained sizes; listed for speed only.

The VAE decode alone takes 81 ms eager and 25 ms compiled; the head and the Oklab-to-sRGB conversion take about 0.5 ms. All 4 transformer steps still run, so the saving is the decode. Peak activation memory is about 2 GB lower at 1 MP.

Fidelity

64 prompts (curated prompts and held-out captions) across the five trained sizes, and 32 held-out real photos. LPIPS uses VGG features.

Comparison PSNR ↑ LPIPS (VGG) ↓
P-Flux-2-Klein-4B-DWD vs the stock VAE image, same prompt and seed (64 prompts) 25.5 dB 0.137
Held-out photos, last-step denoising: DWD head vs the real photo 22.2 dB 0.289
Held-out photos, last-step denoising: base model + VAE decode vs the real photo 20.9 dB 0.316

The first row shows how close the output stays to the stock model's image: close, not identical, and the VAE image can be sharper in fine detail. The last two rows noise each held-out photo to the noise level of the final sampling step and compare one final step with the real photo: the DWD head recovers it more closely than the base model's last step followed by the VAE decode. This measures a single step on real photos, not the detail of generated images.

How it works

FLUX.2 [klein] 4B has 5 double-stream and 20 single-stream blocks.

Part In P-Flux-2-Klein-4B-DWD
Text encoder (Qwen3), double blocks, single blocks 0-15 Unchanged, bit-identical to the base model
Single blocks 16-19, their own copies of the time embedding and single-block modulation, norm_out, proj_out Fine-tuned (the "tail")
DWD head: Linear(3072 β†’ 768) on the norm_out image tokens New
VAE decoder Not used

Each image token becomes one 16 Γ— 16 pixel patch in normalized Oklab (3 Γ— 16 Γ— 16 = 768 values), which is converted to sRGB. Steps 0-2 of the 4-step sampler use the tail's velocity as usual. At step 3 the head output is the image: no final Euler update and no VAE decode.

Training. The head output is trained against the clean image with L1, LPIPS (VGG) and an adaptive adversarial loss (a DINO ViT-S/8 discriminator on random crops, with DiffAugment). A trajectory loss keeps the tail's velocity at high noise levels close to the base model's, so steps 0-2 follow the original sampling path. The head starts from a least-squares fit, and the released weights are a Karras power EMA after 26k iterations at global batch 128, on about 420k real images of 1 MP or more across five aspect buckets.

Train your own

The full recipe is included: data preparation, training, evaluation, export and the latency benchmark. Install the clone with the training extras:

cd P-Flux-2-Klein-4B-DWD
pip install -e ".[train]"
# 1. Bucketed tar shards from your own image + caption pairs (cat.jpg + cat.txt)
python scripts/prepare_data.py --images ./my_images --out ./data

# 2. Train, one process per GPU; the defaults are the released recipe
torchrun --standalone --nproc_per_node 8 scripts/train.py \
    --run-name my-tail --data-root ./data --ckpt-root ./checkpoints

# 3. Evaluate against the stock VAE image, then export the tail
python scripts/evaluate.py --ckpt checkpoints/my-tail/latest --out eval/my-tail --prompts 64 --val-root ./data
python scripts/export_checkpoint.py --ckpt checkpoints/my-tail --out dwd_tail.safetensors

Runs resume from the last checkpoint when started again with the same command. Pass the exported file to DWDKleinPipeline.from_pretrained or --tail. See docs/usage.md for memory, resume and every option, and docs/data_format.md for the data layout.

Limitations

  • Fine texture is slightly softer than with the VAE decode. The image stays close to the stock one for the same seed (25.5 dB PSNR), but it is not identical.
  • Text-to-image only. Image editing and reference-image conditioning are not supported.
  • Trained at about 1 MP and 4 steps. Other sizes run but are not evaluated; another step count runs with a warning.
  • Tied to FLUX.2 [klein] 4B. The tail replaces the last 4 single blocks, norm_out and proj_out of the distilled base model and is not a VAE replacement for other models or arbitrary latents.
  • LoRAs are untested. A LoRA on the last 4 single blocks, norm_out or proj_out will not carry over.
  • Benchmarked on one B200 with bf16 and batch size 1. Speed and memory vary with hardware, resolution, batch size and software.

What this is not

  • Not a standalone model. It needs the text encoder and transformer of black-forest-labs/FLUX.2-klein-4B.
  • Not a faster transformer. All 4 steps still run through the transformer; the saving is the VAE decode.
  • Not a drop-in for the stock diffusers Flux2KleinPipeline; use DWDKleinPipeline from this repository, or the ComfyUI version, whose images are close to, but not identical with, this pipeline's.

License

P-Flux-2-Klein-4B-DWD is based on FLUX.2 [klein] 4B and released under the Apache License 2.0. See NOTICE for details.

Citation

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

@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{pruna2026pflux2klein4bdwd,
  title   = {P-Flux-2-Klein-4B-DWD: Decoding Without a Decoder for FLUX.2 [klein] 4B},
  author  = {{Pruna AI}},
  year    = {2026},
  version = {0.1.0},
  url     = {https://huggingface.co/PrunaAI/P-Flux-2-Klein-4B-DWD}
}

What's next?

  • Use P-Flux-2-Klein-4B-DWD to generate FLUX.2 [klein] 4B images without the VAE decode.
  • Compress your own models with Pruna and give us a ⭐️ for more efficiency!
  • Want to use our optimized image models right away? Check P-Image-Ideogram and P-Image-Edit.

Try our models

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for PrunaAI/P-Flux-2-Klein-4B-DWD

Finetuned
(103)
this model
Finetunes
1 model

Space using PrunaAI/P-Flux-2-Klein-4B-DWD 1

Collection including PrunaAI/P-Flux-2-Klein-4B-DWD

Paper for PrunaAI/P-Flux-2-Klein-4B-DWD