ComfyUI Node

PM Resize LoRA

Shrink a LoRA's rank (and file size) with SVD — PM Resize LoRA

By larsupb·Created 2 years ago·Updated 24 days ago· 75
PM Resize LoRA
  • lora
  • LoRABundle
decomposition_methodrSVD
new_rank16
device
dtype

A LoRA's rank is its capacity knob - roughly, how much information it can hold per layer. Higher rank means more expressiveness but a bigger file and more VRAM, and rank 32 isn't always earning its keep. This node resizes every layer of a LoRA down (or up) to a target rank using SVD, so you can shrink a 128-rank file down to 32 and often lose almost nothing visually. It's the "does this actually need to be that big?" tool.

Beyond file size, it has a real workflow reason to exist: before you merge LoRAs, they usually need matching ranks. Rather than hoping your collection cooperates, you can force them all to rank 32 first. The pack's own merge path can reconcile ranks via SVD at decompose time, but doing it deliberately, up front, gives you a predictable result.

How it works

LoRA weights are stored as pairs of low-rank matrices (up and down). Resizing is a singular value decomposition: split the pair apart, keep only the strongest new_rank singular directions, and recombine. You lose the directions with the smallest singular values - which, in practice, are usually the noise. The one thing worth knowing: this node uses an asymmetric distribution, putting all the singular values in the up matrix, which differs from the symmetric split the decompose node produces. It's an implementation detail that doesn't change the output LoRA's format compatibility.

The inputs that matter

  • lora - a LoRABundle input. Feed it a single LoRA from PM LoRA Select, or anything else that outputs one.
  • decomposition_method - rSVD is the recommended default: randomized SVD, fast and near-optimal. SVD is the slow, exact version. energy_rSVD prunes low-energy components first, which makes it the pick for big DiT/Flux LoRAs.
  • new_rank - the target rank for all layers (default 16, range 1–128). Lower = smaller file, weaker effect.
  • device and dtype - compute location and precision.

Output is a single LoRABundle renamed to {original_name}_r{new_rank}, with the original CLIP weights and strength metadata carried along. It skips layers already at the target rank, so re-running it is cheap.

Installing

Part of the LoRA Power-Merger pack. Manager (search "LoRA Power-Merger") or:

cd ComfyUI/custom_nodes
git clone https://github.com/larsupb/LoRA-Merger-ComfyUI
cd LoRA-Merger-ComfyUI
pip install -r requirements.txt

Restart ComfyUI; it's the node labeled PM Resize LoRA. Dependencies are PyTorch, lxml, and mergekit.

Common issues

Two format caveats from the docs: it handles standard LoRA format, so LoHA/LoCon and DoRA files may not resize cleanly - don't blame the node, those aren't plain low-rank pairs. And if a LoRA looks washed out after shrinking, you cut too far: rank 8 from a rank-64 file loses real information. For SDXL, rank 16 with alpha 16 is the community's comfortable floor for most content. Also worth knowing: it processes layer by layer with a progress bar and clears CUDA cache between layers, so memory usage stays sane even on big LoRAs.

CategoryLoRA PowerMerge

Inputs (5)

NameTypeDefaultDescription
loraLoRABundle
decomposition_methodCOMBOrSVDMethod used to reconcile LoRA ranks when they differ. 'SVD' uses full singular value decomposition (slow but optimal). 'rSVD' uses randomized SVD (much faster, near-optimal). 'energy_rSVD' first prunes low-energy LoRA components and then applies randomized SVD for fast, stable rank reduction (recommended for DiT and large LoRAs).
new_rankINT161–128Target LoRA rank after decomposition. Lower values reduce model size and strength.
deviceCOMBO2 options: cuda, cpu
dtypeCOMBO3 options: float32, float16, bfloat16

Outputs (1)

NameTypeDescription
LoRABundleLoRABundle