| --- |
| base_model: krea/Krea-2-Turbo |
| license: other |
| license_name: krea-2-community-license |
| license_link: https://krea.ai/krea-2-licensing |
| tags: |
| - text-to-image |
| - diffusion |
| - quantization |
| - svdquant |
| - nunchaku |
| - w4a4 |
| pipeline_tag: text-to-image |
| --- |
| |
| # Krea 2 Turbo W4A4 (Nunchaku) |
|
|
| Krea 2 Turbo quantized to **4-bit weights and 4-bit activations** with SVDQuant, running |
| through Nunchaku's fused low-bit kernels. As far as I can tell this is the first W4A4 build |
| of Krea 2, and the first time it has generated an image through fused 4-bit kernels rather |
| than a simulation of them. |
|
|
| This is not storage quantization. The fp8 and int8 builds in circulation shrink the file and |
| leave the forward-pass arithmetic untouched. This one rewrites the arithmetic, which is the |
| only kind of quantization that buys real time. |
|
|
| ## Measured |
|
|
| Scored against BF16 on the same card, 12 versioned prompts, 8 fixed seeds, 96 seed-locked |
| pairs per resolution. Latency is a warm median of 3 seeds on an L40S with both models on the |
| same attention path. |
|
|
| | fidelity vs bf16 | LPIPS | PSNR | ImageReward delta | n | |
| |---|---|---|---|---| |
| | 1024px | 0.276 | 17.7 | +0.078 | 96 | |
| | 512px | 0.226 | 18.4 | -0.013 | 96 | |
|
|
| | latency | W4A4 | bf16 | speedup | |
| |---|---|---|---| |
| | 1024px, 8 steps | 5.36s | 7.71s | 1.44x | |
| | 512px, 8 steps | 1.34s | 2.19s | 1.63x | |
| | 512px, 2 steps | 0.41s | n/a | 2.45 img/s | |
|
|
| Quality did not degrade. **A positive ImageReward delta is not a quality gain** and I would |
| rather say that plainly than let the number flatter the build. A reward model is a learned |
| preference with known failure modes, and the likelier reading is that quantization nudged the |
| trajectory into a more prototypical basin. What the number supports is the narrower claim: |
| four bits of weight and four bits of activation, and no penalty this measure can see. The |
| 1024px result lands on the fake-quant study's prediction of 0.268, which is the best evidence |
| that the running build is faithful to the calibration it came from. |
|
|
| The reason it holds is the shape of the method. SVDQuant carries a rank-32 full-precision |
| branch next to the 4-bit matmul, and it absorbs the outlier activations that would otherwise |
| wreck the last blocks. Calibration error climbs roughly 3x from the first block to the last, |
| and the branch soaks it up. |
|
|
| ## Read this before you benchmark it |
|
|
| Krea 2 uses grouped-query attention and always passes an attention mask, because text and |
| image share one sequence. PyTorch's SDPA **will not serve `enable_gqa=True` together with a |
| mask on the flash backend**. It drops to the math backend silently and materializes the full |
| attention matrix. Expanding the 12 k/v heads to 48 by hand restores FlashAttention with the |
| mask still in place. |
| |
| Four-way ablation on the real pipeline, 1024px, 8 steps: |
| |
| | | time | |
| |---|---| |
| | `enable_gqa=True` | 22.3s | |
| | `enable_gqa=True` + dtype cast | 22.4s | |
| | expanded heads | 7.7s | |
| | expanded heads + dtype cast | 7.8s | |
| |
| A separate 3x, sitting on top of both columns above. Any model that splits heads this way and |
| also masks will lose the fast kernel without saying so. I got the cause wrong twice before |
| isolating it, once by testing the attention call outside the pipeline where there was no mask |
| to trigger the condition. |
| |
| ## Usage |
| |
| Requires the Krea 2 runtime for Nunchaku. It is |
| [under review upstream](https://github.com/nunchaku-ai/nunchaku/pull/947); until it lands, the |
| files are at [github.com/sztlink/krea2-nunchaku](https://github.com/sztlink/krea2-nunchaku). |
| |
| ```python |
| from nunchaku.models.transformers.transformer_krea2 import NunchakuKrea2Transformer2DModel |
| from diffusers import Krea2Pipeline |
| import torch |
| |
| transformer = NunchakuKrea2Transformer2DModel.from_pretrained( |
| "felipesztutman/Krea-2-Turbo-W4A4-Nunchaku/svdq-int4_r32-krea-2-turbo.safetensors", |
| torch_dtype=torch.bfloat16, |
| ) |
| pipe = Krea2Pipeline.from_pretrained( |
| "krea/Krea-2-Turbo", transformer=transformer, torch_dtype=torch.bfloat16, |
| ).to("cuda") |
| |
| # Krea 2 Turbo is cfg-distilled. guidance_scale MUST be 0.0. |
| image = pipe("a fox in the snow", guidance_scale=0.0, num_inference_steps=8).images[0] |
| ``` |
| |
| Ampere or newer, verified on an RTX 3090 (sm_86) on both Linux and native Windows 11: 2.7s at |
| 512px/8 steps, 9.5s at 1024px/8 steps, 0.85s at 512px/2 steps, warm, clean image on both. Also |
| runs on Ada (L40S). Use `nunchaku==1.2.1` (cu12.8 torch2.8 cp312); it carries the loader this |
| runtime needs and ships both Linux and Windows wheels. Nunchaku reports INT4 support down to |
| Turing since v1.2.0, untested here. The NVFP4 variant needs Blackwell; this INT4 build does not. |
| See the [runtime repo](https://github.com/sztlink/krea2-nunchaku) for the exact install. |
| |
| ## Provenance and limits |
| |
| Calibrated on an H100 with deepcompressor, 128 calibration prompts. Every fidelity number |
| above traces to raw per-pair data in |
| [dead-channel](https://github.com/sztlink/dead-channel), the open benchmark this came out of, |
| including the pairs where it does worst. |
| |
| Known: compositions shift relative to BF16 at the same seed, which is expected and is what |
| LPIPS 0.276 is reporting. Not a drop-in seed-for-seed replacement if you need to reproduce |
| existing BF16 outputs exactly. |
| |
| ## License and attribution |
| |
| This is a **modified** version of Krea 2 Turbo. It is not official, and it is not endorsed by |
| or affiliated with Krea. Use is governed by the Krea 2 Community License Agreement, a copy of |
| which is included in this repository as `LICENSE.pdf`. |
|
|
| Krea 2 is licensed under the Krea 2 Community License Agreement. For more information, visit |
| https://krea.ai/krea-2-licensing. |
|
|
| The base model ships with a content filter. Quantization does not remove or weaken it, and |
| redistributing this checkpoint does not license you to bypass it. Downstream use remains |
| subject to the base license's acceptable use terms. |
|
|