Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -326,12 +326,18 @@ def load_model():
|
|
| 326 |
torch_dtype=torch.bfloat16,
|
| 327 |
trust_remote_code=False
|
| 328 |
).to(device).eval()
|
| 329 |
-
# Compile model for faster inference
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 336 |
MODEL_NAME,
|
| 337 |
trust_remote_code=IS_DIFFUSION
|
|
|
|
| 326 |
torch_dtype=torch.bfloat16,
|
| 327 |
trust_remote_code=False
|
| 328 |
).to(device).eval()
|
| 329 |
+
# Compile model for faster inference — ONLY for standard causal models
|
| 330 |
+
if not IS_DIFFUSION:
|
| 331 |
+
try:
|
| 332 |
+
model = torch.compile(model, mode="reduce-overhead", fullgraph=False)
|
| 333 |
+
print("Model compiled with torch.compile.")
|
| 334 |
+
except Exception as e:
|
| 335 |
+
print(f"torch.compile skipped: {e}")
|
| 336 |
+
else:
|
| 337 |
+
print("Diffusion model loaded without torch.compile (custom FX code incompatible with Dynamo).")
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
|
| 341 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 342 |
MODEL_NAME,
|
| 343 |
trust_remote_code=IS_DIFFUSION
|