Nodes/ComfyUI-YogurtNodes/LoRA Compress (Yogurt Nodes)
ComfyUI Node

LoRA Compress (Yogurt Nodes)

Shrink a LoRA's rank with SVD without trashing its effect

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
LoRA Compress (Yogurt Nodes)
  • lora
  • compressed_lora
  • compressed_layers_count
  • report
target_rank-1
energy_keep_ratio0.980
min_rank1
key_pattern.*
update_alphatrue
absorb_alphatrue

Some LoRAs are bigger than they need to be. A rank-128 style LoRA trained "just in case" might spend 400MB when the same behavior fits in rank 32 - and every extra rank costs you VRAM at sampling time and disk on top. YogurtLoraRankCompress is the shrink ray: it compresses a standard LoRA's rank using SVD, keeping as much of the effect as you ask it to keep.

It's part of ComfyUI-YogurtNodes, yogurt7771's 150+ node all-in-one pack. Obscure, MIT-licensed, auto-generated README - and of all the pack's model nodes, this one does something you genuinely can't do with stock ComfyUI.

How it works

Feed it a LORA object (from YogurtLoadLoraOnly) and pick your target:

  • target_rank - INT, default -1, which means "auto-pick for me."
  • energy_keep_ratio - FLOAT, default 0.98, used only when target_rank=-1. It keeps the rank needed to retain 98% of the SVD energy (a proxy for how much of the LoRA's signal survives).
  • min_rank - the floor for auto-selection, default 1.
  • key_pattern - regex over down-key names, default .* (everything).
  • absorb_alpha - BOOLEAN, default true. This is the subtle one.

The rank/alpha detail matters here, so bear with me: a LoRA's effective contribution is scaled by alpha/rank - that's how LoRA training encodes strength, and it's why the same file behaves differently depending on its alpha metadata (a lesson the SDXL-era tables hammer home). absorb_alpha reconstructs the full effective delta (weights × alpha/rank) before running SVD, so the compressed file reproduces the actual effect, not just the raw weights. update_alpha then rewrites the alpha metadata after compression so the saved LoRA keeps the expected scale when you load it.

Outputs: compressed_lora, compressed_layers_count (how many pairs were compressed), and report (per-layer summary).

Where you'll use it

  • Cutting a large SDXL/Illustrious LoRA down to rank 32 or 64 to save VRAM and disk.
  • After YogurtLoraMerge blows the rank up - compress the merged result back to something sane.
  • Packaging: a rank-16 compressed LoRA is easier to share than a 400MB original.

The honest caveats

Compression is lossy by design - it keeps 98% of the energy, and the last 2% is usually the noise floor, but not always. If your LoRA is already low-rank, compression buys nothing and can cost quality; the auto mode usually figures this out. And as with every rank operation in this pack, it expects standard .lora_down/.lora_up pairs - check with YogurtLoraStatViewer first, and save to a new filename so the original survives.

Install

ComfyUI Manager, search ComfyUI-YogurtNodes, install, restart. Or:

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

Restart, look under "Yogurt Nodes". No model downloads; numpy does the SVD, and you already have numpy.

CategoryYogurtNodes/Models

Inputs (7)

NameTypeDefaultDescription
loraLORALoRA to compress.
target_rankINT-1-1–4096Target rank. Use -1 to auto-pick by energy_keep_ratio.
energy_keep_ratioFLOAT0.9800–1Only used when target_rank=-1. Keeps this fraction of SVD energy.
min_rankINT11–4096Minimum rank when auto-selecting.
key_patternSTRING.*Regex filter for down-key names.
update_alphaBOOLEANtrueRewrite alpha after compression so saved LoRA keeps the expected scale.
absorb_alphaBOOLEANtrueWhen true, reconstruct full LoRA effect using alpha/rank before SVD compression.

Outputs (3)

NameTypeDescription
compressed_loraLORA
compressed_layers_countINT
reportSTRING