Nodes/Comfyui-DiffusersUtils/Diffusers LoRA Layers Operation
ComfyUI Node

Diffusers LoRA Layers Operation

Zero out or scale individual transformer blocks

By lrzjason·Created 9 months ago·Updated 8 months ago· 14
Diffusers LoRA Layers Operation
  • lora
  • modified_lora
layer_pattern.*transformer_blocks\.(\d+)\.
layer_indices59
scale_factor1.00

Most of the time you want a LoRA at a single global weight: 0.8, say, and done. But some of the most interesting LoRA work in 2026 is slider and concept-mixing stuff, where you train one file and then disable or boost specific transformer blocks to control what it does. That's the job of DiffusersLoraLayersOperation - it modifies the layers inside a LoRA state dict before it's ever applied. Think of it as the difference between turning the volume down on the whole song and muting a single instrument.

It takes a LORA (from DiffusersLoadLoraOnly), finds the layers you name, and either zeroes them out or scales them. The result is a new LoRA you can save or merge.

The inputs that actually matter

  • layer_pattern - a regex that matches layer names and extracts the block index via its first capture group. Default: .*transformer_blocks\.(\d+)\., which targets LongCat-style transformer_blocks.N naming. This is the knob you'll tune to the LoRA's actual structure.
  • layer_indices - which blocks to hit. Supports comma lists (10,11,12), ranges (50-53), and singles. Default 59 - the last block of a 60-block LongCat transformer.
  • scale_factor - the operation itself. 0 zeroes the layer out; anything else multiplies the weights (negative values flip them, range −10 to 10).

That's it. Output is modified_lora, same LORA type.

How it works

Under the hood it compiles your regex, walks every key in the state dict, and where the pattern matches it reads the captured block number. If that number is in your index set, it clones the tensor and applies the operation - cloning matters, because the original loaded dict is left untouched, so you can branch edits without reloading. If your regex has no useful capture group it falls back to grabbing the first run of digits from the match, which is usually good enough. Empty index list returns the LoRA unchanged.

Why you'd actually do this

Two concrete cases. First, disabling a concept: scale 0 on the blocks that carry an unwanted style or character and you can often excise it without retraining. Second, slider-style control: train a LoRA where the strength of a concept lives in specific late blocks, then drive those blocks up or down - even negative - while leaving the rest alone. It pairs with DiffusersLoraStatViewer first: run that to learn which block indices your LoRA actually has, then write the pattern and indices here with confidence.

Install

ComfyUI Manager → "Comfyui-DiffusersUtils", or:

cd ComfyUI/custom_nodes
git clone https://github.com/lrzjason/Comfyui-DiffusersUtils

Restart ComfyUI. No extra deps for the LoRA nodes - skip the GLM git-installs and ignore the README's phantom requirements.txt.

Gotchas

  • The regex runs on the keys, not blocks. If a LoRA has no transformer_blocks naming, the default pattern matches nothing and your edits silently do nothing (you'll see "Modified 0 parameters" in the log). Check with StatViewer first.
  • Zeroing is not deleting. The zeroed layers still exist until you save with DiffusersSaveLora, which strips all-zero tensors from the file.
  • Pattern is everything. A pattern whose capture group isn't a number makes the node fall back to digits-in-match, which can grab the wrong index. If your edits affect the wrong layers, that's where to look.
CategoryDiffusers/Lora

Inputs (4)

NameTypeDefaultDescription
loraLORAThe LoRA state dictionary to modify.
layer_patternSTRING.*transformer_blocks\.(\d+)\.Regex pattern to match layer names. Use groups to extract layer indices.
layer_indicesSTRING59Comma-separated list of layer indices to operate on, with support for ranges (e.g., '59', '10,11,12', or '50-53').
scale_factorFLOAT1.00-10–10Scale factor to apply. Use 0 to zero out layers.

Outputs (1)

NameTypeDescription
modified_loraLORA