Nodes/ComfyUI-ClipReshaper/Clip Reshaper: Ensure SDXL Metadata
ComfyUI Node

Clip Reshaper: Ensure SDXL Metadata

When SDXL conditioning is missing its size metadata, this patches the holes

By thezveroboy·Created 9 months ago·Updated 9 months ago· 2
Clip Reshaper: Ensure SDXL Metadata
  • conditioning
  • CONDITIONING
width1024
height1024
ensure_pooled_outputtrue

SDXL is the odd one out when it comes to conditioning. Its text-encoder output doesn't just carry the token embeddings - the metadata dict on each conditioning item also records the generation size and crop, and it ships a separate pooled_output vector (a 1280-dim global summary of the prompt). A bunch of SDXL-specific nodes downstream quietly expect those fields to exist. When they're missing, you get errors that are hard to trace, or behavior that's subtly wrong instead of loudly broken.

Clip Reshaper: Ensure SDXL Metadata exists for exactly that hole: it guarantees the SDXL-style fields are present on every conditioning item, no matter where the conditioning came from.

How it works

The mechanism is defensive by design. For each item it calls setdefault on the metadata - meaning it only fills fields that are missing, never clobbers values a real encoder already wrote. It sets width and height from your inputs, zeroes crop_w and crop_h, and sets target_width / target_height to match. Then, if ensure_pooled_output is on and the item has no pooled_output yet, it synthesizes one by taking the mean of the token embeddings across the token dimension. The node otherwise leaves your tensors alone and returns the enriched CONDITIONING.

Inputs

The inputs, all required:

  • conditioning - whatever you suspect is missing metadata.
  • width (INT, default 1024, 64–8192, steps of 8) and height (same) - the size fields to stamp in.
  • ensure_pooled_output (BOOLEAN, default true) - whether to synthesize a pooled vector when one's absent.

This is the node you want when you've hand-built conditioning, routed through a custom encoder or a cross-model adapter, and an SDXL pipeline downstream is choking on missing width/pooled_output. It's also handy for poking at workflows from the community that do weird things to conditioning before the sampler.

The caveat

Now the caveat, and it's an honest one: the synthesized pooled_output is a mean-pooled average of the sequence, which is not the same as the real thing. A proper SDXL text encoder produces pooled_output from a dedicated projection of the last hidden state - a learned summary, not an arithmetic mean. Mean pooling will usually stop the shape errors and give you something plausible, but it's an approximation, and for quality-sensitive work you should treat the result with suspicion rather than as equivalent to real SDXL conditioning. This node fixes structure; it doesn't restore lost semantics.

Install

Same caveat as the rest of the pack, too: it's a niche utility from a small author (thezveroboy) with no community footprint to speak of, so think of it as a targeted patch, not a polished ecosystem tool. Install once for the whole Clip Reshaper family through ComfyUI Manager (search "Clip Reshaper") or:

cd ComfyUI/custom_nodes
git clone https://github.com/thezveroboy/ComfyUI-ClipReshaper

Restart, and you're set - no extra packages, no model downloads. If you're wrestling with an SDXL pipeline that insists on metadata nobody gave it, this is the band-aid that gets you moving again.

CategoryClip Reshaper

Inputs (4)

NameTypeDefaultDescription
conditioningCONDITIONING
widthINT102464–8192
heightINT102464–8192
ensure_pooled_outputBOOLEANtrue

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING