@@ -1212,15 +1212,18 @@ def sample(
12121212 )
12131213
12141214 # Store initial noise for velocity replacement
1215- initial_noise = latents . clone ()
1215+ initial_noise = noise
12161216
1217- for timestep in tqdm (timesteps , total = len (timesteps ), desc = "Sampling" ):
1217+ total_steps = len (timesteps )
1218+ for step_idx , timestep in enumerate (tqdm (timesteps , total = total_steps , desc = "Sampling" )):
12181219 # Normalize timestep to [0, 1] range
12191220 t = (timestep / self .sample_scheduler .config .num_train_timesteps ).expand (latents .shape [0 ])
12201221 t = self .noise_scheduler .safe_clamp (t , min = self .noise_scheduler .min_t , max = self .noise_scheduler .max_t ).to (
12211222 latents .dtype
12221223 )
12231224
1225+ active_skip_layers = skip_layers if (step_idx / total_steps ) >= skip_layers_start_percent else None
1226+
12241227 if video2world_mode :
12251228 # Replace conditioning frames with clean latents using preserve_conditioning
12261229 v2w_condition = {"conditioning_latents" : conditioning_latents , "condition_mask" : condition_mask }
@@ -1249,6 +1252,7 @@ def sample(
12491252 cond_with_mask ,
12501253 fps = fps ,
12511254 conditional_frame_timestep = conditional_frame_timestep ,
1255+ skip_layers = active_skip_layers ,
12521256 )
12531257
12541258 # Classifier-free guidance
@@ -1259,6 +1263,7 @@ def sample(
12591263 neg_cond_with_mask ,
12601264 fps = fps ,
12611265 conditional_frame_timestep = conditional_frame_timestep ,
1266+ skip_layers = active_skip_layers ,
12621267 )
12631268 velocity_pred = velocity_uncond + guidance_scale * (velocity_pred - velocity_uncond )
12641269
0 commit comments