Nodes/ComfyUI-Alchemine-Pack/Cached Load LoRA Tag
ComfyUI Node

Cached Load LoRA Tag

...> tags, without re-patching every run

By alchemine·Created about a year ago·Updated 3 days ago· 2
Cached Load LoRA Tag
  • model
  • clip
  • MODEL
  • CLIP
  • STRING
text

CachedLoraTagLoader is the "Load LoRA Tag" node with a memory: it reads every <lora:name:weight> tag out of your prompt, patches your model and CLIP with those LoRAs, strips the tags back out of the text, and - here's the whole point - remembers the patched result. As long as the set of LoRA tags, the model, and the CLIP don't change, re-running the workflow skips the expensive LoRA loading and re-patching entirely.

If you've ever run a prompt with five LoRAs through a standard loader, you know the cost: every single queue re-reads the .safetensors files from disk and re-patches the model. Do that while you're iterating on a single tag in your prompt and you're burning real seconds per run on work that's identical every time. This node is the fix.

How it works

The node scans your prompt for tags matching <lora:name:model_weight:clip_weight>. The clip weight is optional and defaults to the model weight; a tag with no weight at all loads at 0 (so it's registered but effectively off - handy for toggling without deleting). Each name is matched as a prefix against the files in your loras folder - the pack uses folder_paths.get_filename_list("loras") - so subfolder paths work, and unmatched names are skipped rather than erroring.

Then it loads and patches. The caching is the clever part: it computes a "signature" from the sorted set of LoRA tags plus the identity of the model and CLIP objects. If that signature matches the last run, it returns the cached patched model and CLIP and never touches disk. Change one LoRA weight in the text and the signature changes, so it re-patches - but only that once. It also caches the loaded LoRA state dicts by path, so repeated re-patches of the same file don't re-read the file.

Outputs are MODEL and CLIP (both patched), plus STRING - the prompt with all the <lora:...> tags stripped out, ready to feed your text encoder.

Inputs

Three inputs, all required: model (your base model), clip (your base CLIP), and text (multiline - the prompt containing the lora tags). That's it. No weight fields, no strength sliders; the weights live in the tags themselves, which is the point of a tag-driven loader.

Install

Part of ComfyUI-Alchemine-Pack:

cd ComfyUI/custom_nodes
git clone https://github.com/alchemine/comfyui-alchemine-pack
pip install -r requirements.txt

Or via ComfyUI Manager (search "ComfyUI-Alchemine-Pack"). Only dependency is python-dotenv; the LoRAs themselves are your normal loras-folder files.

Common issues

The big one is typo-driven silence: a mistyped LoRA name is "unmatched" and silently skipped, and the prompt still works - just without that LoRA. Watch the ComfyUI console for the "bypassed lora tag" log line. Second, the cache is per node instance; if you duplicate the node, each copy has its own cache, so you're not saving anything by cloning it everywhere. And tag syntax matters - the clip weight is optional but the format is strict; a malformed tag won't parse and will be ignored, same silent skip.

CategoryAlcheminePack/Model

Inputs (3)

NameTypeDefaultDescription
modelMODEL
clipCLIP
textSTRING

Outputs (3)

NameTypeDescription
MODELMODEL
CLIPCLIP
STRINGSTRING