Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -110,11 +110,13 @@ _SCHEDULE_LOOKUP = {name: (h, l) for name, h, l in SCHEDULES}
|
|
| 110 |
def _estimate_duration(*args, **kwargs) -> int:
|
| 111 |
"""Callable GPU duration, calibrated from measured calls on this Space.
|
| 112 |
|
| 113 |
-
Measured on ZeroGPU:
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
Duration =
|
|
|
|
| 118 |
"""
|
| 119 |
schedule = kwargs.get("schedule") or (args[2] if len(args) > 2 else None)
|
| 120 |
budget = kwargs.get("max_tokens") or (args[3] if len(args) > 3 else 32)
|
|
@@ -123,7 +125,7 @@ def _estimate_duration(*args, **kwargs) -> int:
|
|
| 123 |
except Exception:
|
| 124 |
h, l = 2, 3
|
| 125 |
depth = 16 * h * (l + 1)
|
| 126 |
-
return min(120,
|
| 127 |
|
| 128 |
|
| 129 |
@spaces.GPU(duration=_estimate_duration)
|
|
|
|
| 110 |
def _estimate_duration(*args, **kwargs) -> int:
|
| 111 |
"""Callable GPU duration, calibrated from measured calls on this Space.
|
| 112 |
|
| 113 |
+
Measured on ZeroGPU (cold first call per visitor): 14.1 s at H2L3/32 tok,
|
| 114 |
+
19.3 s at H2L3/96 tok, 39.7 s at H3L3/96 tok. Per-token cost grows
|
| 115 |
+
superlinearly with unrolled depth, so the coefficient is scaled by
|
| 116 |
+
depth/128 with a fixed base that also covers worker init.
|
| 117 |
|
| 118 |
+
Duration = 25 + budget x 0.2 s/token scaled by depth/128, capped at 120 s.
|
| 119 |
+
Worst offered case (H3L3, 96 tok) resolves to ~54 s vs 39.7 s measured.
|
| 120 |
"""
|
| 121 |
schedule = kwargs.get("schedule") or (args[2] if len(args) > 2 else None)
|
| 122 |
budget = kwargs.get("max_tokens") or (args[3] if len(args) > 3 else 32)
|
|
|
|
| 125 |
except Exception:
|
| 126 |
h, l = 2, 3
|
| 127 |
depth = 16 * h * (l + 1)
|
| 128 |
+
return min(120, 25 + int(float(budget) * 0.2 * depth / 128))
|
| 129 |
|
| 130 |
|
| 131 |
@spaces.GPU(duration=_estimate_duration)
|