Skip to content

Conversation

@woct0rdho
Copy link
Contributor

@woct0rdho woct0rdho commented Aug 14, 2025

This PR is based on #2057 . It supports resizing ControlLoRA (LoRA version of ControlNet). We can save a ControlLoRA using ControlLoraSave node in stability-ComfyUI-nodes, then resize it using networks/resize_lora.py.

For example, I've uploaded some resized ControlLoRAs in https://huggingface.co/woctordho/sdxl-control-lora . They help save some VRAM from 2.5 GB (the original ControlNet) to 0.3 GB (the resized ControlLoRA).

@kohya-ss kohya-ss requested a review from Copilot August 14, 2025 23:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the LoRA resizing functionality to support ControlLoRA, which is a LoRA version of ControlNet. The changes enable resizing of ControlLoRA models that can be saved using the ControlLoraSave node from stability-ComfyUI-nodes.

  • Adds support for multiple LoRA naming formats beyond the original format
  • Implements dynamic format detection to handle different trainer formats
  • Updates key construction logic to work with the detected format

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kohya-ss
Copy link
Owner

Thank you, this is a good idea to generalize the converter. Could you please check the Copilot review?
I also think that passing LORAFMT as a parameter instead of globally is a good idea.

@woct0rdho
Copy link
Contributor Author

woct0rdho commented Aug 15, 2025

I agree that using global variables is a bad practice (it was a quick patch based on the previous PR). I'll refactor it.

@woct0rdho
Copy link
Contributor Author

woct0rdho commented Aug 15, 2025

I've refactored the code to avoid the mutable global variable (there is no need to rename lora_down and lora_up in param_dict). I've tested that the 3 LoRA formats can be converted by this script, and they work as intended in ComfyUI.

@kohya-ss
Copy link
Owner

Thank you for update! This looks good.

@kohya-ss kohya-ss merged commit 2857f21 into kohya-ss:main Aug 15, 2025
1 check passed
@woct0rdho woct0rdho deleted the resize-control-lora branch August 15, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants