Nodes/Comfyui-DiffusersUtils/Diffusers Save LoRA
ComfyUI Node

Diffusers Save LoRA

Save the LoRA you just hacked together

By lrzjason·Created 9 months ago·Updated 8 months ago· 14
Diffusers Save LoRA
  • lora
    filenamemy_lora.safetensors
    output_dir/tmp/ComfyUI/output

    DiffusersSaveLora is the endpoint for the pack's LoRA-editing story. Load a LoRA, zero or scale some transformer blocks with DiffusersLoraLayersOperation, and then persist the result to disk as a .safetensors file. It's a terminal node - no outputs, just a file landing somewhere you can find it.

    Inputs

    • lora - the LORA state dict, typically the modified_lora from DiffusersLoraLayersOperation (though it'll happily save anything you feed it, including a freshly-loaded untouched LoRA).
    • filename - what to call the file (default my_lora.safetensors). If you leave off the extension it appends .safetensors for you.
    • output_dir - optional. Leave it empty and the file goes to ComfyUI's default output directory; set it and it saves wherever you point, creating the directory if needed.

    What it actually does - and the one surprise

    Before writing, the node sweeps the state dict for tensors that are all zeros and drops them from the file, logging how many it removed. That's the behavior worth understanding: those layers you zeroed out with the layers-operation node don't survive the save. If you zeroed a block to disable a concept, that's exactly what you want - the saved LoRA is leaner and the block is gone, not merely muted. If you were hoping to save the scaled but not zeroed edits, those still save fine; only all-zero tensors get stripped.

    The output is a proper safetensors file written with the safetensors library, so anything that reads a LoRA - ComfyUI's normal loaders, other tools, training utilities - can pick it back up.

    Install

    ComfyUI Manager → "Comfyui-DiffusersUtils", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lrzjason/Comfyui-DiffusersUtils
    

    Restart ComfyUI. No extra deps for the LoRA path, and remember the README's requirements.txt step is a dead end (no such file ships).

    A practical note

    This node is where the whole "edit a LoRA before it's applied" workflow gets its payoff - you can build a small library of block-modified LoRAs from one download, or turn a one-off experiment into a file you keep. Check the console log after running: it prints the save path and the layer count before/after the zero-filter, which is your confirmation the edit took. And since it's a terminal node with no outputs, don't expect to wire anything downstream of it - it ends the line, on purpose.

    CategoryDiffusers/Lora

    Inputs (3)

    NameTypeDefaultDescription
    loraLORAThe modified LoRA state dictionary to save.
    filenameSTRINGmy_lora.safetensorsFilename to save the LoRA as (e.g. my_lora.safetensors).
    output_diroptSTRING/tmp/ComfyUI/outputDirectory to save the LoRA to. Defaults to ComfyUI output directory if not provided.

    Outputs (0)

    No outputs