Views
No views yet
pip install sdnq1import torch
2import diffusers
3from sdnq import SDNQConfig # import sdnq to register it into diffusers and transformers
4from sdnq.common import use_torch_compile as triton_is_available
5from sdnq.loader import apply_sdnq_options_to_model
6
7pipe = diffusers.ZImagePipeline.from_pretrained("Disty0/Z-Image-Turbo-SDNQ-int8", torch_dtype=torch.bfloat16)
8
9# Enable INT8 MatMul for AMD, Intel ARC and Nvidia GPUs:
10if triton_is_available and (torch.cuda.is_available() or torch.xpu.is_available()):
11 pipe.transformer = apply_sdnq_options_to_model(pipe.transformer, use_quantized_matmul=True)
12 pipe.text_encoder = apply_sdnq_options_to_model(pipe.text_encoder, use_quantized_matmul=True)
13 pipe.transformer = torch.compile(pipe.transformer) # optional for faster speeds
14
15pipe.enable_model_cpu_offload()
16
17prompt = "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."
18image = pipe(
19 prompt=prompt,
20 height=1024,
21 width=1024,
22 num_inference_steps=9,
23 guidance_scale=0.0,
24 generator=torch.manual_seed(42),
25).images[0]
26image.save("z-image-turbo-sdnq-int8")| Quantization | Model Size | Visualization |
|---|---|---|
| Original BF16 | 12.3 GB | ![]() |
| SDNQ INT8 | 6.2 GB | ![]() |
| SDNQ INT8 MatMul | 6.2 GB | ![]() |