UniBlockSwap Cache Control
The cleanup node that does almost nothing — and keeps your low-VRAM rig alive
- model
- model
Look at this node and your first thought is that someone shipped a joke. One MODEL in, one MODEL out, no settings, and the model you put in comes back untouched. It's a wire. But it's the wire that stops the whole UniBlockSwap pack from quietly eating your LoRAs, and it's the reason you'll actually get stable runs on a 4–6GB card. The author - smthemex, the same prolific porter behind packs like ComfyUI_TwinFlow - targets exactly those users: people running Minimax, Klein 9B, Bernini, or Krea 2 that the stock ComfyUI loader would never squeeze onto low VRAM.
Why this node exists
UniBlockSwap and UniBlockSwapTE are the stars of the pack: they install "block swap," keeping a few blocks of the diffusion model (or text encoder) resident in VRAM while the rest lazy-loads from RAM/disk - the same trick that made Flux DreamBooth fit on 6GB cards. But that install is a one-time, structural wrap of the model, and re-running it is actively bad. In older versions the pack forced a re-run every inference via IS_CHANGED, and each re-run re-wrapped the shared model object and could wipe LoRA patches off the quantized GGMLTensor weights - the "changing num_blocks broke my LoRA" bug class the changelog keeps fixing.
UniBlockSwapCacheControl is the replacement for that hack. It re-runs every inference too - but instead of reinstalling swap, it does one cheap, safe thing: it walks ComfyUI's loaded models and unloads everything except the model you pass in. Text encoder, VAE, any leftover patchers - kicked back to CPU RAM, cache emptied, VRAM reserved for the diffusion model's next block load. Then it passes your model through byte-for-byte, leaving the swap install and its LoRA attachments intact.
How it works
Inside, it calls clear_comfyui_cache_except(model), looping over comfy.model_management.loaded_models() and unpatching each to CPU - skipping any patcher that shares the underlying model object with yours, since unpatching a shared object is exactly what used to kill LoRAs. Then it soft-empties the cache and prints an After Max GPU memory allocated: X.XX GB line to your console. That print is normal; it's a diagnostic, not an error.
IS_CHANGED returns a fresh random UUID every call, so ComfyUI re-executes the node on every queue run. The key design decision: the side effect is cache clearing only, never a swap reinstall, so it's safe to fire constantly. The swap nodes, meanwhile, deliberately have no IS_CHANGED, because re-wrapping is the destructive thing. Clean separation: install once, clean every run.
The inputs and outputs that matter
There's exactly one of each, and you don't tune either.
model(input,MODEL, required) - the swapped diffusion model coming out of aUniBlockSwapnode. This is the model that gets protected from eviction; everything else gets unloaded.model(output,MODEL) - the same model, untouched. Wire it into yourKSampler's model input.
Placement is the whole trick, straight from the author: UniBlockSwap → UniBlockSwapCacheControl → KSampler. Put it anywhere else and it's harmless but pointless.
Installing it
It ships with the rest of the pack, so install the pack once and you get all three nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/smthemex/ComfyUI_UniBlockSwap
Then restart ComfyUI. ComfyUI Manager also finds it by searching "ComfyUI_UniBlockSwap" (it's in the Comfy registry). No Python dependencies beyond ComfyUI and torch - no requirements.txt to fight with. What does cost you is the models: this pack exists to run big quantized checkpoints, so expect GGUF downloads and a text encoder that dwarfs the diffusion model, especially with the Klein and Qwen encoders.
What to expect and the traps
- It only matters if you're swapping. No
UniBlockSwaporUniBlockSwapTEin front of it? The node is a no-op for you. Skip it. - Set
num_blockson the swap node sensibly.0disables swap entirely, which makes this node pointless;-1(one resident block) is the most VRAM-frugal, and>= total blocksmeans no swap at all. - If LoRAs silently stop applying, check the wiring: this node must sit after the swap node and before the sampler. The pack has burned a lot of changelog on LoRA + swap interactions, and the current guard logic is the fix - don't route around it.
- Watch RAM, not just VRAM. Swapping trades VRAM for system RAM, and ComfyUI can't substitute RAM for VRAM gracefully once you overshoot. Keep resolutions and frame counts reasonable, or you'll slide into slow shared-memory territory - the README warns the swap path isn't faster than native, it's just cheaper on VRAM.
That's the whole node. It's boring on purpose, and boring is exactly what your 6GB rig needs.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |