Nodes/ComfyUI Flux Trainer/Extract Flux LoRA
ComfyUI Node

Extract Flux LoRA

Turn a full fine-tune into a shippable LoRA

By kijai·Created 2 years ago·Updated about a year ago· 1,156
Extract Flux LoRA
    • output_path
    original_model
    finetuned_model
    output_path/tmp/ComfyUI/models/loras/Flux
    dim4
    save_dtypebf16
    load_devicecuda
    store_devicecpu
    clamp_quantile0.99
    metadatatrue
    mem_eff_safe_openfalse

    Say you did a full Flux fine-tune - a multi-gigabyte checkpoint - and now you want to hand it out as a tidy little LoRA instead. ExtractFluxLoRA does exactly that. It takes your original base model and your fine-tuned model, computes the difference between them, and compresses that difference into a LoRA file. Same learned change, a fraction of the size.

    This is the "middle ground" of distribution. Full fine-tuning gives the best quality but ships as gigabytes; a LoRA ships as megabytes but is trained as an approximation from the start. Extraction lets you train the high-quality way and distribute the compact way - you keep the fine-tune's quality baked into a LoRA-shaped diff.

    How it works

    The node diffs two models and outputs an output_path (STRING) pointing at the extracted LoRA. The inputs that matter:

    • original_model - the base Flux model you started from (a dropdown of your model files).
    • finetuned_model - your fine-tuned result. The extraction is finetuned − original.
    • dim (default 4) - the rank of the extracted LoRA. Higher captures more of the fine-tune's changes at a bigger file size; lower is more compressed and lossier. This is the main quality/size dial.
    • clamp_quantile (default 0.99) - clamps outlier values during the singular-value decomposition, which keeps the extraction stable. The default is sensible; leave it unless you know why you're changing it.
    • save_dtype (default bf16) - precision of the output file.
    • load_device / store_device - where the heavy math runs (cuda to compute) and where results are held (cpu to spare VRAM). The defaults balance speed and memory.

    When you'd use it

    Two honest cases. One: you fine-tuned and want a distributable LoRA without retraining. Two: you want to convert a big checkpoint you got elsewhere into a LoRA you can stack at inference. If you only ever trained a LoRA to begin with, you don't need this node at all - you already have the LoRA.

    Installing the pack

    ComfyUI Manager: search ComfyUI Flux Trainer, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kijai/ComfyUI-FluxTrainer
    pip install -r ComfyUI-FluxTrainer/requirements.txt
    

    Torch 2.4.0+ recommended, plus kijai's ComfyUI-KJNodes for the example workflows.

    Common issues

    dim is a quality/size tradeoff, not free. Extraction into too low a rank loses detail from the fine-tune; too high and you've made a bloated LoRA that barely beats the checkpoint on size. Start around the default and raise dim if the extracted LoRA doesn't reproduce the fine-tune closely enough.

    Mismatched models give garbage. The two models must be the same architecture and lineage - a Flux fine-tune against a Flux base. Diffing incompatible models produces a meaningless LoRA.

    It's not lossless. An extracted LoRA is an approximation of the full fine-tune, not an identical copy. For the absolute best quality you'd distribute the checkpoint itself; extraction is the practical compromise when size matters.

    CategoryFluxTrainer

    Inputs (10)

    NameTypeDefaultDescription
    original_modelCOMBO0 options:
    finetuned_modelCOMBO0 options:
    output_pathSTRING/tmp/ComfyUI/models/loras/Flux
    dimINT42–1024LoRA rank
    save_dtypeCOMBObf16the dtype to save the LoRA as
    load_deviceCOMBOcudathe device to load the model to
    store_deviceCOMBOcputhe device to store the LoRA as
    clamp_quantileFLOAT0.990–1clamp quantile
    metadataBOOLEANtruebuild metadata
    mem_eff_safe_openBOOLEANfalsememory efficient loading

    Outputs (1)

    NameTypeDescription
    output_pathSTRING