LoRA Truncate Rank (CCN)
LoRA Truncate Rank (CCN)
- filepath
LoRA Truncate Rank (CCN) is the disk-space and VRAM diet for one specific kind of file: LoRAs that came out of SVD extraction. When you distill a full model fine-tune into a LoRA with a tool like kohya extract or LoraExtractKJ, the result is often a high-rank file - rank 128, 256, whatever the extractor chose - that's bigger and heavier than it needs to be. This node cuts it down to a smaller rank by slicing off the least important components, and it does it in seconds because it doesn't bother redoing the math.
The trick, and the reason it's fast: SVD extraction stores a LoRA's components in descending order of importance. The first N components are the N most significant ones, by construction. So truncating rank N is literally slicing the weight matrices - keep rows 0..N, drop the rest. No re-decomposition, no reconstruction, no SVD pass. The source docstring is blunt: "runs in seconds vs. minutes for full re-decomposition."
Here's the warning that deserves all caps, straight from the node's own description: this is NOT valid for trained LoRAs. A LoRA produced by actual training does not have its rank dimensions ordered by importance - its components are entangled, not sorted. Truncating a trained LoRA discards arbitrary components rather than the least significant ones, which means a file that still loads but quietly produces different, degraded output. Only use this on SVD-extracted files. If you didn't extract it yourself, you don't know; treat "SVD-extracted" as a requirement, not a suggestion.
The inputs that matter:
- lora_name - the source file.
- new_rank - target rank, must be less than the source's. Default 32. Layers already at or below the target are left alone, so it only trims what needs trimming.
- filename_prefix - where the new file goes (default
loras/CCN_truncated_lora, saved under your output directory). - output_dtype - match_original, fp16, bf16, fp32, or fp8. The fp8 option halves size vs fp16 "with minimal quality loss," per the tooltip - and given the KB's consensus that fp8 is essentially free at inference, that's the option I'd actually pick for a keep-around copy.
- verbose - prints per-layer rank changes to the console.
It detects the file's key format (kohya lora_down/lora_up, PEFT lora_A/lora_B, ControlLoRA down/up) and derives the alpha keys correctly. Output is filepath - the saved file, and it's an output node so the path shows in the UI.
Install
ComfyUI Manager → "ComfyCollectorNodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/valkymaera/ComfyCollectorNodes
Restart ComfyUI; it's under CCN/lora as "LoRA Truncate Rank (CCN)". It pulls in numpy and tqdm on top of stock ComfyUI - both are ubiquitous in this ecosystem and almost certainly already present, but they're the only extra deps in the whole pack to speak of. No model downloads, MIT.
Common issues
The trained-LoRA trap is the one real failure mode, and it won't error - it'll just silently change what the file does. If you're not certain of a file's provenance, run it through LoRA Metadata (CCN) first and look for ss_network_args or extraction markers; when in doubt, skip. Also, new_rank below 1 or above the source rank gets refused or left as a no-op, so don't fight it. And when you test the result, load it at 1.0 against the same base model the original targeted - truncation doesn't change architecture, but it changes the effective behavior enough that strength may need a nudge.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| lora_name | COMBO | Source LoRA file. Must be from SVD extraction, not training. | |
| new_rank | INT | 321–4096 | Target rank. Must be less than the source LoRA's rank. Layers already at or below this rank are left unchanged. |
| filename_prefix | STRING | loras/CCN_truncated_lora | Output path and filename prefix (relative to output directory). |
| output_dtype | COMBO | match_original | Data type for saved tensors. fp8_e4m3 halves size vs fp16 with minimal quality loss. |
| verbose | BOOLEAN | true | Print per-layer rank changes to console. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| filepath | STRING | — |