Nodes/ComfyUI-LLM-Session/Unload LLM Model
ComfyUI Node

Unload LLM Model

Out of VRAM after an LLM run? Unload LLM Model hands the memory back

By kantan-kanto·Created 7 months ago·Updated 14 days ago· 31
Unload LLM Model
  • trigger
  • trigger
unload_nowfalse

Here's the situation that makes this node exist: you run LLM Session Chat or LLM Dialogue Cycle, the generation finishes, and the model is still sitting in VRAM because the pack keeps model managers loaded so multi-turn runs don't reload weights every time. Your next node - an upscaler, a video model - then hits an out-of-memory error on a card that used to fit it fine. Unload LLM Model is a one-purpose utility that says "no, really, free it now," without restarting ComfyUI.

It's a dead-simple output node added in the 1.3.x series specifically for explicit manual VRAM release after keep-loaded runs. There's no graph to wire around: you drop it on the canvas, flip the single switch, and queue.

How it works

The whole control surface is one boolean, unload_now, defaulting to false. Set it to true and queue the workflow - the node calls the pack's runtime cleanup to unload the current LLM from VRAM. Then set it back to false. That's the entire loop, and the author is explicit about why: leaving it true means every subsequent queue also triggers an unload, and repeated unloads of a model that's no longer loaded are pointless at best, wasteful at worst.

There's also an optional trigger input that passes straight through to the trigger output - handy if you want to chain the unload onto the tail of a run so it fires automatically after your LLM step, rather than as a manual one-shot. Either way, it's an output node (OUTPUT_NODE=True), so it sits at the end of a graph doing cleanup duty, not in the middle of data flow.

When you actually need it

Two cases. First, after a Dialogue Cycle with big models and runtime_cache set to KV_cache or LlamaTrieCache - that's the mode that keeps managers loaded between turns, and it's the one that leaves VRAM pinned. Second, when you're mixing LLM work with diffusion in one session and hitting "CUDA out of memory" on the very next node. In both cases, remember the counterpart on the input side: a model only consumes VRAM if it was loaded, so this node is a release valve, not a memory manager. If you're routinely fighting for VRAM, the deeper fix is in the n_gpu_layers and quant choices of your LLM nodes, and the usual ComfyUI instinct to remove unneeded --lowvram flags - the unload node just gets you unblocked without a restart.

Installing it

It ships in the same pack, so it's one install for all five nodes - ComfyUI Manager (search ComfyUI-LLM-Session) or:

cd ComfyUI/custom_nodes
git clone https://github.com/kantan-kanto/ComfyUI-LLM-Session.git
pip install pillow numpy llama-cpp-python

Restart and it appears under LLM/Session. That's the whole tutorial: one boolean, one queue, flip it back. The only real mistake is forgetting step two - the flip back.

CategoryLLM/Session

Inputs (2)

NameTypeDefaultDescription
unload_nowBOOLEANfalseToggle true and queue this node to unload the current LLM model.
triggeropt*

Outputs (1)

NameTypeDescription
trigger*