English
John6666 commited on
Commit
bb44a1f
·
verified ·
1 Parent(s): d44f2d8

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +24 -5
handler.py CHANGED
@@ -42,10 +42,10 @@ if IS_COMPILE:
42
  torch._dynamo.config.suppress_errors = False
43
  #torch._dynamo.config.suppress_errors = True
44
  torch._inductor.config.disable_progress = False
45
- #torch._inductor.config.conv_1x1_as_mm = True
46
- #torch._inductor.config.coordinate_descent_tuning = True
47
- #torch._inductor.config.coordinate_descent_check_all_directions = True
48
- #torch._inductor.config.epilogue_fusion = False
49
 
50
  if IS_MGPU:
51
  import torch.distributed as dist
@@ -207,6 +207,25 @@ def load_pipeline_para(repo_id: str, dtype: torch.dtype) -> Any:
207
  pipe.vae = torch.compile(pipe.vae, mode="max-autotune-no-cudagraphs")
208
  return pipe
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  class EndpointHandler:
211
  def __init__(self, path=""):
212
  repo_id = "NoMoreCopyrightOrg/flux-dev-8step" if IS_TURBO else "NoMoreCopyrightOrg/flux-dev"
@@ -216,7 +235,7 @@ class EndpointHandler:
216
  print_vram()
217
  print("Loading pipeline...")
218
  if IS_AUTOQ: self.pipeline = load_pipeline_autoquant(repo_id, dtype)
219
- elif IS_COMPILE: self.pipeline = load_pipeline_para(repo_id, dtype)
220
  elif IS_LVRAM and IS_CC89: self.pipeline = load_pipeline_lowvram(repo_id, dtype)
221
  else: self.pipeline = load_pipeline_stable(repo_id, dtype)
222
  if not IS_COMPILE:
 
42
  torch._dynamo.config.suppress_errors = False
43
  #torch._dynamo.config.suppress_errors = True
44
  torch._inductor.config.disable_progress = False
45
+ torch._inductor.config.conv_1x1_as_mm = True
46
+ torch._inductor.config.coordinate_descent_tuning = True
47
+ torch._inductor.config.coordinate_descent_check_all_directions = True
48
+ torch._inductor.config.epilogue_fusion = False
49
 
50
  if IS_MGPU:
51
  import torch.distributed as dist
 
207
  pipe.vae = torch.compile(pipe.vae, mode="max-autotune-no-cudagraphs")
208
  return pipe
209
 
210
+ def load_pipeline_fast(repo_id: str, dtype: torch.dtype) -> Any:
211
+ pipe = FluxPipeline.from_pretrained(repo_id, torch_dtype=dtype).to("cuda")
212
+ pipe.enable_vae_slicing()
213
+ pipe.enable_vae_tiling()
214
+ apply_cache_on_pipe(pipe, residual_diff_threshold=0.12)
215
+ if IS_CC90: quantize_(pipe.transformer, float8_dynamic_activation_float8_weight(granularity=PerRow()), device="cuda")
216
+ elif IS_CC89: quantize_(pipe.transformer, float8_dynamic_activation_float8_weight(), device="cuda")
217
+ #pipe.transformer.fuse_qkv_projections()
218
+ pipe.transformer.to(memory_format=torch.channels_last)
219
+ #pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
220
+ pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune-no-cudagraphs")
221
+ if IS_CC90: quantize_(pipe.vae, float8_dynamic_activation_float8_weight(granularity=PerRow()), device="cuda")
222
+ elif IS_CC89: quantize_(pipe.vae, float8_dynamic_activation_float8_weight(), device="cuda")
223
+ #pipe.vae.fuse_qkv_projections()
224
+ pipe.vae.to(memory_format=torch.channels_last)
225
+ #pipe.vae = torch.compile(pipe.vae, mode="max-autotune", fullgraph=True)
226
+ pipe.vae = torch.compile(pipe.vae, mode="max-autotune-no-cudagraphs")
227
+ return pipe
228
+
229
  class EndpointHandler:
230
  def __init__(self, path=""):
231
  repo_id = "NoMoreCopyrightOrg/flux-dev-8step" if IS_TURBO else "NoMoreCopyrightOrg/flux-dev"
 
235
  print_vram()
236
  print("Loading pipeline...")
237
  if IS_AUTOQ: self.pipeline = load_pipeline_autoquant(repo_id, dtype)
238
+ elif IS_COMPILE: self.pipeline = load_pipeline_fast(repo_id, dtype)
239
  elif IS_LVRAM and IS_CC89: self.pipeline = load_pipeline_lowvram(repo_id, dtype)
240
  else: self.pipeline = load_pipeline_stable(repo_id, dtype)
241
  if not IS_COMPILE: