-
-
Notifications
You must be signed in to change notification settings - Fork 81
Add lora cycling (Enhancement request issue 316) #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add lora cycling (Enhancement request issue 316) #740
Conversation
Implements enhancement request willmiao#316 - adds ability to automatically cycle through a list of LoRAs on successive workflow runs. New nodes: - LoraCycler: Cycles through LoRAs with modes: fixed, increment, decrement, random - LoraRandomizer: Convenience alias with random mode as default Features: - Filter LoRAs by folder, base model, tags, or name - Accept lora_stack input for manual LoRA list control - Output correct trigger words for selected LoRA only - Uses IS_CHANGED method to trigger re-execution for cycling modes - Compatible with existing LORA_STACK type for downstream loaders Includes comprehensive test coverage (15 tests).
Changes: - Add web/comfyui/lora_cycler.js frontend extension that listens for execution events and updates connected TriggerWord Toggle nodes - Remove redundant LoraRandomizer node (use LoraCycler with random mode) - Improve tooltips with detailed examples for all filter options - Add OUTPUT_TOOLTIPS for clearer connection guidance The frontend extension: - Listens for ComfyUI 'executed' events - Extracts selected LoRA name from node output - Calls updateConnectedTriggerWords() to update TriggerWord Toggle nodes - Handles node mode changes (bypass/enable) and connection changes This fixes the issue where trigger words weren't populating in the TriggerWord Toggle node when using the Cycler.
…or LoraCycler - Add `/api/lm/loras/cycler_preview` API endpoint for real-time trigger word updates before workflow execution - Update frontend to call preview API when widgets change, enabling trigger words to populate immediately like the main LoRA Manager node - Add base model dropdown that fetches available base models from existing API - Add `first_trigger_word_only` option for LoRAs with multiple trigger words (e.g., multi-character LoRAs like Disney princesses) - Debounce widget changes to avoid excessive API calls - Update tests to cover new functionality Addresses user feedback about trigger words not populating before execution.
Maintainability improvements: - Extract shared filtering and selection logic into py/utils/lora_cycler_utils.py - API endpoint now uses shared utilities for consistent behavior with node - Shared execution counters between node and API New features: - Add "next up" display widget showing currently selected LoRA in node - Display format: "[index/total] LoRA Name" Documentation: - Add comprehensive docs/LORA_CYCLER.md with: - Connection patterns (Cycler -> Lora Loader + Cycler -> TriggerWord Toggle) - Explanation of why trigger_words should connect directly to TriggerWord Toggle - Filter options and examples - Selection modes documentation This refactor ensures the codebase is easier to maintain by: 1. Single source of truth for filtering logic 2. Shared counter state between preview and execution 3. Clear documentation for users and maintainers
- Remove duplicate lora_stack input from frontend (already defined in backend) - Remove unused imports from lora_cycler.py (select_lora_index, format_trigger_words) - Remove unused Tuple import from lora_cycler_utils.py The lora_stack input is defined in INPUT_TYPES in the Python node, so adding it again in the frontend JS created a duplicate.
|
Thank you so much for this PR! I really appreciate the time you put into it. I’ve taken it for a spin, and apart from some minor code issues, it works very well. It's a great feature. To be transparent, I have a similar feature currently in development. However, your approach has given me several new ideas that I plan to reference and incorporate into the official release. I won't be merging this specific PR, mostly due to time constraints. When features involve complex logic, aligning the design via text can be difficult. Since English isn't my first language, the detailed communication required to refine the PR often takes me longer than writing the code myself. I hope you understand that this isn't a reflection on the quality of your work, but just a time-management choice on my end. Thanks again for the great work—stay tuned for the update! |
Wonderful! Thank you. I completely understand and take no offense. I have been using my fork since I made it and really get a lot of usage from the enhancement. I will leave the PR open for your reference until you close it in case you need anything from it. I look forward to the update! Thank you again and happy new year! |
|
I've added the Lora Randomizer feature (see discussion #767 for details). To some extent, this can also function as a cycler, so feel free to give it a try. I'll evaluate whether to implement dedicated cycle support in the future. |
|
Hey! The Lora Cycler node has just been added to the nightly build. Feel free to update and give it a try — feedback is very welcome. |
Hi, Thank you for these! I am enjoying. You did a good job overall with how you've implemented these. One thing I think is not intended behavior from the cycler: |
|
PS my only other idea is to add "lora batch" inputs to randomizer and lora cycler nodes. That way i could chain things however i want - like maybe have the randomizer loading style loras, that feeds into lora cycler which is cycling through character loras, and that feeds into lora manager which outputs triggers for anything loaded. Thank you again for all of your work! Definitely one of my favorite node packs, I use it constantly. |
|
Thanks for the detailed feedback! I’ll look into the cycler behavior you described. As a quick note: although ComfyUI defaults to 100 jobs, you can raise the limit via Regarding the “LoRA batch” idea, I’m not fully clear on the use case yet. My current view of the LoRA Cycler is mainly for testing/comparison (iterating with fixed weights). Do you mean something like randomizing style LoRAs each time, then apply a character LoRA? If you could elaborate, that’d help. Also, in case it helps: this kind of setup is already possible by chaining loaders—e.g. one LoRA Loader fed by a LoRA Randomizer, followed by another LoRA Loader fed by a LoRA Cycler. Please refer to the two newly added template workflows. Thanks again for the kind words and suggestions! |
I know you said you are not taking PRs currently - but I spent some time with Claude, and tested this pretty thoroughly, and LOVE your node pack and really wanted this functionality! You are welcome to scrutinize and merge as-is, or just pick out what you do or do not like. I think it is a great addition so I hope you can integrate it!
Thank you for all of your work, and Merry Christmas.
LoRA Cycler Node - Enhancement Request (Issue #316)
Adds a node to cycle/randomize through LoRAs on each workflow execution.
Files added:
Files modified:
Usage:
Features:
Limitations: