Andhs commited on
Commit
6c8447d
·
verified ·
1 Parent(s): eca03f4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
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 (reduce-overhead is safest for generative loops)
330
- try:
331
- model = torch.compile(model, mode="reduce-overhead", fullgraph=False)
332
- print("Model compiled with torch.compile.")
333
- except Exception as e:
334
- print(f"torch.compile skipped: {e}")
 
 
 
 
 
 
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