Skip to main content
ComfyUI includes native support for training LoRA (Low-Rank Adaptation) models without requiring external tools or custom nodes. This guide covers how to use the built-in training nodes to create your own LoRAs.
The training nodes are marked as experimental. Features and behavior may change in future releases.

Overview

The native LoRA training system consists of four nodes:
NodeCategoryPurpose
Train LoRAtrainingTrains a LoRA model from latents and conditioning
Load LoRA ModelloadersApplies trained LoRA weights to a model
Save LoRA WeightsloadersExports LoRA weights to a safetensors file
Plot Loss GraphtrainingVisualizes training loss over time

Requirements

  • A GPU with sufficient VRAM (training typically requires more memory than inference)
  • Latent images (encoded from your training dataset)
  • Text conditioning (captions for your training images)

Basic training workflow

1

Prepare your dataset

Encode your training images to latents using a VAE Encode node. Create text conditioning for each image using CLIP Text Encode.
For best results, use high-quality images that represent the style or subject you want to train.
2

Configure the Train LoRA node

Connect your model, latents, and conditioning to the Train LoRA node. Set the training parameters:
  • batch_size: Number of samples per training step (default: 1)
  • steps: Total training iterations (default: 16)
  • learning_rate: How quickly the model adapts (default: 0.0005)
  • rank: LoRA rank - higher values capture more detail but use more memory (default: 8)
3

Run training

Execute the workflow. The node will output:
  • lora: The trained LoRA weights
  • loss_map: Training loss history
  • steps: Total steps completed
4

Save and use your LoRA

Connect the output to Save LoRA Weights to export your trained LoRA. Use Load LoRA Model to apply it during inference.

Train LoRA node

The main training node that creates LoRA weights from your dataset.

Inputs

ParameterTypeDefaultDescription
modelMODEL-Base model to train the LoRA on
latentsLATENT-Encoded training images
positiveCONDITIONING-Text conditioning for training
batch_sizeINT1Samples per step (1-10000)
grad_accumulation_stepsINT1Gradient accumulation steps (1-1024)
stepsINT16Training iterations (1-100000)
learning_rateFLOAT0.0005Learning rate (0.0000001-1.0)
rankINT8LoRA rank (1-128)
optimizerCOMBOAdamWOptimizer: AdamW, Adam, SGD, RMSprop
loss_functionCOMBOMSELoss function: MSE, L1, Huber, SmoothL1
seedINT0Random seed for reproducibility
training_dtypeCOMBObf16Training precision: bf16, fp32
lora_dtypeCOMBObf16LoRA weight precision: bf16, fp32
algorithmCOMBOloraTraining algorithm (lora, lokr, oft, etc.)
gradient_checkpointingBOOLEANtrueReduces VRAM usage during training
checkpoint_depthINT1Depth level for gradient checkpointing (1-5)
offloadingBOOLEANfalseOffload model to RAM (requires bypass mode)
existing_loraCOMBO[None]Continue training from existing LoRA
bucket_modeBOOLEANfalseEnable resolution bucketing for multi-resolution datasets
bypass_modeBOOLEANfalseApply adapters via hooks instead of weight modification

Outputs

OutputTypeDescription
loraLORA_MODELTrained LoRA weights
loss_mapLOSS_MAPTraining loss history
stepsINTTotal training steps completed

Load LoRA Model node

Applies trained LoRA weights to a diffusion model. Use this instead of the standard Load LoRA node when working with LoRA weights directly from the Train LoRA node.

Inputs

ParameterTypeDefaultDescription
modelMODEL-Base diffusion model
loraLORA_MODEL-Trained LoRA weights
strength_modelFLOAT1.0LoRA strength (-100 to 100)
bypassBOOLEANfalseApply LoRA without modifying base weights

Output

OutputTypeDescription
modelMODELModel with LoRA applied

Save LoRA Weights node

Exports trained LoRA weights to a safetensors file in your output folder.

Inputs

ParameterTypeDefaultDescription
loraLORA_MODEL-Trained LoRA weights to save
prefixSTRINGloras/ComfyUI_trained_loraOutput filename prefix
stepsINT(optional)Training steps for filename
The saved file will be named {prefix}_{steps}_steps_{counter}.safetensors and placed in your ComfyUI/output/loras/ folder.

Plot Loss Graph node

Visualizes training progress by plotting loss values over training steps.

Inputs

ParameterTypeDefaultDescription
lossLOSS_MAP-Loss history from Train LoRA
filename_prefixSTRINGloss_graphOutput filename prefix

Training tips

VRAM optimization

  • Enable gradient_checkpointing to significantly reduce VRAM usage (enabled by default)
  • Use bypass_mode when working with quantized models (FP8)
  • Enable offloading to move the model to RAM during training (requires bypass_mode)
  • Lower the batch_size if you encounter out-of-memory errors

Dataset preparation

  • Use consistent image dimensions when possible, or enable bucket_mode for multi-resolution training
  • Match the number of conditioning inputs to the number of latent images
  • Quality matters more than quantity—start with 10-20 high-quality images

Training parameters

  • rank: Start with 8-16 for most use cases. Higher ranks (32-64) capture more detail but may overfit
  • steps: Start with 100-500 steps and monitor the loss graph
  • learning_rate: The default 0.0005 works well for most cases. Lower values (0.0001) for more stable training

Continuing training

Select an existing LoRA from the existing_lora dropdown to continue training from a previously saved checkpoint. The total step count will accumulate.

Supported algorithms

The algorithm parameter supports multiple weight adapter types:
  • lora: Standard Low-Rank Adaptation (recommended)
  • lokr: LoCon with Kronecker product decomposition
  • oft: Orthogonal Fine-Tuning

Example: Single-subject LoRA

A minimal workflow for training a LoRA on a specific subject:
  1. Load your training images with Load Image
  2. Encode images to latents with VAE Encode
  3. Create captions with CLIP Text Encode (e.g., “a photo of [subject]”)
  4. Connect to Train LoRA with:
    • steps: 200
    • rank: 16
    • learning_rate: 0.0001
  5. Save with Save LoRA Weights
  6. Test with Load LoRA Model connected to your inference workflow
For training on multiple images with different captions, connect multiple conditioning inputs to match your latent batch size.