Skip to content

Support context window for PiD and fix lq_latent rounding#14136

Merged
comfyanonymous merged 26 commits into
Comfy-Org:masterfrom
kijai:pixeldit
May 27, 2026
Merged

Support context window for PiD and fix lq_latent rounding#14136
comfyanonymous merged 26 commits into
Comfy-Org:masterfrom
kijai:pixeldit

Conversation

@kijai

@kijai kijai commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Context windows are a way to handle the aspect ratio limitations of the model, also noticed mismatch with some dimensions due to rounding differences, so two fixes:

  • Context window slicing needed to account for the lq_latent scaling

  • PiD upscaling failed with a tensor size mismatch when the output width or height wasn't a multiple of 16. The two halves of the model rounded the size differently, so they ended up one row/column apart and couldn't be combined.

ComfyUI_temp_fhnkx_00020_ image

Also in this situation almost halves peak VRAM use:

image

Context window settings (easier to use node specific to this model can be added later):

image
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@comfyanonymous comfyanonymous merged commit 987a937 into Comfy-Org:master May 27, 2026
16 of 17 checks passed
@makisekurisu-jp

Copy link
Copy Markdown

Context windows are a way to handle the aspect ratio limitations of the model, also noticed mismatch with some dimensions due to rounding differences, so two fixes:

  • Context window slicing needed to account for the lq_latent scaling
  • PiD upscaling failed with a tensor size mismatch when the output width or height wasn't a multiple of 16. The two halves of the model rounded the size differently, so they ended up one row/column apart and couldn't be combined.

ComfyUI_temp_fhnkx_00020_ image
Also in this situation almost halves peak VRAM use:

image Context window settings (easier to use node specific to this model can be added later): image

ValueError: Input latent has 3 channels, this model variant expects 16. Flux1/SD3 = 16 channels, Flux2 = 128 channels.
workflow

@kijai

kijai commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

Context windows are a way to handle the aspect ratio limitations of the model, also noticed mismatch with some dimensions due to rounding differences, so two fixes:

  • Context window slicing needed to account for the lq_latent scaling
  • PiD upscaling failed with a tensor size mismatch when the output width or height wasn't a multiple of 16. The two halves of the model rounded the size differently, so they ended up one row/column apart and couldn't be combined.

ComfyUI_temp_fhnkx_00020_ image
Also in this situation almost halves peak VRAM use:

image Context window settings (easier to use node specific to this model can be added later): image

ValueError: Input latent has 3 channels, this model variant expects 16. Flux1/SD3 = 16 channels, Flux2 = 128 channels.
workflow

PiD only supports flux or sd3 latents, you can't feed pixel space into it like that.

@Hermit6202

Copy link
Copy Markdown

What is the latent_retain_index_list setting in the context window manual node?

@kijai

kijai commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

What is the latent_retain_index_list setting in the context window manual node?

That's only relevant to I2V video models, since each window is it's own model pass, that setting allows applying image conditioning to each window that would otherwise just default to T2V generation. The downside in that case is that each window can basically "reset" to the start image instead of continued motion, so in practice it's only useful when the model treats the image as reference rather than start frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants