Nodes/ComfyUI-pyiqa-toolbox/Unload Pyiqa Models
ComfyUI Node

Unload Pyiqa Models

The one-cable node that gets 11 GiB back

By AnsteinHuynh·Created 7 days ago·Updated 6 days ago· 0
Unload Pyiqa Models
  • passthrough
  • passthrough
◄empty_cuda_cachetrue►

Here's an annoying fact about scoring nodes: ComfyUI's memory manager doesn't know they exist. The pyiqa metrics in this pack are built outside comfy.model_management, which means ComfyUI has no idea how much VRAM they're holding and will never free it on your behalf. Load Q-ReAlign Pro to score a batch, then queue a video render, and you can OOM against a model that isn't even in ComfyUI's model list.

Every score node has a memory_management widget that handles this per-score. This node is the blunt instrument: it releases every cached metric in one go.

What it does

empty_cuda_cache is the only required input, default true - after unloading, it calls torch.cuda.empty_cache() to hand PyTorch's reserved-but-unused blocks back to the driver. Leave it on. It's the difference between "freed" and "freed and actually available".

passthrough is optional and accepts anything. Whatever you wire in comes back out of the passthrough output unchanged, so the node can sit inline in a pipeline without breaking a wire - drop it on the image line before your score nodes, or at the very end of the graph. You can also leave it completely unconnected if all you want is the side effect.

Unloading here means gone: weights gutted, out of VRAM and out of RAM, only the file on disk left. The next score rebuilds the metric from its cached recipe - seconds for small metrics, around half a minute for Q-ReAlign Pro. Re-queueing the workflow just works; you don't have to reload anything manually.

Two scoping notes that matter. It only touches this pack's metrics - your checkpoint, VAE and text encoders are left to ComfyUI's own manager, so this is not a general "free everything" button. And ComfyUI's Edit → Unload Models and Edit → Unload Models and Execution Cache already funnel through the same full-unload path (the pack wraps unload_all_models), so if you're a person who hits that menu item out of habit, you've been quietly doing this all along.

When to actually place it

End of graph, after your save/preview nodes, is the default placement and covers the common case: score, then everything gets out of the way for the next job.

The other placements are situational. Before a big render in a graph that scored earlier - you don't want a 9B judge loitering while a video sampler allocates. Or between two halves of a workflow that use different metric families, where you'd rather pay one reload than hold two models.

If you're already using keep loaded on your score nodes because you're scoring in a loop, this node at the end is exactly the complement: fast re-scoring during the loop, clean release afterwards.

Install

Nothing special - it ships with the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/AnsteinHuynh/ComfyUI-pyiqa-toolbox
python -m pip install -r ComfyUI-pyiqa-toolbox/requirements.txt

Or ComfyUI Manager → search pyiqa-toolbox, restart, and find it under pyiqa/Utilities. No weights, no downloads, no first-run delay.

Common issues

Nothing appears to happen. Nothing visible does happen. It's a memory operation, not an image one - check the console line rather than the canvas.

The next score is slow. That's the reload you asked for. Use keep loaded on the score node and put this node after them if the reload is the problem.

VRAM still full. If something else is holding the card - a checkpoint, a video model, an accumulation of other packs' leftovers - this node won't touch it by design. That's ComfyUI's Edit → Unload Models, or restarting the process.

A downstream node got a None. Only if you wired passthrough from somewhere that wasn't producing a value. The node returns exactly what it's given; it doesn't invent one.

Categorypyiqa/Utilities

Inputs (2)

NameTypeDefaultDescription
empty_cuda_cacheBOOLEANtrueAfter unloading, return PyTorch's reserved-but-unused GPU memory to the driver (torch.cuda.empty_cache()).
passthroughopt*Any wire to pass through unchanged (image, latent, etc). Can also be left unconnected if you only want to trigger the unload.

Outputs (1)

NameTypeDescription
passthrough*The input value, returned unchanged.