Downloads · 30 days
84
100% of all-time downloads
catplusplus/nunchaku-qwen-image-2.1
nunchaku-qwen-image-2.1 is a text-to-image model from catplusplus. Use it when you need an image from a text prompt. It is set up for nunchaku. The card lists the license as apache-2.0.
This repository provides the high-fidelity SVDQuant NVFP4 (Rank 32) quantized transformer for Alibaba's Qwen-Image-2.1, forged with channel-wise Level-0 macro scaling (wcscales) for inference with Nunchaku on NVIDIA B…
Downloads · 30 days
84
100% of all-time downloads
All-time downloads
84
Public
Repo size
4.4 GB
Likes
0
Public
Click a slice to open those files.
.safetensors8.8 GB · 100%
From the Hugging Face model README
This repository provides the high-fidelity SVDQuant NVFP4 (Rank 32) quantized transformer for Alibaba's Qwen-Image-2.1, forged with channel-wise Level-0 macro scaling (wcscales) for inference with Nunchaku on NVIDIA Blackwell (sm_120), Ada Lovelace, and Hopper architectures.
wcscales):
attn.to_q, to_k, to_v, to_out.0, img_mlp.proj, img_mlp.gate_layer, img_mlp.out).Qwen21_Text_Encoder_Heretic for maximum prompt adherence, eliminating vector deflection and maintaining fine semantic control.| Pipeline Stage | Baseline (BF16 Offloaded) | SVDQuant NVFP4 (Resident) | Speedup / Savings |
|---|---|---|---|
| DiT Kernel Compute (25 steps) | 23.26 s | 18.02 s (0.72s / step) | 1.29x faster compute |
| PCIe Layer Offload Latency | 37.40 s | 0.00 s (100% Resident) | Eradicated (37.4s saved!) |
| Total T2I Latency (25 steps) | 64.84 s | 20.02 s | 3.24x faster end-to-end |
| Total I2I Edit Latency (40 steps) | 198.44 s | 41.02 s | 4.84x faster end-to-end |
| Peak VRAM Footprint | ~14.8 GB (offloaded) | 10.58 GB (resident DiT + VAE + Streamer) | 4.92 GB Free Headroom on 16GB GPU |
| Domain | Baseline Scalar wtscale | Champion Channel-Wise wcscales | Fidelity Gain |
|---|---|---|---|
| Animal Fur & Whiskers (Kitten T2I) | 26.23 dB PSNR (0.9213 SSIM) | 28.87 dB PSNR (0.9402 SSIM) | +2.64 dB (fuzziness eliminated) |
| High-Res Facial Portraiture (Portrait T2I) | 20.25 dB PSNR (0.8478 SSIM) | 24.87 dB PSNR (0.9193 SSIM) | +4.62 dB (natural skin tones) |
| In-Context Action Edit (Kitten Chase) | 23.11 dB PSNR (0.8920 SSIM) | 25.93 dB PSNR (0.9510 SSIM) | +2.82 dB (identity preserved) |
| Broadcast Testcard (Chroma Spill Ratio) | 4.58 (35x chroma bleed) | 0.88 (clean subcarrier edges) | Banished SECAM-like bleed! |
Ensure you have PyTorch, Diffusers, and Nunchaku installed:
pip install nunchaku diffusers transformers accelerate sentencepiece
import torch
from diffusers import QwenImage21Pipeline
from nunchaku.models.transformers.transformer_qwenimage21 import NunchakuQwenImage21Transformer2DModel
device = "cuda:0"
# 1. Load forged NVFP4 DiT directly into resident VRAM
transformer = NunchakuQwenImage21Transformer2DModel.from_pretrained(
"svdq-fp4_r32-qwen-image-2.1.safetensors",
device=device,
torch_dtype=torch.bfloat16,
)
# 2. Assemble complete pipeline (pointing text encoder to Heretic if desired)
pipeline = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1",
transformer=transformer,
torch_dtype=torch.bfloat16,
)
pipeline.vae = pipeline.vae.to(device)
pipeline.vae.enable_tiling()
# 3. Generate high-resolution image
image = pipeline(
prompt="A serene Japanese garden with blooming cherry blossoms, koi pond, and morning mist, highly detailed",
height=1024,
width=1024,
num_inference_steps=25,
true_cfg_scale=1.0,
).images[0]
image.save("serene_garden.png")
Qwen21_Text_Encoder_Heretic)When generating scenes with complex human anatomy, athletic dynamics, or specific attire, pair this DiT with Qwen21_Text_Encoder_Heretic to eliminate VLM hesitation vector deflection and ensure exact prompt adherence:
# Launch high-throughput server with Heretic text encoder on port 4500:
./extras/imagegen_qwen21_nvfp4.sh 4500
extras/)Inside the extras/ folder of this repository, you will find:
ImageEditServer.py: High-concurrency FastAPI/Uvicorn server supporting Text-to-Image (/v1/images/generations) and Multimodal In-Context Image Editing (/v1/images/edits).QwenImage21NVFP4Backend.py: Production backend with resident DiT management, VAE tiling, and optional PCIe layerwise text encoder streaming.stream_encoder.py: Zero-quality-loss layerwise weight streaming engine for Qwen3-VL-8B.stream_quantize_qwen21.py: Full quantization pipeline implementing alternating least-squares SVD rank-32 decomposition and channel-wise scale packing.diagnose_trajectory_and_scales.py: Step-by-step Euler flow-matching trajectory analyzer.eval_divergence_metrics.py: Multi-domain divergence evaluator (PSNR, SSIM, SigLIP cosine similarity, edge acuity, chroma spill).