stable-diffusion.cpp/docs/models/z_image.md

7.7 KiB

Z-Image

Z-Image and Z-Image-Turbo generate images from text using Qwen3 4B and the FLUX VAE.

You can run Z-Image with stable-diffusion.cpp on GPUs with 4GB of VRAM — or even less.

Model files

Component Weights and downloads CLI option Requirement
Z-Image-Turbo Safetensors
GGUF
--diffusion-model Choose matching variant
Z-Image Safetensors
GGUF
--diffusion-model Choose matching variant
vae Safetensors --vae Use matching VAE
Qwen3 4b Safetensors
GGUF
--llm Use matching text encoder
ControlNet Z-Image control checkpoint with control_all_x_embedder.2-1.weight --control-net or DGL controlnet::load Optional. Match the DiT architecture

Usage

Web UI

Follow the Web UI guide to start the server, then select the recipe matching your weights. Fill the component slots below and click Load models. Use the files and compatibility requirements in Model files.

Recipe Component slots
Z-Image (z-image) diffusion_model, llm, vae, tae
Z-Image Turbo (z-image-turbo) diffusion_model, llm, vae, tae

Slot IDs correspond to CLI component options: diffusion_model uses --diffusion-model, llm uses --llm, and model uses -m / --model. Select optional components when required by your checkpoint or task.

DGL

Example Description
Turbo: text to image Distilled generation.
Base: text to image Base checkpoint.
Turbo with ControlNet Load and apply control weights separately.

Run a script

Edit paths, prompts and settings in the script's var block, then run from the build directory. Paths inside the script resolve from the working directory.

Windows (PowerShell)

.\bin\Release\sd-cli.exe -M dgl --script ..\docs\dgl\z_image\z-image-turbo-txt2img.dgl

Linux/macOS

./bin/sd-cli -M dgl --script ../docs/dgl/z_image/z-image-turbo-txt2img.dgl

Choose another script from the table to run a different task. Add --check to validate syntax and types without loading weights. See the shared run instructions for build paths and the server's file-access rules.

ControlNet

The Z-Image ControlNet script loads the diffusion and control weights as separate models. Set the four checkpoint paths and the prepared control image path in the script. The script encodes the image with the FLUX VAE in posterior mode, converts it to diffusion latents and pads the channel axis to 33 before calling controlnet::apply. Each control model shares the DiT's compute backend. Repeated controlnet::apply calls combine the controls before sampling. In the current Z-Image model, control conditions and reference latents require separate predictions.

Legacy CLI

CLI examples use the shared path and shell conventions.

Z-Image-Turbo

Windows (PowerShell)

.\bin\Release\sd-cli.exe `
  --diffusion-model ..\models\diffusion_models\z_image_turbo-Q3_K.gguf `
  --vae ..\models\vae\ae.sft `
  --llm ..\models\text_encoders\Qwen3-4B-Instruct-2507-Q4_K_M.gguf `
  -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" `
  --cfg-scale 1.0 `
  --steps 8 `
  -H 1024 `
  -W 512 `
  --offload-to-cpu `
  -v

Linux/macOS

./bin/sd-cli \
  --diffusion-model ../models/diffusion_models/z_image_turbo-Q3_K.gguf \
  --vae ../models/vae/ae.sft \
  --llm ../models/text_encoders/Qwen3-4B-Instruct-2507-Q4_K_M.gguf \
  -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" \
  --cfg-scale 1.0 \
  --steps 8 \
  -H 1024 \
  -W 512 \
  --offload-to-cpu \
  -v
z-image example

Z-Image-Base

Windows (PowerShell)

.\bin\Release\sd-cli.exe `
  --diffusion-model ..\models\diffusion_models\z_image_bf16.safetensors `
  --vae ..\models\vae\ae.sft `
  --llm ..\models\text_encoders\qwen_3_4b.safetensors `
  -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" `
  --cfg-scale 5.0 `
  -H 1024 `
  -W 512 `
  --offload-to-cpu `
  -v

Linux/macOS

./bin/sd-cli \
  --diffusion-model ../models/diffusion_models/z_image_bf16.safetensors \
  --vae ../models/vae/ae.sft \
  --llm ../models/text_encoders/qwen_3_4b.safetensors \
  -p "A cinematic, melancholic photograph of a solitary hooded figure walking through a sprawling, rain-slicked metropolis at night. The city lights are a chaotic blur of neon orange and cool blue, reflecting on the wet asphalt. The scene evokes a sense of being a single component in a vast machine. Superimposed over the image in a sleek, modern, slightly glitched font is the philosophical quote: 'THE CITY IS A CIRCUIT BOARD, AND I AM A BROKEN TRANSISTOR.' -- moody, atmospheric, profound, dark academic" \
  --cfg-scale 5.0 \
  -H 1024 \
  -W 512 \
  --offload-to-cpu \
  -v
z-image example

Comparison of Different Quantization Types

bf16 q8_0 q6_K q5_0 q4_K q4_0 q3_K q2_K
bf16 q8_0 q6_K q5_0 q4_K q4_0 q3_K q2_K