Spaces:
Runtime error
Runtime error
jadechoghari
commited on
Commit
β’
7e59139
1
Parent(s):
1c2e16e
Update app.py
Browse files
app.py
CHANGED
@@ -17,22 +17,27 @@ pipeline_optimized = FluxPipeline.from_pretrained(
|
|
17 |
"camenduru/FLUX.1-dev-diffusers",
|
18 |
torch_dtype=torch.bfloat16
|
19 |
).to("cuda")
|
20 |
-
pipeline_optimized.transformer = autoquant(
|
21 |
-
pipeline_optimized.transformer
|
22 |
-
)
|
23 |
-
print("all good")
|
24 |
pipeline_optimized.transformer.to(memory_format=torch.channels_last)
|
25 |
pipeline_optimized.transformer = torch.compile(
|
26 |
pipeline_optimized.transformer,
|
27 |
mode="max-autotune",
|
28 |
fullgraph=True
|
29 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
pipeline_optimized.transformer
|
33 |
-
|
34 |
-
|
35 |
-
)
|
36 |
pipeline_normal = pipeline_optimized
|
37 |
|
38 |
@spaces.GPU(duration=120)
|
|
|
17 |
"camenduru/FLUX.1-dev-diffusers",
|
18 |
torch_dtype=torch.bfloat16
|
19 |
).to("cuda")
|
|
|
|
|
|
|
|
|
20 |
pipeline_optimized.transformer.to(memory_format=torch.channels_last)
|
21 |
pipeline_optimized.transformer = torch.compile(
|
22 |
pipeline_optimized.transformer,
|
23 |
mode="max-autotune",
|
24 |
fullgraph=True
|
25 |
)
|
26 |
+
# wrap the autoquant call in a try-except block to handle unsupported layers
|
27 |
+
for name, layer in pipeline_optimized.transformer.named_children():
|
28 |
+
try:
|
29 |
+
# apply autoquant to each layer
|
30 |
+
pipeline_optimized.transformer._modules[name] = autoquant(layer, error_on_unseen=False)
|
31 |
+
print(f"Successfully quantized {name}")
|
32 |
+
except AttributeError as e:
|
33 |
+
print(f"Skipping layer {name} due to error: {e}")
|
34 |
+
except Exception as e:
|
35 |
+
print(f"Unexpected error while quantizing {name}: {e}")
|
36 |
|
37 |
+
# pipeline_optimized.transformer = autoquant(
|
38 |
+
# pipeline_optimized.transformer,
|
39 |
+
# error_on_unseen=False
|
40 |
+
# )
|
|
|
41 |
pipeline_normal = pipeline_optimized
|
42 |
|
43 |
@spaces.GPU(duration=120)
|