From 707bbcd72b60320ce0bf5d9f086d89452269f34b Mon Sep 17 00:00:00 2001 From: Yifu Wang <54875093+YFJack@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:36:53 +0800 Subject: [PATCH] Fix: Fix torch.arange bounds error in context window processing Fixed "upper bound and lower bound inconsistent with step sign" error when using WanVideoContextOptions with pose latents. Changed end index from c[-1] to c[-1] + 1 to properly include the last frame in the range. --- nodes_sampler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes_sampler.py b/nodes_sampler.py index 2e8f7c7..76f4769 100644 --- a/nodes_sampler.py +++ b/nodes_sampler.py @@ -1986,13 +1986,13 @@ class WanVideoSampler: partial_wananim_face_pixels = partial_wananim_pose_latents = None if wananim_face_pixels is not None and partial_wananim_face_pixels is None: start = c[0] * 4 - end = c[-1] * 4 + end = c[-1] * 4 + 1 center_indices = torch.arange(start, end, 1) center_indices = torch.clamp(center_indices, min=0, max=wananim_face_pixels.shape[2] - 1) partial_wananim_face_pixels = wananim_face_pixels[:, :, center_indices].to(device, dtype) if wananim_pose_latents is not None: start = c[0] - end = c[-1] + end = c[-1] + 1 center_indices = torch.arange(start, end, 1) center_indices = torch.clamp(center_indices, min=0, max=wananim_pose_latents.shape[2] - 1) partial_wananim_pose_latents = wananim_pose_latents[:, :, center_indices][:, :, :context_frames-1].to(device, dtype)