ComfyUI Node

Save LoRA

Bake your edited LoRA back into a .safetensors file

By lrzjason·Created 11 months ago·Updated 5 months ago· 32
Save LoRA
  • lora
    filenamemy_lora.safetensors
    output_dir/tmp/ComfyUI/output
    remove_zero_layersfalse

    All the editing nodes in this pack give you a modified LoRA in memory - useful for one generation, gone the next. Save LoRA is the persistence layer: it writes that state dict to disk as a real .safetensors file, so your surgery becomes a permanent LoRA you can load anywhere, share, or build workflows around.

    The point of this node only makes sense inside the pack's own philosophy. You zero out a few overbaked layers, merge a style with a character LoRA, or re-key a file for a different trainer - and then you keep the result as a first-class file instead of re-running the whole edit chain every time. It's the difference between a one-off experiment and a deliverable.

    Three settings do the work:

    • lora - the modified state dict from any upstream node in the pack.
    • filename - the name to save as (default my_lora.safetensors). The node appends the .safetensors extension if you forget it.
    • output_dir - optional; defaults to ComfyUI's output directory. Point it at your models/loras folder and the new file shows up in every LoRA loader dropdown after a refresh.
    • remove_zero_layers - when on, it drops any tensor whose values are all zero before saving. Defaults to off, but if you've zeroed out layers with LoRA Layers Operation, turning this on shrinks the file and keeps it clean.

    Mechanically it's a thin wrapper around safetensors.torch.save_file - the same writer that produces every LoRA you've ever downloaded. It will overwrite an existing file with the same name without asking, and it prints the save location to the console so you can confirm where things landed. It's an output node: no outputs to wire, it just executes when you queue the graph.

    The gotchas are the kind you only hit once. Overwrite-without-warning is the big one - don't name a file after something you care about unless you've got a backup. Second, the saved file is the raw state dict; it doesn't carry the full metadata header (training details, CivitAI info) that files straight from a trainer have. ComfyUI will load it fine and it'll merge like any other LoRA, but it's a bare file, not a pedigree. And keep remove_zero_layers in mind for the other direction: if your LoRA legitimately has tiny but non-zero weights everywhere, this toggle changes nothing, because it only strips all-zero tensors.

    One honest note about the workflow that surrounds this node: editing then re-saving a LoRA is a real technique, but it's also a good way to destroy a good LoRA if you don't know what you're doing. Save to a new filename, keep the original, and A/B test the baked version against the source at a fixed seed before you commit to it. When the edit is good, though, having it as a plain file means you never re-derive it again.

    Installation is the pack's standard two-liner with zero extra dependencies - torch and safetensors, both already in ComfyUI:

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

    Restart ComfyUI and look under LoraUtils. ComfyUI Manager users can search for Comfyui-LoraUtils. It's a small pack from lrzjason (a.k.a. xiaozhijason on Civitai) with a quiet community footprint, so expect the node to work exactly as documented - and not a single nicety more.

    CategoryLoraUtils

    Inputs (4)

    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.
    remove_zero_layersoptBOOLEANfalseRemove layers where all values are zero before saving.

    Outputs (0)

    No outputs