KJNodes/loragenerated

LoraReduceRank

This node is based on resize_lora from kohya-ss's sd-scripts

Lora Reduce Rank

lora_name
COMBO
new_rank
8
dynamic_method
disabled
dynamic_param
0.20
output_dtype
match_original
verbose
KJNodes

The LoraReduceRank node, based on resize_lora from kohya-ss's sd-scripts.

The LoraReduceRank node is a tool for reducing the rank of a LoRA model. Its core function is to read an existing LoRA model, reduce the model file size and computational requirements by adjusting the dimensions of its internal parameter matrices, and save the processed new model to the output directory.

Node Functionality

This node is implemented based on the resize_lora.py script from kohya-ss's sd-scripts. It supports multiple dynamic rank reduction methods, including those based on singular value ratio, cumulative sum, Frobenius norm, or detecting the elbow point in the singular value curve, allowing users to specify a fixed new rank or set a dynamic threshold to automatically determine an appropriate rank. The node can handle various data precision formats and preserves metadata compatible with the original model.

Node Parameter Description - LoraReduceRank

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
lora_nameCOMBOYes--Select the target model file from the list of loaded LoRA models that requires rank reduction processing.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
dynamic_methodCOMBOYesdisabled"disabled", "sv_ratio", "sv_cumulative", "sv_fro", "sv_knee"Method to use for dynamically determining new alphas and dims. sv_knee finds the elbow point in the singular value curve.
output_dtypeCOMBOYesmatch_original"match_original", "fp16", "bf16", "fp32"Data type to save the LoRA as: match_original, fp16, bf16, or fp32.
new_rankINTYes81 - 4096 (Step: 1)The new rank to resize the LoRA. Acts as max rank when using dynamic_method.
dynamic_paramFLOATYes0.20.0 - 2.0 (Step: 0.01)Parameter for dynamic methods. For sv_knee: sensitivity (1.0=standard knee, <1.0=more aggressive/lower rank, >1.0=more conservative).
verboseBOOLEANYesTrue-Controls whether detailed processing logs are output to the console. Enabling (True) aids in debugging and understanding rank reduction details.

Usage Scenarios

In an actual workflow, you can use this node when you find a LoRA model file is too large or its inference speed is too slow. For example, after loading a high-rank LoRA for stylized generation, you can connect it to this node, set a lower new_rank value, and run it. A new, smaller, and more efficient LoRA file will be available in the output folder for use in subsequent processes.

Notes

Please note that this is an experimental node. Rank reduction is a lossy compression technique; excessively reducing the rank may significantly affect the performance of the LoRA model. The node itself does not output tensors; it only performs file save operations.

The LoraReduceRank node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…