Nodes/Comfyui-Z-Image-Utilities/Z-Image Unload Models
ComfyUI Node

Z-Image Unload Models

Free your VRAM when Z-Image's local LLM refuses to leave

By Koko-boya·Created 9 months ago·Updated 6 months ago· 127
Z-Image Unload Models
  • passthrough
  • status
unload_alltrue

If you use this pack's Direct provider - the one that downloads a HuggingFace LLM and loads it into your GPU - then the model stays loaded after you run. That's deliberate; the Prompt Enhancer's keep_model_loaded defaults to true so subsequent runs are fast. The catch is that a Qwen-class model sitting in VRAM eats memory that your actual image sampler now has to fight for. This node is the eject button: click it, and the cached model is moved off the GPU, deleted, and the CUDA cache is cleared.

It's a two-field utility, and both fields tell you how small its job is:

  • unload_all - boolean, defaults to true. With it true, every cached Direct-provider model is unloaded. With it false, nothing happens ("No action taken" in the status), so there's no reason to ever set it false unless you want a deliberately inert node in the graph.
  • passthrough - an optional wildcard input of any type that passes through untouched. It exists for graph hygiene: chain some value through this node so it sits on the critical path and forces its execution order relative to other nodes.

Output is a single status string - "All models unloaded" and friends - which is useful if you're reading execution results programmatically, less useful in a normal visual workflow.

When you actually need it

Three situations, in order of commonness: you're about to run a sampling-heavy job and the LLM is hogging memory (Direct provider, low VRAM cards especially); you've switched Direct models and the old cache entry is stale; or you hit an out-of-memory error in the middle of a workflow and want to recover without restarting ComfyUI. A restart also clears the cache, since it lives in memory only, so the node mostly saves you from babysitting long ComfyUI sessions.

The honest caveat

It does nothing for the OpenRouter or local-API providers. Those models live on a remote server or in a separate process - there's no VRAM footprint for this node to reclaim. If you're using only cloud or local-API backends, you can skip this node entirely; the pack's own README ties the unload tools to "cached direct models."

Installing

Part of the Comfyui-Z-Image-Utilities pack, so it arrives with everything else:

cd ComfyUI/custom_nodes
git clone https://github.com/Koko-boya/ComfyUI-Z-Image-Utilities.git

Restart ComfyUI. No extra dependencies beyond the Direct provider's own pip install bitsandbytes huggingface-hub.

CategoryZ-Image

Inputs (2)

NameTypeDefaultDescription
unload_allBOOLEANtrue
passthroughopt*

Outputs (1)

NameTypeDescription
statusSTRING