Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -3,15 +3,24 @@ import numpy as np
|
|
3 |
import random
|
4 |
import spaces
|
5 |
import torch
|
6 |
-
from diffusers import DiffusionPipeline
|
7 |
|
8 |
-
from pruna import PrunaModel
|
9 |
|
10 |
dtype = torch.bfloat16
|
11 |
-
device = "cuda" if torch.cuda.is_available() else "
|
12 |
|
13 |
-
pipe =
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
)
|
16 |
|
17 |
MAX_SEED = np.iinfo(np.int32).max
|
|
|
3 |
import random
|
4 |
import spaces
|
5 |
import torch
|
6 |
+
from diffusers import DiffusionPipeline, FluxPipeline
|
7 |
|
8 |
+
from pruna import PrunaModel, smash, SmashConfig
|
9 |
|
10 |
dtype = torch.bfloat16
|
11 |
+
device = "cuda" if torch.cuda.is_available() else "CPU"
|
12 |
|
13 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", dtype=dtype).to(device)
|
14 |
+
smash_config = SmashConfig()
|
15 |
+
smash_config["factorizer"] = "qkv_diffusers"
|
16 |
+
smash_config["cacher"] = "fora"
|
17 |
+
smash_config["fora_interval"] = 2
|
18 |
+
smash_config["quantizer"] = "torchao"
|
19 |
+
smash_config["torchao_quant_type"] = "fp8dq"
|
20 |
+
smash_config["torchao_excluded_modules"] = "norm+embedding"
|
21 |
+
pipe = smash(
|
22 |
+
model=pipe,
|
23 |
+
smash_config=smash_config,
|
24 |
)
|
25 |
|
26 |
MAX_SEED = np.iinfo(np.int32).max
|