Views
No views yet
| Model | Download |
|---|---|
| Z-Image Turbo GGUF | Download |
| Qwen3-4B (Text Encoder) | unsloth/Qwen3-4B-GGUF |



pip install git+https://github.com/huggingface/diffusers1from diffusers import ZImagePipeline, ZImageTransformer2DModel, GGUFQuantizationConfig
2import torch
3
4prompt = "Young Chinese woman in red Hanfu, intricate embroidery. Impeccable makeup, red floral forehead pattern. Elaborate high bun, golden phoenix headdress, red flowers, beads. Holds round folding fan with lady, trees, bird. Neon lightning-bolt lamp (⚡️), bright yellow glow, above extended left palm. Soft-lit outdoor night background, silhouetted tiered pagoda (西安大雁塔), blurred colorful distant lights."
5height = 1024
6width = 1024
7seed = 42
8
9#hf_path = "https://huggingface.co/jayn7/Z-Image-Turbo-GGUF/blob/main/z_image_turbo-Q3_K_M.gguf"
10local_path = "path\to\local\model\z_image_turbo-Q3_K_M.gguf"
11
12transformer = ZImageTransformer2DModel.from_single_file(
13 local_path,
14 quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
15 dtype=torch.bfloat16,
16)
17
18pipeline = ZImagePipeline.from_pretrained(
19 "Tongyi-MAI/Z-Image-Turbo",
20 transformer=transformer,
21 dtype=torch.bfloat16,
22).to("cuda")
23
24# [Optional] Attention Backend
25# Diffusers uses SDPA by default. Switch to Custom attention backend for better efficiency if supported:
26#pipeline.transformer.set_attention_backend("_sage_qk_int8_pv_fp16_triton") # Enable Sage Attention
27#pipeline.transformer.set_attention_backend("flash") # Enable Flash-Attention-2
28#pipeline.transformer.set_attention_backend("_flash_3") # Enable Flash-Attention-3
29
30# [Optional] Model Compilation
31# Compiling the DiT model accelerates inference, but the first run will take longer to compile.
32#pipeline.transformer.compile()
33
34# [Optional] CPU Offloading
35# Enable CPU offloading for memory-constrained devices.
36#pipeline.enable_model_cpu_offload()
37
38images = pipeline(
39 prompt=prompt,
40 num_inference_steps=9, # This actually results in 8 DiT forwards
41 guidance_scale=0.0, # Guidance should be 0 for the Turbo models
42 height=height,
43 width=width,
44 generator=torch.Generator("cuda").manual_seed(seed)
45).images[0]
46
47images.save("zimage.png")📂 ComfyUI/
├── 📂 models/
│ ├── 📂 text_encoders/
│ │ └── qwen_3_4b-Q*.gguf
│ ├── 📂 diffusion_models/
│ │ └── z_image_turbo-Q*.gguf
│ └── 📂 vae/
│ └── ae.safetensors