Nodes/ComfyUI/Train LoRA
ComfyUI Node Runs on cloud

Train LoRA

A ComfyUI node in model/training with 21 inputs and 3 outputs.

By Comfy-Org·Created 4 years ago·Updated 15 days ago· 121,575
Train LoRA
  • model
  • latents
  • positive
  • lora
  • loss_map
  • steps
batch_size1
grad_accumulation_steps1
steps16
learning_rate0
rank8
optimizerAdamW
loss_functionMSE
seed0
training_dtypebf16
lora_dtypebf16
quantized_backwardfalse
algorithmLoRA
gradient_checkpointingtrue
checkpoint_depth1
offloadingfalse
existing_lora[None]
bucket_modefalse
bypass_modefalse
Categorymodel/training

Inputs (21)

NameTypeDefaultDescription
modelMODELThe model to train the LoRA on.
latentsLATENTThe Latents to use for training, serve as dataset/input of the model.
positiveCONDITIONINGThe positive conditioning to use for training.
batch_sizeINT11–10000The batch size to use for training.
grad_accumulation_stepsINT11–1024The number of gradient accumulation steps to use for training.
stepsINT161–100000The number of steps to train the LoRA for.
learning_rateFLOAT01e-7–1The learning rate to use for training.
rankINT81–128The rank of the LoRA layers.
optimizerCOMBOAdamWThe optimizer to use for training.
loss_functionCOMBOMSEThe loss function to use for training.
seedINT00–18446744073709550000The seed to use for training (used in generator for LoRA weight initialization and noise sampling)
training_dtypeCOMBObf16The dtype to use for training. 'none' preserves the model's native compute dtype instead of overriding it. For fp16 models, GradScaler is automatically enabled.
lora_dtypeCOMBObf16The dtype to use for lora.
quantized_backwardBOOLEANfalseWhen using training_dtype 'none' and training on quantized model, doing backward with quantized matmul when enabled.
algorithmCOMBOLoRAThe algorithm to use for training.
gradient_checkpointingBOOLEANtrueUse gradient checkpointing for training.
checkpoint_depthINT11–5Depth level for gradient checkpointing.
offloadingBOOLEANfalseOffload model weights to CPU during training to save GPU memory.
existing_loraCOMBO[None]The existing LoRA to append to. Set to None for new LoRA.
bucket_modeBOOLEANfalseEnable resolution bucket mode. When enabled, expects pre-bucketed latents from ResolutionBucket node.
bypass_modeBOOLEANfalseEnable bypass mode for training. When enabled, adapters are applied via forward hooks instead of weight modification. Useful for quantized models where weights cannot be directly modified.

Outputs (3)

NameTypeDescription
loraLORA_MODELLoRA weights
loss_mapLOSS_MAPLoss history
stepsINTTotal training steps