Nodes/ComfyUI-NO8D-controls/NO8D-Match Krea2 Reference Latents
ComfyUI Node

NO8D-Match Krea2 Reference Latents

Keep the edit reference, fix its size

By no8d·Created 2 months ago·Updated 14 days ago· 271
NO8D-Match Krea2 Reference Latents
  • conditioning
  • target_latent
  • conditioning
methodbilinear

In the Ostris Krea2 Edit workflow, your reference image rides inside the conditioning as reference_latents - a list of latent grids the edit-model patch reads during sampling. That metadata was encoded at whatever resolution you fed it, and it isn't tied to your target latent's size. Change the target size mid-workflow - drop from 1024 to 768, switch to portrait - and the reference grid and the generation grid can disagree. ComfyUI won't stop you; you'll just get output that's subtly wrong, or a size mismatch error from the edit patch.

NO8D-Match Krea2 Reference Latents is the alignment fix. It takes your conditioning, your target latent, and an interpolation method, and returns the conditioning with every reference latent resized to match the target latent's spatial grid - prompt conditioning and all other metadata untouched.

What you set

  • conditioning - the conditioning carrying the Krea2 reference latents.
  • target_latent - the latent your generation is actually running at. The node reads the target's grid (its height/width in latent space) and resizes every reference to match.
  • method - the interpolation: bilinear (default), bicubic, nearest-exact, or area. The defaults are sensible; bilinear is the safe all-around choice, area is better when downscaling (it averages), nearest-exact keeps hard edges at the cost of aliasing.

Output is conditioning - same entries, same prompt, same VLM conditioning, with reference latents resized in place.

How it works

Straight from the source: it walks each conditioning entry, and if the entry's metadata has reference_latents, it interpolates each one to the target grid using the selected method, preserving the original dtype. It handles both 4D and 5D tensors - the 5D case is the frames-shaped variant, which it flattens, resizes, and restores. Entries without reference latents pass through untouched.

Why you'd reach for it

The resize-in-place behavior is the whole reason it's better than the obvious alternative of re-encoding the reference image every time you change resolution. Re-encoding is slow, re-runs your VAE, and can shift the reference's character; this node just geometrically rescales what's already in the conditioning, so it's cheap and leaves everything else alone. It's the tool for the "I changed my target size, keep my reference" moment - and it complements NO8D-Remove Krea2 Reference Latents for the "I changed my mind entirely" moment.

The honest scope

It matches size, not content - rescaling a reference latent can't recover detail the original encoding didn't have, and aggressive upscales will look soft. And as with everything in the Krea2-edit corner, remember the technique is experimental: the community reports the edit path can alter the input image and trip over wide aspect ratios, so validate the final image rather than trusting the pipeline silently. This node makes the sizes agree; it doesn't make the edit good.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/no8d/ComfyUI-NO8D-controls.git
python -m pip install -r requirements.txt

ComfyUI Manager → "NO8D-controls". No models. Requires an upstream Krea2 Edit workflow that puts reference latents into the conditioning in the first place.

CategoryNO8D-control

Inputs (3)

NameTypeDefaultDescription
conditioningCONDITIONING
target_latentLATENT
methodCOMBObilinear4 options: bilinear, bicubic, nearest-exact, area

Outputs (1)

NameTypeDescription
conditioningCONDITIONING