multimodalart HF Staff commited on
Commit
2c1f9ea
·
verified ·
1 Parent(s): 5144d1b

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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: ~0.081 s/token at 128 unrolled layers, roughly
114
- proportional to depth; ~2.5 s fixed plus up to ~9 s one-time init on a
115
- visitor's first call. The 20 s base covers init + prefill + margin.
 
116
 
117
- Duration = 20 + budget x (0.12 s/token scaled by depth/128), capped.
 
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, 20 + int(float(budget) * 0.12 * depth / 128))
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)