Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,35 +57,36 @@ pipe.to("cuda")
|
|
| 57 |
# ---------------------------------------------------------------------------
|
| 58 |
# 🔥 AOT LOADING LOGIC 🔥
|
| 59 |
# ---------------------------------------------------------------------------
|
| 60 |
-
AOT_FILENAME = "helios_distilled_transformer.pt2"
|
| 61 |
-
AOT_PATH = os.path.join(_APP_DIR, AOT_FILENAME)
|
| 62 |
-
|
| 63 |
-
def load_aot_model(path, original_module):
|
| 64 |
-
"""
|
| 65 |
-
Loads a raw AOTI package (.pt2) and patches the original module.
|
| 66 |
-
"""
|
| 67 |
-
print(f"[AOT] Loading AOTI package from {path}...")
|
| 68 |
-
|
| 69 |
-
compiled_model = torch._inductor.aoti_load_package(path)
|
| 70 |
-
|
| 71 |
-
original_module.forward = compiled_model
|
| 72 |
-
|
| 73 |
-
original_module.to("meta")
|
| 74 |
-
|
| 75 |
-
print("[AOT] Model patched successfully!")
|
| 76 |
-
|
| 77 |
-
if os.path.exists(AOT_PATH):
|
| 78 |
-
try:
|
| 79 |
-
load_aot_model(AOT_PATH, pipe.transformer)
|
| 80 |
-
print(f"[AOT] ✅ Loaded compiled graph: {e}")
|
| 81 |
-
except Exception as e:
|
| 82 |
-
print(f"[AOT] ❌ Failed to load compiled graph: {e}")
|
| 83 |
-
# Restore device if failed
|
| 84 |
-
pipe.to("cuda")
|
| 85 |
-
pipe.transformer.set_attention_backend("_flash_3_hub")
|
| 86 |
-
else:
|
| 87 |
-
print(f"[AOT] ⚠️ No compiled graph found at {AOT_PATH}.")
|
| 88 |
-
|
|
|
|
| 89 |
|
| 90 |
# ---------------------------------------------------------------------------
|
| 91 |
# Generation
|
|
|
|
| 57 |
# ---------------------------------------------------------------------------
|
| 58 |
# 🔥 AOT LOADING LOGIC 🔥
|
| 59 |
# ---------------------------------------------------------------------------
|
| 60 |
+
# AOT_FILENAME = "helios_distilled_transformer.pt2"
|
| 61 |
+
# AOT_PATH = os.path.join(_APP_DIR, AOT_FILENAME)
|
| 62 |
+
|
| 63 |
+
#def load_aot_model(path, original_module):
|
| 64 |
+
# """
|
| 65 |
+
# Loads a raw AOTI package (.pt2) and patches the original module.
|
| 66 |
+
# """
|
| 67 |
+
# print(f"[AOT] Loading AOTI package from {path}...")
|
| 68 |
+
#
|
| 69 |
+
# compiled_model = torch._inductor.aoti_load_package(path)
|
| 70 |
+
#
|
| 71 |
+
# original_module.forward = compiled_model
|
| 72 |
+
#
|
| 73 |
+
# original_module.to("meta")
|
| 74 |
+
#
|
| 75 |
+
# print("[AOT] Model patched successfully!")
|
| 76 |
+
|
| 77 |
+
#if os.path.exists(AOT_PATH):
|
| 78 |
+
# try:
|
| 79 |
+
# load_aot_model(AOT_PATH, pipe.transformer)
|
| 80 |
+
# print(f"[AOT] ✅ Loaded compiled graph: {e}")
|
| 81 |
+
# except Exception as e:
|
| 82 |
+
# print(f"[AOT] ❌ Failed to load compiled graph: {e}")
|
| 83 |
+
# # Restore device if failed
|
| 84 |
+
# pipe.to("cuda")
|
| 85 |
+
# pipe.transformer.set_attention_backend("_flash_3_hub")
|
| 86 |
+
#else:
|
| 87 |
+
# print(f"[AOT] ⚠️ No compiled graph found at {AOT_PATH}.")
|
| 88 |
+
|
| 89 |
+
pipe.transformer.set_attention_backend("_flash_3_hub")
|
| 90 |
|
| 91 |
# ---------------------------------------------------------------------------
|
| 92 |
# Generation
|