Nodes/ComfyUI-YogurtNodes/LoRA Layers Operation (Yogurt Nodes)
ComfyUI Node

LoRA Layers Operation (Yogurt Nodes)

Surgically zeroing or scaling specific blocks inside a LoRA

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
LoRA Layers Operation (Yogurt Nodes)
  • lora
  • modified_lora
  • modified_keys_count
layer_pattern.*transformer_blocks\.(\d+)\.
layer_indices59
scale_factor1.00

A LoRA isn't one effect - it's a stack of per-layer effects. Some layers carry the character's face, others carry the pose or the texture, and sometimes the thing you actually want is to kill the effect in one specific band of layers. LoRA Layers Operation (Yogurt Nodes) is the node that reaches inside a loaded LoRA and scales - or zeroes out - only the layers you select. It's layer surgery, and there isn't much else like it in the stock node set.

The workflow it's built for: you've got a style or identity LoRA that's great overall but wrecks one thing - say, everything past transformer block 20. Instead of fighting it with a global strength, you load the LoRA unapplied (LoRA Load Only), tell this node "scale layers 15–20 to 0", and save a new LoRA that leaves the rest untouched. Layer-level control is how you keep the parts you like.

How it works

The mechanism is regex plus arithmetic. Each LoRA key contains a layer index, and layer_pattern is a regex whose first capture group extracts that index - the default .*transformer_blocks\.(\d+)\. matches Flux/SDXL-style transformer block numbers. The node parses layer_indices (comma-separated, or ranges like 10-15), then walks every tensor key in the LoRA: if the regex matches and the captured index is in your selection, it multiplies that tensor by scale_factor. Set scale_factor to 0 and the selected layers are zeroed outright. Everything outside the selection is untouched.

One genuinely useful detail: it reports back modified_keys_count, so you get immediate feedback on whether your pattern actually matched anything. If that count is 0, your regex or indices are wrong - much better than silently producing a no-op LoRA.

The inputs that matter

  • lora - the LoRA object to modify (load it unapplied with LoRA Load Only).
  • layer_pattern - the regex, with the layer index in group 1. The default targets transformer_blocks.<n>; change it for other architectures.
  • layer_indices - which layers to hit, e.g. 59, 0,1,2, or 10-15.
  • scale_factor - multiply selected layers by this; 0 zeroes them.

Two outputs: modified_lora (the edited object) and modified_keys_count (how many tensors changed).

Installing it

It's part of ComfyUI-YogurtNodes, installable via ComfyUI Manager (search "ComfyUI-YogurtNodes") or:

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

Restart ComfyUI; it lives under "Yogurt Nodes".

Where people get burned

The classic failure is the silent no-op: a pattern that matches nothing, modified_keys_count of 0, and a "modified" LoRA that's identical to the input. Always glance at that count before saving. Second, zeroing is destructive - scale 0 means those layers are gone from the saved LoRA, and there's no undo short of redoing the load. If you're experimenting, keep the original file around or save the modified version under a new name. And remember this modifies an in-memory object; you still need a Save LoRA node to write the result to disk.

CategoryYogurtNodes/Models

Inputs (4)

NameTypeDefaultDescription
loraLORAThe LoRA object to modify.
layer_patternSTRING.*transformer_blocks\.(\d+)\.Regex used to detect a layer index. Group 1 should capture the index.
layer_indicesSTRING59Comma/range format, e.g. 0,1,2 or 10-15.
scale_factorFLOAT1.00-10–10Scale selected layers. Use 0 to zero-out selected layers.

Outputs (2)

NameTypeDescription
modified_loraLORA
modified_keys_countINT