ford442 commited on
Commit
894158a
·
verified ·
1 Parent(s): 8e7d60e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -28
app.py CHANGED
@@ -6,18 +6,13 @@
6
  # copies of the Software, and to permit persons to whom the Software is
7
  import spaces
8
  import os
9
-
10
  import random
11
  import uuid
12
  import gradio as gr
13
  import numpy as np
14
  from PIL import Image
15
  import torch
16
- import torch._dynamo
17
-
18
- import hidet
19
- import diffusers
20
-
21
  from diffusers import AutoencoderKL, StableDiffusionXLPipeline
22
  from diffusers import EulerAncestralDiscreteScheduler
23
  from typing import Tuple
@@ -31,8 +26,8 @@ torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = False
31
  torch.backends.cudnn.allow_tf32 = False
32
  torch.backends.cudnn.deterministic = False
33
  torch.backends.cudnn.benchmark = False
34
- #torch.backends.cuda.preferred_blas_library="cublas"
35
- # torch.backends.cuda.preferred_linalg_library="cusolver"
36
  torch.set_float32_matmul_precision("highest")
37
 
38
  FTP_HOST = "1ink.us"
@@ -112,30 +107,10 @@ def load_and_prepare_model():
112
  pipe.safety_checker=None
113
  #pipe.unet.to(memory_format=torch.channels_last)
114
  #pipe.enable_vae_tiling()
115
- #pipe.unet = pipe.unet.to(memory_format=torch.contiguous_format)
116
- #pipe.unet = torch.compile(pipe.unet, backend="hidet")
117
  pipe.to(device=device, dtype=torch.bfloat16)
118
 
119
  return pipe
120
 
121
- # for compile
122
- hidet.option.parallel_build(True)
123
- #hidet.option.parallel_tune(-1,4.0)
124
- torch._dynamo.config.suppress_errors = True
125
- torch._dynamo.disallow_in_graph(diffusers.models.attention.BasicTransformerBlock)
126
- # more search
127
- hidet.torch.dynamo_config.search_space(1)
128
- #hidet.torch.dynamo_config.dump_graph_ir("./local_graph")
129
- hidet.option.cache_dir("local_cache")
130
- # automatically transform the model to use float16 data type
131
- hidet.torch.dynamo_config.use_fp16(True)
132
- # use float16 data type as the accumulate data type in operators with reduction
133
- hidet.torch.dynamo_config.use_fp16_reduction(True)
134
- # use tensorcore
135
- hidet.torch.dynamo_config.use_tensor_core()
136
- # Preload and compile both models
137
- hidet.torch.dynamo_config.steal_weights(False)
138
-
139
  pipe = load_and_prepare_model()
140
 
141
  MAX_SEED = np.iinfo(np.int64).max
 
6
  # copies of the Software, and to permit persons to whom the Software is
7
  import spaces
8
  import os
 
9
  import random
10
  import uuid
11
  import gradio as gr
12
  import numpy as np
13
  from PIL import Image
14
  import torch
15
+ #import diffusers
 
 
 
 
16
  from diffusers import AutoencoderKL, StableDiffusionXLPipeline
17
  from diffusers import EulerAncestralDiscreteScheduler
18
  from typing import Tuple
 
26
  torch.backends.cudnn.allow_tf32 = False
27
  torch.backends.cudnn.deterministic = False
28
  torch.backends.cudnn.benchmark = False
29
+ torch.backends.cuda.preferred_blas_library="cublas"
30
+ torch.backends.cuda.preferred_linalg_library="cusolver"
31
  torch.set_float32_matmul_precision("highest")
32
 
33
  FTP_HOST = "1ink.us"
 
107
  pipe.safety_checker=None
108
  #pipe.unet.to(memory_format=torch.channels_last)
109
  #pipe.enable_vae_tiling()
 
 
110
  pipe.to(device=device, dtype=torch.bfloat16)
111
 
112
  return pipe
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  pipe = load_and_prepare_model()
115
 
116
  MAX_SEED = np.iinfo(np.int64).max