Spaces:
vilarin
/
Running on Zero

vilarin commited on
Commit
92f9e1d
·
verified ·
1 Parent(s): a0f72b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -13,7 +13,7 @@ from diffusers.utils import load_image
13
  from PIL import Image
14
  import requests
15
  import transformers
16
- from transformers import AutoTokenizer, T5EncoderModel, BitsAndBytesConfig
17
  from translatepy import Translator
18
 
19
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
@@ -53,12 +53,10 @@ transformer = SD3Transformer2DModel.from_pretrained(
53
  torch_dtype=torch.float16,
54
  )
55
 
56
- quantization_config = BitsAndBytesConfig(load_in_8bit=True)
57
 
58
  text_encoder_3 = T5EncoderModel.from_pretrained(
59
  repo,
60
  subfolder="text_encoder_3",
61
- quantization_config=quantization_config,
62
  )
63
 
64
  tokenizer_3 = AutoTokenizer.from_pretrained(
@@ -81,6 +79,31 @@ if torch.cuda.is_available():
81
  text_encoder_3=text_encoder_3,
82
  torch_dtype=torch.float16).to("cuda")
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe.scheduler.config)
85
  pipe2.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe2.scheduler.config)
86
 
 
13
  from PIL import Image
14
  import requests
15
  import transformers
16
+ from transformers import AutoTokenizer, T5EncoderModel
17
  from translatepy import Translator
18
 
19
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
 
53
  torch_dtype=torch.float16,
54
  )
55
 
 
56
 
57
  text_encoder_3 = T5EncoderModel.from_pretrained(
58
  repo,
59
  subfolder="text_encoder_3",
 
60
  )
61
 
62
  tokenizer_3 = AutoTokenizer.from_pretrained(
 
79
  text_encoder_3=text_encoder_3,
80
  torch_dtype=torch.float16).to("cuda")
81
 
82
+ torch.set_float32_matmul_precision("high")
83
+
84
+ torch._inductor.config.conv_1x1_as_mm = True
85
+ torch._inductor.config.coordinate_descent_tuning = True
86
+ torch._inductor.config.epilogue_fusion = False
87
+ torch._inductor.config.coordinate_descent_check_all_directions = True
88
+
89
+ pipe.set_progress_bar_config(disable=True)
90
+
91
+ pipe.transformer.to(memory_format=torch.channels_last)
92
+ pipe.vae.to(memory_format=torch.channels_last)
93
+
94
+ pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
95
+ pipe.vae.decode = torch.compile(pipe.vae.decode, mode="max-autotune", fullgraph=True)
96
+
97
+
98
+ pipe2.set_progress_bar_config(disable=True)
99
+
100
+ pipe2.transformer.to(memory_format=torch.channels_last)
101
+ pipe2.vae.to(memory_format=torch.channels_last)
102
+
103
+ pipe2.transformer = torch.compile(pipe2.transformer, mode="max-autotune", fullgraph=True)
104
+ pipe2.vae.decode = torch.compile(pipe2.vae.decode, mode="max-autotune", fullgraph=True)
105
+
106
+
107
  pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe.scheduler.config)
108
  pipe2.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe2.scheduler.config)
109