[Bug] IndexError in nodes_sampler.py when using bg_images with context window sampling
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start by reading WanVideoAnimateEmbeds.process and the context-window sampling path around nodes_sampler.py line 1903, where image_cond[:, c] raises the reported IndexError. Reproduce with bg_images connected and WanVideoContextOptions enabled, then trace how the looping path builds the conditioning sequence. Done when the workflow samples without out-of-bounds latent indices; add or run a regression test if the project has one.
Written by the indexing model from the issue text.
Description
Describe the bug
When using the WanVideoAnimateEmbeds node with bg_images connected, the workflow crashes during the sampling stage with an IndexError. This appears to happen when context windowing is active, as the sampler attempts to access latent indices that are out of bounds for the image_cond tensor.
Error Log
Plaintext
IndexError: index 15 is out of bounds for dimension 0 with size 2
File "/root/ComfyUI/execution.py", line 525, in execute
...
File "/root/ComfyUI/custom_nodes/ComfyUI-WanVideoWrapper/nodes_sampler.py", line 1903, in process
partial_img_emb = image_cond[:, c].to(device)
Reproduction Steps
- Create a WanAnimate workflow.
- Connect an image sequence to the
bg_imagesinput of theWanVideoAnimateEmbedsnode. - Enable
WanVideoContextOptions. - Run the queue.
Technical Analysis
In nodes_sampler.py (Line 1903), the code tries to slice the image_cond based on the context window indices c:
partial_img_emb = image_cond[:, c].to(device)
However, in WanVideoAnimateEmbeds.process, when looping is True (triggered by context options), the logic for bg_images does not seem to correctly concatenate the background latents into the ref_latent sequence that eventually becomes image_cond.
Specifically:
- If
loopingis True,ref_latentis initialized only withref_latent_masked(usually size 1 or 2 in the temporal dimension). - The sampler then tries to access indices like
15from a tensor that only has a size of2, causing theIndexError.
- Dominant language
- Python
- Stars
- 6.8k
- Forks
- 712
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kijai/ComfyUI-WanVideoWrapper
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
kijai/ComfyUI-WanVideoWrapper#2060 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
kijai/ComfyUI-WanVideoWrapper#2055 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
kijai/ComfyUI-WanVideoWrapper#2046 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
kijai/ComfyUI-WanVideoWrapper#2058 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
kijai/ComfyUI-WanVideoWrapper#2057 ·
All issues in kijai/ComfyUI-WanVideoWrapper
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
OCA/account-invoicing#2529 ·
Maintainers usually reply within 1 day
-
area/ci
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
ImageGen generate-batch aborts valid JSONL jobs containing a Unicode line separator in poster textOpenbug imagen skills
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Email validation accepts a trailing newlinePossibly taken @marcello-pichini claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day