Nodes/Allma Nodes/Clear Allma VRAM
ComfyUI Node

Clear Allma VRAM

Give the diffusion model the GPU back, mid-graph

By OliveiraNickolas·Created 24 days ago·Updated 22 days ago· 0
Clear Allma VRAM
  • any
  • connectivity
  • any
  • status
kill_orphanstrue
wait_until_freetrue
timeout90
enabledtrue

Run an LLM prompt enhancer and a diffusion pipeline on the same card and you're budgeting VRAM for two models at once - the classic setup the LLM-in-ComfyUI crowd keeps banging into. The catch is that Allma's model lives in a separate process: Allma Generate just talks HTTP to the backend, so ComfyUI's own cache-clearing nodes can't touch that memory. Only the owning process can release it. Clear Allma VRAM is the node that politely asks the backend to unload - then, if polite isn't enough, cleans up the stragglers - right in the middle of your graph, at the exact moment you need the memory back.

How it works

It's a pass-through on purpose. You feed it anything at all (any), it returns that same value untouched, and that's the trigger: the cleanup runs when the value is needed, which forces the node to execute at the point in the run where you placed it. A node with no output would run whenever ComfyUI felt like it; this one runs where you put it because graph ordering demands it. Put it between the LLM stage and a heavy image or video stage, and the memory is free before the next node starts loading.

The actual cleanup is two stages:

  1. Ask Allma to unload what it tracks - via the backend's /v1/ps/v1/unload.
  2. Terminate orphan backends still holding VRAM. Allma loses track of servers that outlive its bookkeeping - a manual launch, a reload, a crash - and such an orphan can sit on 20+ GB that nothing else frees. This is the kill_orphans toggle, and it's scoped hard: it only signals processes whose command line names a known backend (llama-server, vllm, sglang). ComfyUI itself is never touched.

Supporting widgets: connectivity (where the server lives - without it, 127.0.0.1:9000 is assumed), wait_until_free (hold the graph until memory is really released instead of racing the next node), timeout (seconds before giving up and letting the graph continue anyway), and enabled (OFF makes it pure pass-through, so you can leave it wired while iterating). Outputs are the any value untouched plus a status string reporting how much was freed per GPU.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/OliveiraNickolas/AllmaNodes

Restart, no pip install. Despite living in the Allma/utils group, it is Allma-specific - it needs the backend to be running to have anything to unload.

Where people get burned

Two things. First, kill_orphans sends process signals, and while the whitelist means it'll never touch ComfyUI, it's still the one genuinely "dangerous" toggle in the pack - don't flip it on casually in a shared machine where another job's llama-server might look like an orphan. Second, it reports per-GPU what was freed on status, which is how you'll know whether the polite unload actually worked or whether the 20 GB is still sitting there because the backend lost track. For a pack this new with zero community battle history, treat this node as "check the status output" rather than "set and forget."

CategoryAllma/utils

Inputs (6)

NameTypeDefaultDescription
any*Anything at all — returned unchanged. This is the trigger: the cleanup happens when this value is needed.
connectivityoptALLMA_CONNECTIVITYWhere the Allma server lives. Without it, 127.0.0.1:9000 is assumed.
kill_orphansoptBOOLEANtrueAlso terminate inference-backend processes still holding VRAM after the unload — the ones Allma has lost track of. Only processes whose command line names a known backend (llama-server, vllm, sglang) are ever signalled; ComfyUI is never touched. OFF: only the polite unload is attempted.
wait_until_freeoptBOOLEANtrueHold the graph until the memory is actually released, so the next node does not start loading into VRAM that is still occupied.
timeoutoptINT905–600Seconds to wait before giving up and letting the graph continue anyway.
enabledoptBOOLEANtrueOFF: pure pass-through, nothing is freed. Lets you keep the node wired while iterating.

Outputs (2)

NameTypeDescription
any*
statusSTRING