Nodes/was-node-suite-comfyui/Apply Reweighted LoRA
ComfyUI Node Runs on cloud

Apply Reweighted LoRA

Turn one down without turning it off

By WASasquatch·Created 4 years ago·Updated a day ago· 1,864
Apply Reweighted LoRA
  • model
  • clip
  • model
  • clip
  • stats
◄lora_name▾►
◄strength_model0.80►
◄strength_clip0.80►
◄global_scale1.00►
◄front_scale1.00►
◄mid_scale1.00►
◄back_scale1.00►
◄last_block_scale1.00►
◄scale_targetup_only►
◄block_presetauto►
◄filter_by_block_rangetrue►
◄save_reweightedtrue►
◄output_filename►
◄verify_roundtriptrue►

LoRA strength is one number, and one number is a blunt instrument. At 0.8 your character LoRA nails the face and also drags the whole composition toward its training set. At 0.5 the composition is yours again and the face has wandered. You end up at 0.6 with both problems, which is the sign that you're using a single knob for two jobs.

Block weighting is the fix, and it's been a folk practice in A1111 extensions for years: a LoRA's tensors are injected across the model's blocks in order, and the early blocks carry composition, the middle carries subject and structure, the late ones carry detail and texture. Scale them separately and you can have a LoRA's look without its layout urges. Apply Reweighted LoRA is that, built into the pack.

How it works

It loads the LoRA from disk on every run - your original file is never modified - detects how many blocks it spans, and applies a multiplier to each tensor based on which third of the model that block sits in. Then it applies the result to the model and clip, exactly like a normal LoRA load, and saves the reweighted copy under output/loras so the setting you found can be reused.

global_scale multiplies everything before the three below it, so you can dial the whole reweighting up or down once the balance between thirds is right.

front_scale is the first third: composition and overall shape. Lower it to keep a LoRA's style while the prompt decides the layout - this is the one people should be reaching for more often than they do.

mid_scale is the middle third: subject and structure. The tooltip is unusually direct about the use case - this is the third to lower when a character LoRA is overriding the face you asked for.

back_scale is the last third: detail, texture, surface style. Raise it to keep a LoRA's look with its subject influence turned down.

last_block_scale is a further multiplier for the final block alone, on top of its third's. That block sits closest to the output, so small changes here show up strongly in fine detail.

strength_model and strength_clip are the ordinary strengths. Lowering strength_clip while leaving strength_model alone keeps a LoRA's look without its trigger words steamrolling the prompt, which is a trick worth stealing for any LoRA with an aggressive trigger.

The two settings that trip people up

scale_target is up_only, down_only or both. A LoRA is a pair of matrices per layer, and up_only - the default - scales the result linearly, which is what you want. both scales the two halves and therefore squares the effect: the same numbers hit far harder. If your reweighting feels far more extreme than the values suggest, check this first.

block_preset is which model family's block naming the node reads to number the blocks - auto (from the LoRA's own keys, and right almost always), or wan, qwen, flux, zimg-turbo, sd, sdxl, generic. If stats reports 0 blocks detected, name the family yourself. And filter_by_block_range (on by default) drops tensors for blocks the connected model doesn't have, which is the reason a LoRA trained on a bigger version of a model can be applied to a smaller one instead of failing outright.

The outputs, including the one nobody uses

model and clip go where a LoRA loader's outputs go. The third output, stats, is a dictionary and it's the reason this node is pleasant rather than mystifying: which naming scheme was detected, how many blocks were found, how many tensors were scaled, dropped and kept, where the copy was saved with its SHA-256, and whether the round-trip check passed. Wire it into a debug node and you'll know in one run why a reweighting had no effect. verify_roundtrip - on by default - reads the saved file back and compares it tensor by tensor with what was applied, at the cost of one extra file read; it's what proves the copy on disk behaves the same as the run you just watched.

save_reweighted writes to output/loras, and output_filename left empty builds a name from the source file and every scale - style.reweighted.up_only.g1.00.f1.0.m1.0.b1.0.L1.0.safetensors - so two settings never overwrite each other. Turn saving off while hunting for numbers and on for the run worth keeping.

Installing it

Part of WAS Node Suite v3 (MIT, WASasquatch):

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

Or ComfyUI Manager, search WAS Node Suite v3. Needs ComfyUI 0.14.0+ and Python 3.10+; no pip packages get installed and nothing is downloaded. The LoRA merging and reweighting nodes are among the 27 in the extras feature group, enabled by default - check features.extras in <ComfyUI user dir>/was-node-suite/config.yaml if they're missing. output/loras is created for the saved copies, so don't be surprised by a new folder in your output directory.

When to use it

Three jobs. Taming a style LoRA whose composition you don't want. Getting a character LoRA's likeness while letting the prompt own the layout. And pruning a LoRA trained on a bigger model down to the blocks your model actually has, which filter_by_block_range does by just dropping the orphans. What it won't do is make a badly trained LoRA good - we're scaling weights, not fixing them.

CategoryWAS Suite/LoRA

Inputs (16)

NameTypeDefaultDescription
modelMODELThe model the reweighted LoRA is applied to.
clipCLIPThe clip the LoRA's text-encoder half is applied to. A LoRA with no text-encoder tensors leaves it untouched.
lora_nameCOMBOThe LoRA file to reweight, from your LoRA folder. It is read from disk on every run, so the original file is never modified.
strength_modelFLOAT0.80-5–5How strongly the reweighted LoRA is applied to the model, before any block scaling. 1.0 is full strength; a negative value pushes away from what the LoRA learned.
strength_clipFLOAT0.80-5–5The same for the clip. Lowering it while leaving strength_model alone keeps the LoRA's look without its trigger words dominating the prompt.
global_scaleFLOAT1.00-5–5Multiplier applied to every block before the three below. 1.0 changes nothing; use it to turn the whole reweighting up or down once the balance between the thirds is right.
front_scaleFLOAT1.00-5–5Extra multiplier for the first third of the blocks, which carry composition and overall shape. Lower it to keep a LoRA's style while letting the prompt decide the layout.
mid_scaleFLOAT1.00-5–5Extra multiplier for the middle third, which carries subject and structure. This is the third to lower when a character LoRA is overriding the face you asked for.
back_scaleFLOAT1.00-5–5Extra multiplier for the last third, which carries detail, texture and surface style. Raise it to keep a LoRA's look while its subject influence is turned down.
last_block_scaleFLOAT1.00-5–5A further multiplier for the final block alone, on top of its third's. That block sits closest to the output, so small changes here show up strongly in fine detail.
scale_targetCOMBOup_onlyWhich half of each LoRA pair is scaled. `up_only` is the usual choice and scales the result linearly. `both` scales the two halves and so squares the effect, which is much stronger for the same numbers. `down_only` is there for comparison.
block_presetCOMBOautoWhich model family's block naming is read to find each block's number. `auto` works it out from the LoRA's own keys and is right almost always; name the family if the stats output reports 0 blocks detected.
filter_by_block_rangeBOOLEANtrueDrop tensors for blocks the connected model does not have. This is what lets a LoRA trained on a larger version of a model be applied to a smaller one instead of failing.
save_reweightedBOOLEANtrueWrite the reweighted LoRA to output/loras. Switch it off while hunting for the right numbers, then on for the run worth keeping.
output_filenameSTRINGName for the saved copy. Left empty, a name is built from the source file and every scale, such as 'style.reweighted.up_only.g1.00.f1.0.m1.0.b1.0.L1.0.safetensors', so two settings never overwrite each other.
verify_roundtripBOOLEANtrueRead the saved file back and compare it tensor by tensor with what was applied, reporting the answer in the stats output. Costs a second read of the file; it is what proves the saved copy behaves the same as this run.

Outputs (3)

NameTypeDescription
modelMODELThe model with the reweighted LoRA applied.
clipCLIPThe clip with the reweighted LoRA applied.
statsDICTWhat the run did: which naming scheme was detected, how many blocks were found, how many tensors were scaled, dropped and kept, where the copy was saved with its SHA-256, and whether the round-trip check passed. Feed it to a debug node to see why a reweighting had no effect.