multimodalart HF Staff commited on
Commit
adb1853
·
verified ·
1 Parent(s): 840ab96

Calibrate ZeroGPU duration from measured runs; cap steps at 40

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -216,7 +216,14 @@ def _estimate_duration(
216
  *args,
217
  **kwargs,
218
  ):
219
- """ZeroGPU duration estimate: overhead + per-DiT-pass cost × number of passes."""
 
 
 
 
 
 
 
220
  latent_t = (int(num_frames) - 1) // 4 + 1
221
  passes = 1
222
  if float(cfg_scale) != 1.0:
@@ -225,8 +232,8 @@ def _estimate_duration(
225
  passes += 1
226
  if float(state_cfg_scale) != 1.0 and float(cfg_scale) == 1.0:
227
  passes += 1
228
- total = 55.0 + 0.085 * latent_t * passes * int(num_inference_steps)
229
- return int(min(300, math.ceil(total)))
230
 
231
 
232
  @spaces.GPU(duration=_estimate_duration)
@@ -440,7 +447,7 @@ with gr.Blocks(title="StatePlay") as demo:
440
  num_frames = gr.Dropdown(
441
  [41, 61, 81, 101], value=101, label="Frames (20 fps)"
442
  )
443
- steps = gr.Slider(10, 50, value=30, step=1, label="Denoising steps")
444
  cfg = gr.Slider(1.0, 10.0, value=5.0, step=0.1, label="Text CFG")
445
  action_cfg = gr.Slider(
446
  1.0, 5.0, value=1.0, step=0.1, label="Action CFG (1.0 = off)"
 
216
  *args,
217
  **kwargs,
218
  ):
219
+ """ZeroGPU duration estimate: fixed overhead + per-DiT-pass cost x number of passes.
220
+
221
+ Calibrated on zero-a10g (Blackwell, bf16, SDPA) against two measured runs:
222
+ 41 frames / 10 steps / cfg 5.0 -> 14.4 s (latent_t 11, 2 passes)
223
+ 101 frames / 30 steps / cfg 5.0 -> 94.6 s (latent_t 26, 2 passes)
224
+ Both fit t = 1.2 + 0.0599 * latent_t * passes * steps within 4%, i.e. cost is
225
+ essentially linear in latent length. The coefficients below add ~25-30% margin.
226
+ """
227
  latent_t = (int(num_frames) - 1) // 4 + 1
228
  passes = 1
229
  if float(cfg_scale) != 1.0:
 
232
  passes += 1
233
  if float(state_cfg_scale) != 1.0 and float(cfg_scale) == 1.0:
234
  passes += 1
235
+ total = 8.0 + 0.075 * latent_t * passes * int(num_inference_steps)
236
+ return int(min(260, math.ceil(total)))
237
 
238
 
239
  @spaces.GPU(duration=_estimate_duration)
 
447
  num_frames = gr.Dropdown(
448
  [41, 61, 81, 101], value=101, label="Frames (20 fps)"
449
  )
450
+ steps = gr.Slider(10, 40, value=30, step=1, label="Denoising steps")
451
  cfg = gr.Slider(1.0, 10.0, value=5.0, step=0.1, label="Text CFG")
452
  action_cfg = gr.Slider(
453
  1.0, 5.0, value=1.0, step=0.1, label="Action CFG (1.0 = off)"