Nodes/More Math/Batch LoRa apply
ComfyUI Node

Batch LoRa apply

Render every LoRA in a folder in one queue

By mcDandy·Created about a year ago·Updated 3 days ago· 5
Batch LoRa apply
  • model
  • clip
  • model_strength
  • clip_strength
  • stack
  • model
  • clip
  • stack
folder
add_no_lora

You've just downloaded ten LoRAs that might fit your workflow and you want to see them side by side, same seed, same prompt. The manual way is ten copies of the workflow with ten different LoraLoader nodes. Batch LoRa apply from More Math does it in one node: it points at a folder, applies every LoRA in it to your model and CLIP, and outputs a list of patched models for batch processing. It's the node I'd build this pack around if I only had one feature to ship.

How it works

Give it a model and a clip, point folder at a subfolder inside your LoRA directory, and the node iterates the LoRAs in it, applying each one to produce a patched model+clip pair. The model_strength and clip_strength fields are expressions, not fixed numbers - the defaults are [1.0] (a list literal), and that's the whole point: you can supply a list of strengths, one per LoRA, or compute them with the pack's expression language. You can even reference lora_names and lora_count inside the expression if you want strengths derived from the LoRA list itself. add_no_lora adds a baseline entry with no LoRA applied - which is how you get your "control" render in the same batch, and honestly you should always turn that on for comparisons.

Inputs and outputs

Required: model, clip, folder (the subfolder containing the LoRA weights), add_no_lora, model_strength, clip_strength. Optional stack. Outputs are model (a list - one per LoRA), clip (list, matching), and stack. Feed those lists into your batch machinery and render the whole folder in one queue.

Installing it

Identical to the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/mcDandy/more_math
cd more_math
pip install -r requirements.txt

Restart ComfyUI, or install "More math" from ComfyUI Manager. Dependency is antlr4-python3-runtime on top of torch. The LoRAs themselves are yours - drop them in your LoRA folder, point folder at the subfolder name.

Gotchas

The strength fields expect list syntax - [1.0] applies 1.0 to every LoRA, [1.0, 0.5, 0.75] applies one strength per LoRA and will misbehave if the counts don't line up. Keep the folder scoped: put only the LoRAs you want to compare in one subfolder, or every render you queue gets one model per file, and a folder with 40 LoRAs means 40 generations. And because model patching is CPU-side work, applying a large batch of LoRAs adds real setup time before sampling starts. New pack, solo-maintained, but the concept is simple and it does exactly what it says - if you A/B test LoRAs at all, this is a time-saver you'll use constantly.

CategoryMore math

Inputs (7)

NameTypeDefaultDescription
modelMODELThe model to apply the LoRA weights to
clipCLIPThe clip to apply the LoRA weights to
folderSTRINGThe sub-folder containing the LoRA weights
add_no_loraBOOLEANWhether to add a model execution without a lora
model_strengthSTRING,SYNTAX_TREE[1.0]strength of lora applied to model
clip_strengthSTRING,SYNTAX_TREE[1.0]strength of lora applied to clip
stackoptSTACKThe stack

Outputs (3)

NameTypeDescription
modelMODELThe model with the LoRA weights applied
clipCLIPThe clip with the LoRA weights applied
stackSTACKThe stack