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
Copy link
Copy Markdown
Collaborator

@kijai kijai commented May 27, 2026

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
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

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
Copy link
Copy Markdown
Collaborator Author

kijai commented May 28, 2026

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants