lulavc commited on
Commit
c2d9d34
·
verified ·
1 Parent(s): 40ca812

v15 Phase 3: FP8 quantization with torchao

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -1,4 +1,4 @@
1
- """Z-Image-Turbo v14.4 - Optimized with SDPA + VAE optimizations"""
2
 
3
  import random
4
  import torch
@@ -30,6 +30,15 @@ pipe_i2i = ZImageImg2ImgPipeline.from_pretrained(
30
  )
31
  pipe_i2i.to("cuda")
32
 
 
 
 
 
 
 
 
 
 
33
  # Phase 1+2 Optimizations: VAE optimizations for large images
34
  try:
35
  pipe_t2i.vae.enable_tiling()
@@ -45,7 +54,7 @@ try:
45
  except Exception as e:
46
  print(f"VAE slicing not available: {e}")
47
 
48
- print("Pipelines ready with optimizations!")
49
 
50
  STYLES = ["None", "Photorealistic", "Cinematic", "Anime", "Digital Art",
51
  "Oil Painting", "Watercolor", "3D Render", "Fantasy", "Sci-Fi"]
 
1
+ """Z-Image-Turbo v15 - Phase 3: FP8 Quantization + SDPA + VAE optimizations"""
2
 
3
  import random
4
  import torch
 
30
  )
31
  pipe_i2i.to("cuda")
32
 
33
+ # Phase 3: FP8 Quantization (30-50% speedup, 50% memory reduction)
34
+ try:
35
+ from torchao.quantization import quantize_, float8_dynamic_activation_float8_weight
36
+ quantize_(pipe_t2i.transformer, float8_dynamic_activation_float8_weight())
37
+ quantize_(pipe_i2i.transformer, float8_dynamic_activation_float8_weight())
38
+ print("FP8 quantization enabled on transformers!")
39
+ except Exception as e:
40
+ print(f"FP8 quantization not available: {e}")
41
+
42
  # Phase 1+2 Optimizations: VAE optimizations for large images
43
  try:
44
  pipe_t2i.vae.enable_tiling()
 
54
  except Exception as e:
55
  print(f"VAE slicing not available: {e}")
56
 
57
+ print("Pipelines ready with all optimizations!")
58
 
59
  STYLES = ["None", "Photorealistic", "Cinematic", "Anime", "Digital Art",
60
  "Oil Painting", "Watercolor", "3D Render", "Fantasy", "Sci-Fi"]