(Deno) Text Encoder Unload
(Deno) Text Encoder Unload, decoded
- value
- clip
- wait_for
- value
The text encoder used to be a rounding error. On SD 1.5 it was a few hundred MB of CLIP that loaded and vanished. Then T5-XXL showed up, and Gemma, and Qwen3, and Mistral-3 - the encoder on Flux 2 Dev is a 24B model sitting on top of the diffusion model. That thing eats VRAM while it's resident, and ComfyUI's dynamic memory management doesn't always shove it aside fast enough for the heavy part: sampling. That's the gap this node fills.
What it actually is
(Deno) Text Encoder Unload is a passthrough node with a side effect. You wire one value through it - normally your positive or negative conditioning - and it hands that value to the sampler exactly unchanged. The real job happens in between: it tells ComfyUI's model management to unload the specific CLIP/text encoder you connect, then force-empties the GPU cache. Diffusion models, VAEs, and ControlNets are left alone. It's an opt-in VRAM barrier you drop in at the point where every text encode is done and nothing downstream needs the encoder again.
The name is honest, which is refreshing. It doesn't "manage memory" or "optimize anything" - it unloads one encoder, deterministically, when you tell it to.
How it works
Behind the curtain it calls ComfyUI's built-in unload_model_and_clones on the CLIP's patcher, then soft_empty_cache(force=True). Two details matter for how you treat it:
- It only unloads the exact CLIP you connect and its clones. Connect the same CLIP output your text encode nodes used, not a sibling.
- It's deliberately uncacheable - the node forces a fresh run every queue so ComfyUI can't skip the unload when another branch reuses the same inputs. That's a feature, but it means the node always executes.
It also refuses to run if your CLIP's load and offload devices are both the GPU - which happens under --gpu-only. There's nothing to move it to, so it errors with a readable message instead of silently doing nothing.
The three inputs and one output
value(required) - anything you want passed through; typically conditioning, wired inline before the sampler. It comes out unchanged on thevalueoutput.clip(required) - the exact CLIP/text encoder to unload. Same one your encoders used.wait_for(optional) - the other positive/negative conditioning branch. This is the classic setup: positive throughvalue, negative intowait_for, and both encodes finish before the unload fires.
One node, three wires, and you've freed encoder VRAM for the sampler run.
Installing it
It ships in the Deno Custom Nodes pack. Easiest is ComfyUI Manager: search "Deno Custom Nodes", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/Deno2026/comfyui-deno-custom-nodes.git
cd comfyui-deno-custom-nodes
python -m pip install -r requirements.txt
The pack's requirements.txt only pulls in openai-whisper (for a different node in the pack - this one needs nothing extra). No model files to download for the node itself.
Where people get burned
- It frees headroom, not guarantees. The README is blunt: it cannot make the process use 0 MiB. CUDA context, conditioning tensors, and other models stay put. What it buys you is less offloading churn - and sometimes the difference between fitting and an OOM.
- Re-encoding reloads it. If a later node encodes text again, the encoder loads back, slower than before. Use it in single-encode or refiner-style workflows, not in the middle of a loop that re-encodes every pass.
- Needs a recent ComfyUI. It uses
unload_model_and_clones, which requires ComfyUI 0.23.0+. If you're on a truly old build, update first.
It's a small, surgical tool - but when a 24B encoder is squatting in your VRAM while the sampler waits, it's the difference between watching a run crawl and watching it fly.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| value | COMFY_MATCHTYPE_V3 | Any value to pass through unchanged. Connect this output inline before the sampler or another downstream node that should run after the text encoder is released. | |
| clip | CLIP | The exact CLIP/text encoder to unload. Connect the same CLIP output used by the upstream text encoding nodes. | |
| wait_foropt | COMFY_MATCHTYPE_V3 | Optional extra dependency that is not changed or returned. For a classic KSampler, connect the other positive/negative conditioning branch here so both encodes finish before unload. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | COMFY_MATCHTYPE_V3 | The original value unchanged, emitted only after the connected CLIP/text encoder and its clones have been unloaded from ComfyUI model management. |