[llama.cpp] Unload Session
Free the VRAM Before the Sampler Asks For It
- session
- timing
- timing
You just used a 12B vision model to write a prompt. Now the sampler wants the whole card back. Unload Session is the node that makes that happen on purpose, at the moment you choose.
It's an output node with no outputs worth wiring anywhere. One input that matters, one passthrough. That's the entire API, and it's still one of the more useful nodes in the pack once you're running an LLM and a diffusion model in the same graph.
How it works
You feed it the session handle. It calls the session's close path, and the right thing happens depending on what kind of session you had:
- Runtime session (the workflow-owned server) - the supervised
llama-serverprocess is shut down, its temp chat-template file is deleted, the model is gone from memory. - Connect session (a server you're pointing at) - it asks the server to unload the model rather than killing someone else's process. That's why these are two paths and not one.
The timing input and output are the interesting bit. timing is an untyped * passthrough - connect anything you want and it comes out the other side unchanged. What it's actually for is ordering. In a graph, ComfyUI only runs a node when something depends on it; you put a final node from your loop (the author's own description says "a final End Loop result") or any tail output into timing so the unload provably happens after the work, not in parallel with it. It's a hand-built execution dependency, and it's a neat trick to know even when you're not unloading anything.
Then there's the safety net: the pack tracks sessions and closes them at prompt end and on process exit, so forgetting this node leaks memory during a run but shouldn't leave an orphaned server after a crash. That net is why this node exists for timing, not for hygiene.
When you'd actually add it
Between the LLM and the sampler. This is the real use. Caption first, unload, then generate - so the sampler starts with a clean card instead of whatever the LLM left behind. Anything else and you're gambling on the driver's swapping behaviour, which is not a bet you want to make on a 12GB card.
Inside a loop. The pack's session_unload toggle on the Generate and Decide nodes covers "unload after this node", but a loop with several LLM calls in it wants one unload at the end, after the last iteration. That's what the timing wire is for.
Batch jobs where you know you're done. A captioning run that finishes can hand the memory back rather than holding a warm model until you close ComfyUI.
Not needed on a one-node text-generation test graph. The prompt-end cleanup catches that. If you find yourself adding this node to every workflow out of superstition, you can drop it.
Where people get burned
Unload looks instant and VRAM takes a moment to come back. The process gets terminated, then the memory is actually released. If a node immediately downstream still OOMs, the honest fix is load-then-free elsewhere - this is a timing tool, not a guarantee about the exact millisecond.
The session is dead afterwards. Anything downstream that still expects to generate from that handle fails. Ordering the graph is the whole discipline here: unload is the last LLM-side thing, not a middle step.
Killing someone else's server isn't on the menu. On a Connect session you're asking a remote server to unload its model, and a server that doesn't implement that path won't oblige - in which case it's your own process to manage, not ComfyUI's. That's a normal outcome, not an error to debug for an hour.
Install
Manager → search llama multimodal → ComfyUI-llama-multimodal. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/craftingmod/ComfyUI-llama-multimodal.git
ComfyUI 0.19.3 or later. Nothing extra is needed for this node - it operates on a session handle, so the install requirements come from whatever session node you paired it with (the llama runtime from Settings → llama-multimodal → Download llama.cpp, plus a GGUF and matching mmproj in ComfyUI/models/LLM for the local path).
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| session | OLLAMA_IMAGE_LIST_LLAMA_CPP_SESSION | — | |
| timingopt | * | Optional execution dependency passed through unchanged. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| timing | * | — |