@@ -491,21 +491,18 @@ def run_inference_2_2_i2v(
491491 latents , scheduler_state = scheduler .step (scheduler_state , noise_pred , t , latents ).to_tuple ()
492492 continue
493493
494- dx_norm = jnp .sqrt (jnp .mean ((latents - ref_latent ) ** 2 ))
495- dt = jnp . abs (t_float - ref_timestep )
494+ dx_norm = float ( jnp .sqrt (jnp .mean ((latents - ref_latent ) ** 2 ) ))
495+ dt = abs (t_float - ref_timestep )
496496 accum_dx += dx_norm
497497 accum_dt += dt
498498
499499 score = alpha_x * accum_dx + alpha_t * accum_dt
500500
501- cond = jnp .logical_and (score <= sen_epsilon , reuse_count < max_reuse )
502-
503- def hit_fn (args ):
504- ref_noise_pred , ref_latent , ref_timestep , accum_dx , accum_dt , reuse_count , cache_count = args
505- return ref_noise_pred , ref_latent , ref_timestep , accum_dx , accum_dt , reuse_count + 1 , cache_count + 1
506-
507- def miss_fn (args ):
508- _ , _ , _ , _ , _ , _ , cache_count = args
501+ if score <= sen_epsilon and reuse_count < max_reuse :
502+ noise_pred = ref_noise_pred
503+ reuse_count += 1
504+ cache_count += 1
505+ else :
509506 latents_doubled = jnp .concatenate ([latents , latents ], axis = 0 )
510507 latents_doubled = jnp .transpose (latents_doubled , (0 , 4 , 1 , 2 , 3 ))
511508 latent_model_input = jnp .concatenate ([latents_doubled , condition_doubled ], axis = 1 )
@@ -524,19 +521,12 @@ def miss_fn(args):
524521 encoder_attention_mask = encoder_attention_mask ,
525522 )
526523 noise_pred = jnp .transpose (noise_pred , (0 , 2 , 3 , 4 , 1 ))
527- return (
528- noise_pred ,
529- latents ,
530- jnp .array (t_float , dtype = jnp .float32 ),
531- jnp .array (0.0 , dtype = jnp .float32 ),
532- jnp .array (0.0 , dtype = jnp .float32 ),
533- jnp .array (0 , dtype = jnp .int32 ),
534- cache_count ,
535- )
536-
537- noise_pred , ref_latent , ref_timestep , accum_dx , accum_dt , reuse_count , cache_count = jax .lax .cond (
538- cond , hit_fn , miss_fn , (ref_noise_pred , ref_latent , ref_timestep , accum_dx , accum_dt , reuse_count , cache_count )
539- )
524+ ref_noise_pred = noise_pred
525+ ref_latent = latents
526+ ref_timestep = t_float
527+ accum_dx = 0.0
528+ accum_dt = 0.0
529+ reuse_count = 0
540530
541531 latents , scheduler_state = scheduler .step (scheduler_state , noise_pred , t , latents ).to_tuple ()
542532
0 commit comments