ComfyUI Extension: ComfyUI-Rebase-LoRA
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
This custom node builds a new LoRA or patch file relative to a finetuned model, computing weight differences and writing results as standard LoRA or exact diff patch files.
README
ComfyUI Rebase LoRA From Finetune
This custom node builds a new LoRA or patch file relative to a finetuned model.
It computes:
(base model + source LoRA) - finetuned model
and then writes the result back out as either:
- a standard low-rank LoRA (
output_mode = standard), or - an exact diff patch file (
output_mode = full_diff_patch).
What changed in this version
This version adds several practical improvements:
- proper
.alphatensors for standard LoRA output - canonical LoRA prefixes when available, instead of raw state-dict keys
- selectable compute device (
auto,cpu,cuda) - selectable SVD strategy (
auto,full,lowrank) - CUDA SVD driver option for
torch.linalg.svd - per-layer CUDA-to-CPU fallback on SVD failure or OOM
- bias diffs now resolve against the corresponding weight prefix, so
.diff_bkeys load correctly - tuple-style loader targets are normalized in
original_lora_only, improving compatibility with mapped/sliced patch keys torch.inference_mode()/ inference-style execution- passthrough of simple metadata like
prompt,description,tool
Files
ComfyUI-Rebase-LoRA/
├── __init__.py
├── rebase_lora_node.py
├── README.md
└── js/
└── rebase_lora_ui.js
Install
Copy the folder into:
ComfyUI/custom_nodes/ComfyUI-Rebase-LoRA
Then restart ComfyUI.
Node
Node name: Rebase LoRA From Finetune
Required inputs
base_model(MODEL)finetuned_model(MODEL)base_lora_namesave_relpathranklayer_scoperank_modeoutput_modestrength_modelstrength_clipsave_dtypebias_diffclamp_quantileinclude_clipcompute_devicesvd_modecuda_svd_driverlowrank_oversamplelowrank_niter
Optional inputs
base_clip(CLIP)finetuned_clip(CLIP)
Recommended workflow
CheckpointLoaderSimple (base) ---- model ----┐
---- clip ---┤
│
CheckpointLoaderSimple (finetune) ---- model --┼--> Rebase LoRA From Finetune
---- clip ---┤
│
base_lora_name ----┘
If your source LoRA includes text-encoder weights, connect both clip inputs and leave include_clip = true.
Practical settings
Fastest exact patch export
output_mode = full_diff_patch
compute_device = cpu
This skips SVD entirely. It is usually the best choice when you care more about speed and fidelity than file size.
Smaller standard LoRA, safe default
layer_scope = original_lora_only
rank_mode = match_input_lora_when_possible
output_mode = standard
compute_device = auto
svd_mode = auto
This keeps the output focused on the layers touched by the source LoRA and uses GPU only when available.
Push speed on a CUDA box
output_mode = standard
compute_device = cuda
svd_mode = auto
cuda_svd_driver = auto
lowrank_oversample= 16
lowrank_niter = 2
That is the reasonable performance preset. If CUDA SVD blows up on one layer, the node falls back to CPU for that layer instead of dying dramatically like a Victorian inventor.
Most faithful standard LoRA extraction
output_mode = standard
compute_device = auto
svd_mode = full
cuda_svd_driver = auto
This stays with full SVD per layer, so it avoids randomized low-rank approximation.
Notes on performance
- The cheap part is weight subtraction.
- The expensive part is SVD / low-rank factorization.
full_diff_patchmostly needs memory bandwidth and disk I/O.standardmode is where CUDA helps a lot, because the bottleneck is dense linear algebra.svd_mode = lowrankor CUDAautocan be much faster when your requested rank is much smaller than the layer size, but it is an approximation path.
Save path behavior
save_relpathis relative to the first registered ComfyUIlorasfolder..safetensorsis optional.- If the target filename already exists, the node increments it:
rebased/my_lora.safetensors
rebased/my_lora_00001.safetensors
rebased/my_lora_00002.safetensors
Output details
standard
Writes:
<prefix>.lora_up.weight
<prefix>.lora_down.weight
<prefix>.alpha
and bias diffs as:
<prefix>.diff_b
full_diff_patch
Writes:
<prefix>.diff
and optional bias diffs as:
<prefix>.diff_b
Caveats
- A rebased LoRA is still a low-rank approximation unless you use
full_diff_patch. svd_mode = lowrankuses randomized low-rank SVD under the hood, so tiny numeric differences between runs are possible.- GPU acceleration is mainly useful for
standardmode. Forfull_diff_patch, CPU is usually fine. - The node uses the effective incoming MODEL/CLIP weights. If you feed already-patched models into it, those patches become part of the source or finetuned side.
- The JS extension adds a node context-menu action to auto-fill the save path from the selected LoRA name.
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.