Nodes/Model Utility Toolkit/LoRA Resize (Frobenius)
ComfyUI Node

LoRA Resize (Frobenius)

LoRA Resize (Frobenius) — shrink a LoRA to a target fidelity, not a fixed rank

By silveroxides·Created about a year ago·Updated 4 days ago· 14
LoRA Resize (Frobenius)
    • output_path
    lora_name
    max_rank128
    target0.90
    output_filenameresized_lora_fro
    save_dtypefp16
    devicecuda
    lazy_loadtrue
    force_clear_cachefalse

    The adaptive sibling to LoRA Resize (Fixed Rank) in silveroxides' ComfyUI-ModelUtils. Instead of you picking a target rank and hoping it's the right tradeoff, LoRA Resize (Frobenius) lets you specify how much of the LoRA's original signal to keep - as a percentage - and works out the rank needed to hit that target. The node's own description: "Dynamically resize LoRA to preserve target fraction of Frobenius norm."

    The mechanism. It reconstructs the full-size weight delta the LoRA represents (multiplying its low-rank matrices back together), runs SVD on that reconstruction, and keeps adding singular values until the retained set accounts for your target fraction of the original matrix's Frobenius norm - a standard measure of a matrix's overall magnitude. A layer that carries most of its signal in a few dominant directions can hit a high retention target at a low rank; a layer with a flatter, more spread-out singular value profile needs more rank to reach the same target. Either way, the rank comes out per-layer and adaptive, rather than uniform across the whole LoRA.

    Inputs that matter. target (default 0.9, i.e. "keep 90% of the norm") is the dial that actually matters - lower it for a smaller file at some cost to fidelity, raise it toward 1.0 if a resize is coming out visibly weaker than the source. max_rank (default 128, range 1-3072) caps how far the adaptive selection can go, so a layer with a very gradual singular-value decay doesn't balloon trying to hit a stubbornly high target. svd_niter isn't exposed here the way it is in the extraction nodes - this node's controls are deliberately just target and max_rank alongside the shared output settings: output_filename (default resized_lora_fro), save_dtype (fp16), device (cuda), lazy_load (on by default), and force_clear_cache (off by default). Output is output_path.

    Installing it. ComfyUI Manager, search "Model Utility Toolkit" - or cd ComfyUI/custom_nodes && git clone https://github.com/silveroxides/ComfyUI-ModelUtils, then restart. No extra dependencies in the README.

    Frobenius vs Fixed vs Ratio. If you already know exactly what rank you want, Fixed Rank is simpler and more predictable. If you're chasing "as small as possible while staying close to the original," Frobenius (this node) or LoRA Resize (SV Ratio) - also in this pack - are the better fit, since both size the result to a fidelity target instead of a raw number. Between those two, Frobenius targets the reconstructed matrix's overall norm; Ratio keeps singular values above a threshold relative to the largest one. They'll often land in similar places for a moderate target; Frobenius is the more intuitive framing if you're thinking in terms of "percentage of the LoRA's actual signal retained."

    The honest limit. SVD can only work with what's already in the file - it can't recover detail the original extraction or training run never captured. This node is genuinely good at shrinking a LoRA down while losing as little as the math allows; it's not a way to upgrade a low-rank LoRA into something with more real capacity, since setting target near 1.0 on an already-compact LoRA just means there's very little to trim in the first place, not that you're adding anything back.

    Cost. A single LoRA is 10-200MB, nowhere near the multi-gigabyte checkpoints the extraction nodes juggle, so this is a comparatively light operation - which is why force_clear_cache defaults to off here (the tooltip calls it "slower but saves VRAM," worth flipping on only if you're genuinely VRAM-constrained). If a resized LoRA looks off, check target and max_rank before assuming something's broken - an unreachably high target against a low max_rank ceiling will silently cap out short of what you asked for.

    CategoryModelUtils/LoRA/Resize

    Inputs (8)

    NameTypeDefaultDescription
    lora_nameCOMBOLoRA to resize
    max_rankINT1281–3072Maximum allowed rank
    targetFLOAT0.900.1–1Target Frobenius norm retention (0.9 = 90%)
    output_filenameSTRINGresized_lora_fro
    save_dtypeCOMBOfp163 options: fp16, bf16, fp32
    deviceCOMBOcuda2 options: cuda, cpu
    lazy_loadBOOLEANtrueLow memory mode: load tensors from disk on demand
    force_clear_cacheBOOLEANfalseClear CUDA cache after each layer (slower but saves VRAM)

    Outputs (1)

    NameTypeDescription
    output_pathSTRING