Nodes/ComfyUI-ClipReshaper/Clip Reshaper: Assert Dim
ComfyUI Node

Clip Reshaper: Assert Dim

A tripwire that catches dimension crashes before KSampler does

By thezveroboy·Created 9 months ago·Updated 9 months ago· 2
Clip Reshaper: Assert Dim
  • conditioning
  • CONDITIONING
expected_dim768

Some errors you want to hit sooner, not later. When a conditioning tensor's last dimension doesn't match what a model expects, ComfyUI doesn't complain at the text encoder - it crashes deep inside a KSampler's matrix multiply with mat1 and mat2 shapes cannot be multiplied, and you're left staring at a giant tensor-shape stack trace trying to remember which node could possibly have produced a 320-wide vector. Clip Reshaper: Assert Dim exists to make that a clean, immediate, readable error instead.

What it does

It's a tripwire, and it's honest about being one. You set expected_dim - the dimension your model's conditioning is supposed to be - and the node walks every item in your conditioning, checks that the last dimension equals it, and passes the conditioning straight through untouched if everything matches. The moment any item differs, it raises an exception that names the offending item, the dimension it found, and the dimension you expected. The author even embeds the hint you'll recognize: this kind of mismatch is what turns into that matmul crash later.

The inputs

The inputs are exactly two: conditioning and expected_dim (an INT, default 768, range 1–65536). Default 768 is the SD 1.5 CLIP dimension - change it to 1280 for SDXL's OpenCLIP-G, or whatever dimension your encoder or adapter actually produces. The single output is a passthrough CONDITIONING, so you can drop this node inline between a CLIPTextEncode and the KSampler without altering the data at all. That's the whole trick: it costs you nothing on the happy path and converts a confusing crash into a self-explanatory one.

This is the node for the situation where you're deliberately mixing encoders or experimenting with cross-model adapters and you want to know, instantly, whether your construction actually produced compatible shapes. It's also a genuinely useful guard when you load a workflow off the internet: stick it in front of the sampler, set expected_dim to what the workflow's model needs, and the first run tells you whether that exotic text-encoder setup you grabbed is the reason your generations refuse to start.

A tripwire, not a fix

Just don't mistake a tripwire for a fix. Assert Dim catches the mismatch and tells you where - it does nothing to resolve it. If you need to cross a dimension gap deliberately (say, shove 768-dim SD 1.5 conditioning into an SDXL-shaped pipeline for an experiment), you're looking for the pack's CR_ConditioningPadOrSlice or CR_ConditioningLinearProject instead. Assert is the check; those are the hacks.

Install

Installation is the standard one for this pack: ComfyUI Manager, search "Clip Reshaper", install, restart. Or manually:

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

No extra dependencies, no model downloads - it's a few dozen lines of validation over torch tensors. One thing worth knowing about the pack generally: it's small and from a niche author, so treat the nodes as utilities rather than polished products. But for "tell me loudly that my conditioning shape is wrong, before the sampler does it confusingly," Assert Dim does exactly what it says on the tin.

CategoryClip Reshaper

Inputs (2)

NameTypeDefaultDescription
conditioningCONDITIONING
expected_dimINT7681–65536

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING