# comfyui-lora-range-loader (ComfyUI) ![LoRA Range Loader icon](comfyui-lora-range-loader-icon-256.png) Custom node for ComfyUI that loads a LoRA like the core `LoraLoaderModelOnly`, but adds a filename range sweep workflow for testing many LoRA checkpoints from the same training run. ## What this node does - Adds the node **Load LoRA Range (Model Only)**. - Loads the LoRA selected in `current` exactly like the core model-only LoRA loader. - Adds `first` and `last` fields to define an allowed filename range. - Adds `mode` to control how `current` changes after each queued run. - Supports these modes: - `fixed`: keep `current` unchanged - `increment`: move to the next filename in the sorted `first..last` range and wrap to `first` - `decrement`: move backward in the sorted `first..last` range and wrap to `last` - `random`: pick a random filename from the sorted `first..last` range ## How it works The node is split into two parts: - Backend Python loads only the LoRA selected in `current`. - Frontend JavaScript updates `current` after the workflow is queued. This means the LoRA used for the current execution is always the value visible in `current` at queue time, and the next value is prepared for the following run. ## Range rules - The list of LoRAs is sorted by filename in ascending order. - `first` must come before or equal to `last` in that sorted list. - If `first` comes after `last`, automatic switching is disabled. - If `current` is outside the `first..last` range, the node still loads that LoRA, but `increment`, `decrement`, and `random` do not change it. ## LoRA loading behavior - The node reuses the core `LoraLoader` implementation. - It does not load `first` or `last` into memory. - It only loads `current`. - It inherits the same single-entry cache as the core loader, so repeating the same `current` value does not reload the LoRA file unnecessarily. ## Compatibility Backend compatibility: - The Python node is lightweight and relies only on ComfyUI core APIs. - No extra Python packages are required. Frontend compatibility: - Full automatic switching of `current` requires a modern ComfyUI frontend that supports widget queue lifecycle hooks. - If the frontend extension does not run, the backend node still works as a manual `current` LoRA loader. ## How to use 1. Add **Load LoRA Range (Model Only)** to the graph. 2. Connect your `MODEL` input. 3. Choose `first`, `last`, and `current` from the LoRA dropdowns. 4. Choose `mode`. 5. Run the workflow repeatedly. 6. Observe `current` advancing for the next run according to `mode`. ## Install via ComfyUI-Manager 1. Open **Manager** in ComfyUI. 2. Install this node from the list or by repository URL. 3. Restart ComfyUI or refresh node definitions. ## Manual install 1. Clone or copy this repository into `ComfyUI/custom_nodes/`. 2. Restart ComfyUI. No additional Python dependencies are needed. ## Included files - [`__init__.py`](__init__.py) - backend node definition - [web/lora_range_loader.js](web/lora_range_loader.js) - frontend logic that advances `current` ## Notes for publishing - The Registry package name in `pyproject.toml` is intended to be stable and should be treated as immutable after publishing. - If you want a different final GitHub repository URL or package name, change it before the first Registry publish.