CoolFace
Modelpublic

lite-infer/Qwen-Image-nunchaku-lite-int4_r32-bnb4-text-encoder

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
1likes6downloads
Model Card

Qwen-Image Nunchaku Lite INT4 R32 with BNB4 Text Encoder

[!IMPORTANT] Experimental: This Nunchaku Lite quantized Qwen-Image checkpoint is experimental. APIs and loading behavior may change.

This repository contains a full Diffusers pipeline for Qwen/Qwen-Image with:

  • —a Nunchaku Lite quantized diffusion transformer
  • —a prequantized bitsandbytes 4-bit NF4 text_encoder
  • —inherited tokenizer, scheduler, and VAE from the Qwen-Image release

Quantization

The transformer uses a compact Nunchaku Lite quantization config stored in transformer/config.json.

ComponentMethodPrecisionGroup sizeRankTargets
Transformer svdq_w4a4Nunchaku Liteint46432720
Transformer awq_w4a16Nunchaku Liteint464-120
Text encoderbitsandbytesnf4 4-bit--358 modules

Requirements

This checkpoint requires a Diffusers version that includes NunchakuLiteQuantizationConfig and the Nunchaku Lite loader path.

bash
pip install git+https://github.com/huggingface/diffusers
pip install kernels bitsandbytes

Use a CUDA-capable PyTorch environment. The quantized transformer uses kernels from the Hugging Face kernels package, and the text encoder uses bitsandbytes 4-bit modules.

Usage

python
import torch
from diffusers import QwenImagePipeline

pipe = QwenImagePipeline.from_pretrained(
    "lite-infer/Qwen-Image-nunchaku-lite-int4_r32-bnb4-text-encoder",
    torch_dtype=torch.bfloat16,
).to("cuda")

image = pipe(
    prompt="A cinematic photo of a glass teapot on a wooden table, warm window light, detailed reflections, shallow depth of field",
    negative_prompt=" ",
    height=1024,
    width=1024,
    num_inference_steps=20,
    true_cfg_scale=4.0,
    generator=torch.Generator(device="cuda").manual_seed(42),
).images[0]

image.save("qwen-image-nunchaku-lite-int4_r32-bnb4-text-encoder.png")

Evaluation

Evaluation was run with the following settings:

  • —Hardware: NVIDIA GeForce RTX 5090 or equivalent Blackwell GPU with CUDA
  • —Precision: torch_dtype=torch.bfloat16
  • —Output: 1024x1024
  • —Inference steps: 20
  • —Guidance: true_cfg_scale=4.0
  • —Negative prompt: " "
  • —Seed: 42
  • —Runs: 1 warmup run, 3 measured runs

The + torch.compile rows compile only pipe.transformer with mode=None and fullgraph=False.

[!NOTE] On Blackwell GPUs, the INT4 variants measured slower than FP4 in this benchmark. Prefer FP4 variants for latency-sensitive use on Blackwell-class hardware. The Diffusers integration currently uses the Nunchaku Lite quantized modules and kernels, but does not include the original Nunchaku runtime's kernel/module fusing. The + torch.compile rows compile only the Diffusers transformer graph around those modules, so the speedup can be smaller than the original Nunchaku checkpoint benchmark below.
VariantGeneration latencyPeak allocated VRAMPeak reserved VRAM
BF16 base11.41s57.94GB58.80GB
INT4 R32 transformer + BNB4 text encoder47.63s21.22GB22.55GB
INT4 R128 transformer + BNB4 text encoder48.28s22.45GB23.06GB
FP4 R32 transformer + BNB4 text encoder9.17s21.58GB22.11GB
FP4 R128 transformer + BNB4 text encoder9.83s22.76GB23.56GB
BF16 base + torch.compile10.06s57.93GB59.51GB
INT4 R32 transformer + BNB4 text encoder + torch.compile46.41s21.20GB22.41GB
INT4 R128 transformer + BNB4 text encoder + torch.compile47.06s22.43GB23.71GB
FP4 R32 transformer + BNB4 text encoder + torch.compile8.14s21.55GB22.76GB
FP4 R128 transformer + BNB4 text encoder + torch.compile8.83s22.72GB24.18GB

Original Nunchaku Checkpoint Benchmark

The original Nunchaku transformer was loaded with NunchakuQwenImageTransformer2DModel.from_pretrained(...) and inserted into the matching converted pipeline components so the text encoder, tokenizer, VAE, and scheduler matched the converted checkpoint.

Original checkpointGeneration latencyPeak allocated VRAMPeak reserved VRAM
nunchaku-ai/nunchaku-qwen-image/svdq-int4_r32-qwen-image.safetensors36.47s21.23GB22.38GB
nunchaku-ai/nunchaku-qwen-image/svdq-int4_r128-qwen-image.safetensors36.94s22.26GB22.82GB
nunchaku-ai/nunchaku-qwen-image/svdq-fp4_r32-qwen-image.safetensors7.27s21.56GB22.10GB
nunchaku-ai/nunchaku-qwen-image/svdq-fp4_r128-qwen-image.safetensors7.72s22.64GB23.28GB

[image]

Result Image

[image]

Conversion Comparison

[image]

Provenance

Limitations

  • —This is an experimental quantized checkpoint.
  • —The transformer and text encoder are quantized; the scheduler, tokenizer, and VAE are inherited from the base model.
  • —Output quality and performance may differ from the original BF16 pipeline and from the original Nunchaku runtime.

License

This repository follows the Apache-2.0 license from the base Qwen-Image release.