From f9755820dedae6f9c6aec2547dabdcb511c632d9 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Mon, 1 Sep 2025 14:19:51 +0300 Subject: [PATCH] handle negative latent indices with extra latents --- nodes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nodes.py b/nodes.py index d2bf2fd..aaa3758 100644 --- a/nodes.py +++ b/nodes.py @@ -2314,6 +2314,10 @@ class WanVideoSampler: for entry in extra_latents: add_index = entry["index"] num_extra_frames = entry["samples"].shape[2] + # Handle negative indices + if add_index < 0: + add_index = noise.shape[1] + add_index + add_index = max(0, min(add_index, noise.shape[1] - num_extra_frames)) if start_step == 0: noise[:, add_index:add_index+num_extra_frames] = entry["samples"].to(noise) log.info(f"Adding extra samples to latent indices {add_index} to {add_index+num_extra_frames-1}")