Nodes/KJNodes for ComfyUI/LoraReduceRank
ComfyUI Node Runs on cloud

LoraReduceRank

Shrink a LoRA's rank without retraining it

By kijai·Created 3 years ago·Updated about 15 hours ago· 2,930
LoraReduceRank
      lora_name
      new_rank8
      dynamic_methoddisabled
      dynamic_param0.20
      output_dtypematch_original
      verbosetrue

      If you've trained a LoRA at a high rank because you wanted the extra capacity during training, and now you're staring at a file you'd rather not distribute at that size, this is the node for that. LoraReduceRankKJ takes an existing LoRA and shrinks its rank after the fact - no retraining, no dataset needed. It's a straight port of a function out of kohya's sd-scripts (resize_lora.py), the same reference toolkit whose vocabulary - network_dim, network_alpha - basically is the community's shared language for talking about LoRA rank. If you've ever set a rank/alpha pair following a guide, you were speaking Kohya's dialect whether the guide said so or not.

      How it actually shrinks a LoRA

      A LoRA's weight is a low-rank decomposition, ΔW = A · B, and rank is just how "tall" that decomposition is allowed to be. Reducing rank means running an SVD on each layer's delta and keeping only the top singular values - the directions that account for most of what the LoRA actually changed - and throwing the rest away. It's lossy by construction: you're discarding information, not compressing it losslessly. How much you lose depends on how "spread out" the original LoRA's weight changes were across its rank. A character LoRA trained tight and specific compresses more gracefully than a broad style LoRA that was genuinely using its full rank.

      The inputs and outputs that matter

      This one's an output node with no output socket - it writes the resized LoRA straight to disk rather than passing anything downstream, the same shape as a Save node.

      • lora_name - picked from your loras folder (has to already be there for the dropdown to see it).
      • new_rank - the target rank, default 8. This is the whole point of the node; go lower for a smaller file, but expect visible quality loss below whatever rank your LoRA was actually using.
      • dynamic_method and dynamic_param - an alternative to a flat new_rank: instead of forcing every layer to the same size, let the algorithm pick each layer's effective rank based on how much of its singular-value energy is worth keeping. Leave dynamic_method on its default ("disabled") until you've got a feel for what a flat rank does to your specific LoRA.
      • output_dtype - defaults to match_original, so unless you have a reason to change precision, leave it.
      • verbose - prints the resize stats to your console; keep it on the first few times so you can see what actually happened.

      How to install it

      It's part of KJNodes: ComfyUI Manager → search "KJNodes for ComfyUI" → install, or cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, pip install -r ComfyUI-KJNodes/requirements.txt, restart. Nothing extra beyond the pack's own requirements - no separate model download, it just needs your LoRA file already sitting in models/loras.

      Common issues & troubleshooting

      Setting new_rank above the LoRA's original rank does nothing. SVD truncation only removes information; it can't invent more than was there. If your source LoRA was trained at rank 8 and you ask for rank 32, you'll get a bigger file with the same effective content - not a higher-capacity LoRA.

      No output socket means no in-graph confirmation. Because this saves directly to disk, there's nothing to preview inline in the workflow - check your output folder (or the console log, with verbose on) to confirm the run actually did something rather than assuming it worked because the queue finished.

      Quality drops off a cliff past a certain point, and it's LoRA-specific. There's no universal "safe" rank to reduce to. Start high, generate a few test images, and step the rank down until you see the difference you're not willing to accept - then back off one step.

      CategoryKJNodes/lora

      Inputs (6)

      NameTypeDefaultDescription
      lora_nameCOMBOThe name of the LoRA.
      new_rankINT81–4096The new rank to resize the LoRA. Acts as max rank when using dynamic_method.
      dynamic_methodCOMBOdisabledMethod to use for dynamically determining new alphas and dims. sv_knee finds the elbow point in the singular value curve.
      dynamic_paramFLOAT0.200–2Parameter for dynamic methods. For sv_knee: sensitivity (1.0=standard knee, <1.0=more aggressive/lower rank, >1.0=more conservative).
      output_dtypeCOMBOmatch_originalData type to save the LoRA as.
      verboseBOOLEANtrue

      Outputs (0)

      No outputs