ComfyUI Node

TS Free VRAM

A wire that clears your GPU at the exact right moment

By AlexYez·Created 2 years ago·Updated a day ago· 15
TS Free VRAM
  • passthrough
  • model
  • passthrough

TS Free VRAM is a node whose output is identical to its input. That sounds useless until the fourth consecutive video render hangs at 100% GPU with your VRAM pinned at the ceiling, and the only thing that fixes it is a manual click you can't automate.

Its one job is to unload models at a chosen point in the graph. You place it on a link that gets consumed right before the step that needs the whole card, and by the time that step runs, the card is empty.

The problem it solves

Some steps refuse to share the GPU. The clearest case is the heavy VAE decode on the LTX video line: that decoder has to stay fully resident (ComfyUI marks it disable_offload = True) and asks for a very large reservation. With the diffusion model still staged next to it the two don't fit - and on Windows the driver doesn't raise an out-of-memory error, it quietly spills into shared system memory instead. Nothing fails; the decode just crawls while VRAM sits at the ceiling, and with no exception raised ComfyUI never falls back to tiled decoding.

The workaround has been manual for years: run one clip, click Free model and node cache, run the next. The "purge VRAM" nodes people install to automate that frequently do nothing - they fire the /free HTTP endpoint, which queues behind the run in progress. This one calls ComfyUI's own model management directly, in-process, mid-run.

How it works

Grounded in the source (nodes/utils/ts_free_vram.py), the mechanism is three lines:

  • connect a model → comfy.model_management.unload_model_and_clones(model), which takes exactly that model off the card and leaves everything else alone;
  • leave model empty → unload_all_models(), which evicts everything ComfyUI currently has loaded;
  • either way soft_empty_cache() releases the cached allocations afterwards.

Then it logs what it freed: [TS Free VRAM] Unloaded every loaded model. Free VRAM 1204 MB -> 9720 MB (+8516 MB).

One detail worth knowing: since this node's output is its input, an honest cache fingerprint would let ComfyUI serve the passthrough from cache on every run after the first and never unload a thing. The author returns float("NaN") instead - NaN never equals itself, so the side effect always fires.

Inputs and output

Two sockets, one of them optional.

passthrough (required, wildcard) is the thing you're routing - a latent, an image, anything; * fits on any link.

model (optional, MODEL) is the surgical option: wire the same MODEL the sampler used and only that one leaves the card. Leave it empty and everything goes.

passthrough (wildcard) comes out unchanged. Wire it into VAE Decode, an upscaler, or whatever heavy step you're clearing the way for.

Wiring it so it actually works

The wire type is free. The position is not. ComfyUI runs a node when its output is needed, so the node must sit on a link that is consumed after the step you want to free memory for:

KSampler --latent--> TS Free VRAM --latent--> VAE Decode
                          ^ model (optional)

That's the usual spot. Put it on a MODEL or CONDITIONING link feeding a sampler and it runs before sampling, when there's nothing to free yet - it'll log a +0 MB delta and you'll blame the node.

Two honest caveats. Because the fingerprint is always dirty, everything downstream of this node re-executes on every run instead of being served from cache - fine at the end of a graph, wasteful in the middle. And unload_all_models() only reaches models ComfyUI itself is tracking; anything a custom node loaded into VRAM by its own route is invisible to it.

Installing it

It ships in comfyui-timesaver, a 76-node pack, and the node itself has no dependencies and no model downloads.

ComfyUI Manager → Custom Nodes Manager → search Timesaver → install → restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/AlexYez/comfyui-timesaver
cd comfyui-timesaver
python -m pip install -r requirements.txt

Run pip from the same Python ComfyUI uses - on the Windows portable build that's python_embeded\python.exe. One install requirement is worth checking up front: the pack is written against ComfyUI's newer comfy_api.v0_0_2 backend API and declares requires-comfyui = ">=0.20.1". On an older build the node won't appear in the menu at all, and Manager will refuse to install it.

If it seems to do nothing

Read the log line. If the delta is around zero and nothing was on the card, there was nothing to free - often it's simply in the wrong place. If the node is missing entirely, the pack didn't load: start ComfyUI with TS_VERBOSE_STARTUP=1 and the startup report will name the module that refused.

And if you free the models but the decode still crawls, the resident memory is probably tensors pinned in ComfyUI's node output cache rather than weights. No unloading node touches that - click Free model and node cache once and see whether the number moves. If it does, your problem is cache, not models.

CategoryTS/Utils

Inputs (2)

NameTypeDefaultDescription
passthrough*Anything at all — it comes back out unchanged. Its only job is to place this node in time: ComfyUI runs a node when its output is needed, so put this on a link consumed AFTER the heavy step you want to free memory for (a latent going into VAE Decode is the usual spot). On a link feeding a sampler it would run too early.
modeloptMODELWhich model to unload. Connect the same MODEL the sampler used and only that one is taken off the card. Leave it empty to unload everything currently loaded.

Outputs (1)

NameTypeDescription
passthrough*Exactly what came in, unchanged.