multimodalart HF Staff commited on
Commit
f505dbd
·
verified ·
1 Parent(s): 7e77941

tighten ZeroGPU duration to measured latency (~1s/step/window)

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -413,10 +413,17 @@ def _write_mp4(frames_u8: np.ndarray, fps: int = 15) -> str:
413
 
414
 
415
  def _estimate_duration(*a, **k):
416
- """ZeroGPU reservation: scales with rollout rounds x sampler steps."""
417
- rounds = int(a[10]) if len(a) > 10 else 2
418
- steps = int(a[11]) if len(a) > 11 else 20
419
- return int(min(280, 45 + max(1, rounds) * (8 + max(1, steps) * 2.2)))
 
 
 
 
 
 
 
420
 
421
 
422
  @spaces.GPU(duration=_estimate_duration)
 
413
 
414
 
415
  def _estimate_duration(*a, **k):
416
+ """ZeroGPU reservation, fitted to latency measured on this Space.
417
+
418
+ Client-side end-to-end at 20 sampler steps: 1 window 28.6 s, 2 windows 50.6 s,
419
+ 3 windows 67.2 s -> ~1.0 s per sampler step per window, plus ~12 s of scene
420
+ prep, VAE encode/decode and mp4 muxing. Keeps ~20% headroom, no more.
421
+ """
422
+ rounds = int(a[10]) if len(a) > 10 else int(k.get("rollout_rounds", 2))
423
+ steps = int(a[11]) if len(a) > 11 else int(k.get("num_steps", 20))
424
+ rounds = max(1, min(rounds, 3))
425
+ steps = max(1, min(steps, 40))
426
+ return int(min(180, 12 + rounds * (4 + steps * 1.0)))
427
 
428
 
429
  @spaces.GPU(duration=_estimate_duration)