LLaVA (Managed Cache, Advanced)
Run LLaVa, then hand the VRAM back before your sampler starts
- image
- STRING
Here's the workflow most people want: look at a reference image with a VLM to build a prompt, then immediately run a diffusion sampler with that prompt. The problem is that both models want the same VRAM, and ComfyUI doesn't always cooperate. This node is the answer - it's a full-featured LLaVa sampler that loads the model itself, and when it's done it can unload it, freeing your GPU for the actual generation.
What it is
LLavaOptionalMemoryFreeAdvanced is the pack's self-contained LLaVa node. Unlike the other samplers, it doesn't take a model from a separate loader - it reads the checkpoint straight from a dropdown and manages its own context, GPU offload, and thread settings. The "Optional Memory Free" in the name is the whole selling point: a boolean unload that, when checked, frees the model from memory after it answers.
The inputs that matter
- ckpt_name - dropdown of GGUF model files in
models/LLavacheckpoints. The main model. - clip_name - dropdown for the matching clip projector (
mmproj-*). This pair must belong together. - image - what the model looks at.
- system_msg and prompt - role and question, as usual.
- gpu_layers - how many layers to offload to the GPU (default 27). This is the setting that decides whether you're fast or VRAM-thin; if the model is crawling on CPU, raise it.
- max_ctx - context length, default 4096. Only raise it if you're feeding long prompts in.
- n_threads - CPU threads for the parts that don't run on GPU.
- temperature / top_p / top_k / penalties / seed - the usual sampling dials; defaults are sane.
- unload - the star. Default false. Check it and the model is released after generation, so your diffusion sampler gets the VRAM back.
Output is a single STRING.
How it works
Because the node owns model loading and unloads on demand, it's the pick for one-shot workflows: caption the image, grab the string, and let ComfyUI move on to the KSampler with a clean GPU. When unload is false it keeps the model cached, so repeated calls are fast but VRAM stays occupied - that's the trade you're choosing with one checkbox.
Install
Pack-level:
cd ComfyUI/custom_nodes
git clone https://github.com/gokayfem/ComfyUI_VLM_nodes
Restart (or Manager → "VLM Nodes"). Python 3.9+ and the llama-cpp-python stack. Model files go in models/LLavacheckpoints as a GGUF + matching mmproj pair from the same HF repo.
Troubleshooting
The llama-cpp-python wheel problems are the usual suspects - on Windows that's the "invalid wheel filename" install error and the missing llama.dll import failure people hit at startup; rebuild the package for your GPU backend and both clear up. If the model ignores your GPU entirely, that's the same root cause. If you're getting VRAM OOM at the sampler step, you forgot to tick unload. If captions are nonsense, check the GGUF/projector pairing before changing any dials.
Inputs (25)
| Name | Type | Default | Description |
|---|---|---|---|
| ckpt_name | COMBO | 0 options: | |
| clip_name | COMBO | 0 options: | |
| max_ctx | INT | 4096128–131072 | — |
| gpu_layers | INT | -1-1–1000 | — |
| n_threads | INT | 121–256 | — |
| image | IMAGE | — | |
| system_msg | STRING | You are an assistant who accurately describes images. | — |
| prompt | STRING | — | |
| max_tokens | INT | 5121–8192 | — |
| temperature | FLOAT | 0.100–2 | — |
| top_p | FLOAT | 0.950–1 | — |
| top_k | INT | 40 | — |
| frequency_penalty | FLOAT | 0.00-2–2 | — |
| presence_penalty | FLOAT | 0.00-2–2 | — |
| repeat_penalty | FLOAT | 1.100–2 | — |
| seed | INT | 42 | — |
| unload | BOOLEAN | false | — |
| handleropt | COMBO | Auto (GGUF chat template) | 10 options: Auto (GGUF chat template), LLaVA 1.5, LLaVA 1.6, MiniCPM-V 2.6, Moondream2, NanoLLaVA, +4 |
| n_batchopt | INT | 5121–8192 | Logical prompt batch. Lower this if context loading runs out of memory. |
| n_ubatchopt | INT | 5121–8192 | Physical prompt micro-batch. Never exceeds n_batch. |
| flash_attentionopt | COMBO | Auto | Auto enables llama.cpp flash attention only with accelerator offload and safely retries without it when unsupported. |
| use_mmapopt | BOOLEAN | true | Memory-map GGUF weights when the installed backend supports it. |
| split_modeopt | COMBO | Layer | How llama.cpp distributes tensors across multiple accelerators. |
| main_gpuopt | INT | 00–31 | — |
| tensor_splitopt | STRING | Optional comma-separated accelerator proportions, for example 0.6,0.4. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |