Spaces:
Running on Zero
Running on Zero
Commit ·
b8216f1
1
Parent(s): e92bb7f
Add heartbeat logging during model loading
Browse filesPrints a progress line every 15s while each from_pretrained call
blocks, so log streams show the space is alive during cold start.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -46,22 +46,37 @@ print("[startup] all imports done", flush=True)
|
|
| 46 |
|
| 47 |
dtype = torch.bfloat16
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
_t0_load = time.perf_counter()
|
| 50 |
print("[startup] loading transformer from_pretrained (prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23)...", flush=True)
|
|
|
|
| 51 |
_transformer = QwenImageTransformer2DModel.from_pretrained(
|
| 52 |
"prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23",
|
| 53 |
torch_dtype=dtype,
|
| 54 |
device_map="cuda",
|
| 55 |
)
|
|
|
|
| 56 |
print(f"[startup] transformer loaded in {time.perf_counter()-_t0_load:.1f}s", flush=True)
|
| 57 |
|
| 58 |
_t1_load = time.perf_counter()
|
| 59 |
print("[startup] loading pipeline from_pretrained (FireRedTeam/FireRed-Image-Edit-1.1)...", flush=True)
|
|
|
|
| 60 |
pipe = QwenImageEditPlusPipeline.from_pretrained(
|
| 61 |
"FireRedTeam/FireRed-Image-Edit-1.1",
|
| 62 |
transformer=_transformer,
|
| 63 |
torch_dtype=dtype,
|
| 64 |
).to(device)
|
|
|
|
| 65 |
print(f"[startup] pipeline loaded in {time.perf_counter()-_t1_load:.1f}s", flush=True)
|
| 66 |
|
| 67 |
print("Using default attention processor (FA3 skipped for ZeroGPU GPU-arch compatibility).", flush=True)
|
|
|
|
| 46 |
|
| 47 |
dtype = torch.bfloat16
|
| 48 |
|
| 49 |
+
|
| 50 |
+
def _start_heartbeat(label: str) -> threading.Event:
|
| 51 |
+
done = threading.Event()
|
| 52 |
+
t0 = time.perf_counter()
|
| 53 |
+
def _beat():
|
| 54 |
+
while not done.wait(timeout=15):
|
| 55 |
+
print(f"[startup] {label} still loading... ({time.perf_counter()-t0:.0f}s)", flush=True)
|
| 56 |
+
threading.Thread(target=_beat, daemon=True).start()
|
| 57 |
+
return done
|
| 58 |
+
|
| 59 |
+
|
| 60 |
_t0_load = time.perf_counter()
|
| 61 |
print("[startup] loading transformer from_pretrained (prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23)...", flush=True)
|
| 62 |
+
_hb = _start_heartbeat("transformer")
|
| 63 |
_transformer = QwenImageTransformer2DModel.from_pretrained(
|
| 64 |
"prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V23",
|
| 65 |
torch_dtype=dtype,
|
| 66 |
device_map="cuda",
|
| 67 |
)
|
| 68 |
+
_hb.set()
|
| 69 |
print(f"[startup] transformer loaded in {time.perf_counter()-_t0_load:.1f}s", flush=True)
|
| 70 |
|
| 71 |
_t1_load = time.perf_counter()
|
| 72 |
print("[startup] loading pipeline from_pretrained (FireRedTeam/FireRed-Image-Edit-1.1)...", flush=True)
|
| 73 |
+
_hb = _start_heartbeat("pipeline")
|
| 74 |
pipe = QwenImageEditPlusPipeline.from_pretrained(
|
| 75 |
"FireRedTeam/FireRed-Image-Edit-1.1",
|
| 76 |
transformer=_transformer,
|
| 77 |
torch_dtype=dtype,
|
| 78 |
).to(device)
|
| 79 |
+
_hb.set()
|
| 80 |
print(f"[startup] pipeline loaded in {time.perf_counter()-_t1_load:.1f}s", flush=True)
|
| 81 |
|
| 82 |
print("Using default attention processor (FA3 skipped for ZeroGPU GPU-arch compatibility).", flush=True)
|