LoRA Compress (Yogurt Nodes)
Shrink a LoRA's rank with SVD without trashing its effect
- lora
- compressed_lora
- compressed_layers_count
- report
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 whentarget_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
YogurtLoraMergeblows 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.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| lora | LORA | LoRA to compress. | |
| target_rank | INT | -1-1–4096 | Target rank. Use -1 to auto-pick by energy_keep_ratio. |
| energy_keep_ratio | FLOAT | 0.9800–1 | Only used when target_rank=-1. Keeps this fraction of SVD energy. |
| min_rank | INT | 11–4096 | Minimum rank when auto-selecting. |
| key_pattern | STRING | .* | Regex filter for down-key names. |
| update_alpha | BOOLEAN | true | Rewrite alpha after compression so saved LoRA keeps the expected scale. |
| absorb_alpha | BOOLEAN | true | When true, reconstruct full LoRA effect using alpha/rank before SVD compression. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| compressed_lora | LORA | — |
| compressed_layers_count | INT | — |
| report | STRING | — |