Nodes/DOGMA Nodes/DOGMA Local VLM Barrier v26
ComfyUI Node

DOGMA Local VLM Barrier v26

Unload the VLM before Klein, or watch your second pass OOM

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMA Local VLM Barrier v26
  • crops
  • reference_crops
  • crop_masks
  • stitch
  • crops
  • reference_crops
  • crop_masks
  • stitch
  • prompts
  • preview
prompts
unload_modelstrue

This is the node in the pack that people will find, use, and never quite understand why they needed. It does two things: it holds five parallel lists together while you send twenty crops through a vision-language model, and then it evicts that model from VRAM before the Klein pass runs. DOGMALocalVLMBarrierV26.

Why a "barrier" exists

A category-by-category restoration run looks like this: cluster the masks into groups, crop each group, send each crop to a Qwen-VL, get a sentence per crop, then feed crop + mask + prompt to a local diffusers pass. That's two large models live in the same run - the VLM you used to describe the regions, and the Klein checkpoint you use to repair them.

ComfyUI is decent at loading and unloading models for you, but not reliably at the boundary between "my VLM node just finished its twentieth image" and "a different, big model is about to do nineteen sampling passes". On a 16GB card that boundary is where the run dies with a VRAM error several minutes in, usually phrased as if the sampler were the problem.

So this node sits on that boundary and does it explicitly. With unload_models left on - it defaults to true - it calls ComfyUI's model manager to unload everything, empties the soft cache, and forces a garbage collection before releasing the lists downstream. That's it. That's the trick.

The lists, and the truncation

The rest of the node is plumbing. crops, reference_crops, crop_masks, stitch and prompts all come in as lists, and they all go back out as lists with the same list type, so the crop-edit-stitch chain stays aligned end to end. Before returning, it computes the shortest of the five and truncates every list to that length. If your VLM step dropped a prompt or your clustering emitted a different number of masks than crops, you don't get a crash - you get quietly fewer groups. Which is better than exploding halfway through a batch, but it will hide a mismatch, so check the count when a run produces fewer crops than your planner named.

stitch is the pack's DOGMA_STITCH type - the per-crop metadata (source coordinates, size, group id, members) that the stitch node needs to put the patch back in the right place. Passing it through here is what lets the stitch happen after the model swap instead of before.

And preview is a plain STRING output: the prompts, numbered by group, concatenated. Wire it to a text preview node and you can read exactly what your VLM said about every region in one place. On a long run that's the fastest sanity check you have - if group 7's prompt is nonsense, you'll see it without digging through a console log.

Inputs and outputs

crops, reference_crops, crop_masks, stitch, prompts (all forceInput), plus the unload_models boolean. Out: the same five as lists, plus preview.

Install

ComfyUI Manager → search DOGMA Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes

Restart. No pip installs - the unload path uses comfy.model_management, which you already have.

Where it bites

Turning unload_models off is the right move if you have VRAM to spare and a second VLM pass later in the same graph, because you'll pay a full reload. Otherwise leave it on.

The truncation is the sharp edge. If a list lengths mismatch, everything silently shortens to the shortest - so the node that caused the mismatch is the one to go looking at, and you'll be looking at the wrong node if you assume this one broke. Check the preview output's group count against your planner's category count.

And this only helps if the VLM is actually unloadable at that point. If something else in the graph still holds a reference to the vision model, freeing VRAM now just means it gets loaded again immediately, and you've paid the reload for nothing.

CategoryDOGMA/Semantic Detailer

Inputs (6)

NameTypeDefaultDescription
cropsIMAGE
reference_cropsIMAGE
crop_masksMASK
stitchDOGMA_STITCH
promptsSTRING
unload_modelsBOOLEANtrue

Outputs (6)

NameTypeDescription
cropsIMAGE
reference_cropsIMAGE
crop_masksMASK
stitchDOGMA_STITCH
promptsSTRING
previewSTRING