Nodes/ComfyUI-Apt_Preset/Apt_clear_cache
ComfyUI Node

Apt_clear_cache

The manual VRAM-release valve for Apt_Preset workflows

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Apt_clear_cache
  • data

    This node does one thing and it's not glamorous: you plug your RUN_CONTEXT into it, it runs, and whatever models and caches that context was holding onto get released. No outputs, nothing to wire onward - it's a dead end by design, a terminal node whose entire job is the side effect. If you've ever watched VRAM climb across a session because ComfyUI happily keeps a checkpoint resident even after you've stopped using it, this is the pack's answer to that specific pain.

    Why it exists

    Apt_Preset is built around a "Loader → Controller → Sampler" pipeline, and its loader nodes (like the pack's Sum_load_adv) are designed to cache what they load so switching between presets doesn't mean re-reading a multi-gigabyte checkpoint off disk every single run. That's great for speed and genuinely one of the pack's better ideas - the README's own changelog calls out an update specifically to "optimize sum_load to support caching and cleaning." But caching that never gets cleaned is just a slow leak. Apt_clear_cache is the cleaning half of that pair: the node you drop at the end of a batch, or between preset switches in the same session, to actually force the release instead of hoping ComfyUI's own garbage collection gets to it before you run out of VRAM.

    The one input

    There's exactly one field, and it's required: data, typed RUN_CONTEXT - the same bundle-of-everything wire that flows out of this pack's loader and sampler nodes. You don't configure anything else. Wire the context you're done with into this node, queue the run, and it clears. It's an output node with no outputs, so ComfyUI will execute it as a terminal step in the graph rather than something you chain further work off of.

    Installing it

    Search "ComfyUI-Apt_Preset" in ComfyUI Manager, or clone it directly:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
    

    Run install.bat on Windows, or pip install -r requirements.txt from inside the cloned folder on Linux/Mac, then restart ComfyUI fully. This node has no model dependency of its own - it operates purely on whatever the loader already pulled into memory.

    Common issues

    The mistake that defeats the whole point of this node is wiring it to a context you're not actually finished with. Since it's a hard release, if another part of your graph still expects that model or clip to be resident later in the same run, you'll get a reload (or an error) instead of the speed you were trying to protect. Use it at genuine session boundaries - end of a batch, or right before you switch to a different preset entirely - not mid-pipeline.

    Generic VRAM math is worth keeping in your head here too: GPU memory bandwidth is roughly 11x faster than PCIe, which is why swapping a model out to system RAM instead of actually freeing it is "usually not worth it" as a middle-ground fix - you want a real release, not a slow shuffle, and that's exactly what this node is for.

    Separately, and this applies to the whole pack rather than this node specifically: at least one user has reported ComfyUI-Apt_Preset throwing an IMPORT FAILED line on ComfyUI startup. That's a red node in the console, not a runtime bug in Apt_clear_cache itself - the fix is almost always a skipped dependency from the install step. Rerun install.bat (or the pip command) and do a full restart of ComfyUI, not just a page refresh, before assuming something's broken with the node itself.

    CategoryApt_Preset/chx_load

    Inputs (1)

    NameTypeDefaultDescription
    dataRUN_CONTEXT

    Outputs (0)

    No outputs