ComfyUI Node

comfy

Train a LoRA on Civitai's GPU fleet, from ComfyUI

By civitai·Created 3 months ago·Updated 2 days ago· 44
comfy
  • continue_from
  • model
  • diffusion_model
  • text_encoder_model
  • vae_model
  • api_config
  • moderation_status
  • epochs
  • workflow_id
  • raw_json
training_data_json
uses_step_pricingfalse
requires_age_classificationfalse
storage_buzz_per_epoch0.00
default_steps0
max_batch_size0
samples_json
ecosystem
epochs1
steps1
batch_size1
lr0.00
text_encoder_lr0.00
train_text_encoderfalse
lr_scheduler
optimizer_type
network_dim1
network_alpha1
noise_offset0.00
flip_augmentationfalse
shuffle_tokensfalse
keep_tokens0
trigger_word
resolution1024
no_half_vaefalse
min_snr_gamma0
training_dtype
lora_dtype
quantized_backwardfalse
bypass_modefalse
grad_accumulation_steps0
loss_function
algorithm
checkpoint_depth0
offloadingfalse
clip_type
unet_weight_dtype
model_sampling_shift0.00
dataset_cachingfalse

Training a LoRA is the one job in this pack that's a real commitment, and for a lot of people it's also the one they can't do locally - no VRAM for it, or no desire to babysit a multi-hour run. This node moves the whole thing to Civitai's fleet: you hand over training data and hyperparameters, a hosted job trains your LoRA, and you get back a checkpoint per epoch, billed in Buzz. It's the ai-toolkit training pipeline, exposed as a single ComfyUI node.

What it is

comfy (display name) - CivitaiTrainingComfy - from civitai/civitai-comfy-nodes, under Civitai/Training/comfy. The discriminator pins the engine to comfy, meaning the hosted training backend runs the Comfy-style native training pipeline rather than the legacy AI-toolkit path. The tooltips make the pricing model explicit: training is billed per step, each epoch is a delivered checkpoint plus preview samples, and storage is a per-epoch surcharge on top.

The inputs that matter

The schema is enormous, but the ones that decide your run are few:

  • training_data_json - required. Your dataset, as JSON. This is where the KB's oldest lesson still rules: dataset curation beats every knob in this node. Caption well, keep the set consistent, and the rest of your settings just don't have to be perfect.
  • steps (1–10,000) and epochs (1–200) - the two ways to set training length. The tooltips describe the dance: steps is the primary control and determines pricing; when you supply it, epochs (the number of saved checkpoints) is derived from it, and vice versa. Epochs = downloadable models. Want several checkpoints to pick from? Set epochs; want a fixed budget? Set steps.
  • network_dim / network_alpha - rank and alpha. The tooltips are unusually candid: a larger Dim stores more but can learn junk and grows the file; with Alpha 16 and Dim 32 the effective strength is 16/32 = 0.5. Keep them equal to start.
  • lr (0.0001), optimizer_type (the tooltip's honest line: "the most commonly used in LoRA learning is adamw8bit"), lr_scheduler - the learning-rate trio.
  • trigger_word - the word that activates your LoRA in prompts. Only meaningful for certain ecosystems (sd1, sdxl, flux1, chroma, and friends), per the tooltip.
  • train_text_encoder - off by default, and per the KB that's the right instinct for modern models. Turning it on improves prompt understanding but adds time and memory.
  • model - CIVITAI_AIR. The checkpoint to train upon; wire a Model Selector. diffusion_model / text_encoder_model / vae_model are the split-model overrides for the native Comfy path.
  • continue_from - a previously trained LoRA, to keep training instead of starting from base. Nice for refining.
  • batch_size (1–4), resolution (256–1024, default 1024), noise_offset, flip_augmentation, shuffle_tokens / keep_tokens - the augmentation and efficiency controls.

The outputs

  • moderation_status - the age-classification / moderation result for your dataset (the node even has requires_age_classification as an input).
  • epochs - the list of trained checkpoints. This is your deliverable.
  • workflow_id / raw_json - the pack standard.

Installing it

ComfyUI Manager → Civitai Comfy Nodes → Install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/civitai/civitai-comfy-nodes.git
pip install -r civitai-comfy-nodes/requirements.txt

Gotchas

  • This is the expensive node. Per-step training plus per-epoch storage, all in Buzz. steps is literally described as "the primary control over training length and determines pricing" - treat it as your budget dial.
  • Your data leaves your machine - the entire dataset is uploaded to Civitai's fleet. Training is the one operation here where the "cloud" framing is not a convenience, it's the whole point.
  • Epochs are checkpoints, not iterations. Save several and pick the best - the last epoch is often overtrained, the KB's longest-running lesson.
  • Credentials required - Civitai Auth node, CIVITAI_API_TOKEN, or sidebar OAuth. Training with no balance will fail fast, not politely.
  • It's one node, but it's not a beginner's first run. If this is your first LoRA ever, the KB's advice holds: curate the dataset, don't train the text encoder, and don't trust the last epoch.
CategoryCivitai/Training/comfy

Inputs (45)

NameTypeDefaultDescription
training_data_jsonSTRINGRepresents training data in various formats
uses_step_pricingBOOLEANfalseWhether this run uses step-based pricing rather than the legacy flat per-epoch price.
requires_age_classificationBOOLEANfalseWhether age classification should run on this training type's dataset.
storage_buzz_per_epochFLOAT0.000–2147483647Per-epoch surcharge (buzz). Each epoch is a delivered checkpoint plus its preview samples, billed on top of the per-step training cost — so raising the epoch count raises the price by this much each. Override per ecosystem where per-epoch samples are expensive to compute (e.g. video).
default_stepsINT00–2147483647Default total step budget when neither Civitai.Orchestration.Grains.Workflows.Steps.Training.AIToolkit.AIToolkitTrainingInput.Steps nor Civitai.Orchestration.Grains.Workflows.Steps.Training.AIToolkit.AIToolkitTrainingInput.Epochs is supplied. Override per ecosystem where the default training length differs (e.g. video needs more steps, quickly-overtrained models need fewer).
max_batch_sizeINT00–2147483647
samples_jsonoptSTRINGSample generation configuration for training workflows
ecosystemoptSTRING
epochsoptINT11–200Number of training epochs — the number of saved checkpoints produced (each epoch yields one downloadable model). When omitted it is derived from Civitai.Orchestration.Grains.Workflows.Steps.Training.AIToolkit.AIToolkitTrainingInput.Steps; when both are supplied, both are honored (epochs = checkpoint count, steps = total).
stepsoptINT11–10000Total number of training steps. This is the primary control over training length and determines pricing. When supplied, Civitai.Orchestration.Grains.Workflows.Steps.Training.AIToolkit.AIToolkitTrainingInput.Epochs (the number of saved checkpoints) is derived from it; when omitted, steps are derived from epochs.
batch_sizeoptINT11–4Training batch size. Defaults to 1; raise it up to 4 for this ecosystem to train faster at the cost of more GPU memory.
lroptFLOAT0.000–1Sets the learning rate for the model. This is the learning rate when performing additional learning on each attention block (and other blocks depending on the setting).
text_encoder_lroptFLOAT0.000–1Sets the learning rate for the text encoder. Only used when TrainTextEncoder is true. For models with multiple text encoders, this applies to all of them.
train_text_encoderoptBOOLEANfalseWhether to train the text encoder(s) alongside the model. Enabling this can improve prompt understanding but increases training time and memory usage.
lr_scheduleroptCOMBOYou can change the learning rate in the middle of learning. A scheduler is a setting for how to change the learning rate.
optimizer_typeoptCOMBOThe optimizer determines how to update the neural net weights during training. Various methods have been proposed for smart learning, but the most commonly used in LoRA learning is "adamw8bit".
network_dimoptINT11–256The larger the Dim setting, the more learning information can be stored, but the possibility of learning unnecessary information other than the learning target increases. A larger Dim also increases LoRA file size.
network_alphaoptINT11–256The smaller the Network alpha value, the larger the stored LoRA neural net weights. For example, with an Alpha of 16 and a Dim of 32, the strength of the weight used is 16/32 = 0.5, meaning that the learning rate is only half as powerful as the Learning Rate setting. If Alpha and Dim are the same number, the strength used will be 1 and will have no effect on the learning rate.
noise_offsetoptFLOAT0.000–1Adds noise to training images. 0 adds no noise at all. A value of 1 adds strong noise.
flip_augmentationoptBOOLEANfalseIf this option is turned on, the image will be horizontally flipped randomly. It can learn left and right angles, which is useful when you want to learn symmetrical people and objects.
shuffle_tokensoptBOOLEANfalseRandomly changes the order of your tags during training. The intent of shuffling is to improve learning. If you are using captions (sentences), this option has no meaning.
keep_tokensoptINT00–10If your training images have tags, you can randomly shuffle them. However, if you have words that you want to keep at the beginning, you can use this option to specify "Keep the first 0 words at the beginning". This option does nothing if the Shuffle Tokens option is off.
trigger_wordoptSTRINGA trigger word that activates the trained LoRA when used in prompts. Only applicable to certain ecosystems (sd1, sdxl, flux1, chroma, zimagebase, zimageturbo, flux2klein).
continue_fromoptCIVITAI_AIROptional previously-trained LoRA to continue training from ("train further"). When set, the first epoch resumes from this model instead of the base model, and the new epochs build on top of it.
resolutionoptINT1024256–1024
no_half_vaeoptBOOLEANfalse
min_snr_gammaoptINT00–20Min-SNR gamma passed through to compatible training backends.
modeloptCIVITAI_AIRThe primary checkpoint to train upon. The model ecosystem drives Comfy training behavior.
diffusion_modeloptCIVITAI_AIRSplit diffusion model used by native Comfy training nodes. When omitted, checkpoint-backed families load Civitai.Orchestration.Grains.Workflows.Steps.Training.Comfy.ComfyTrainingInput.Model.
text_encoder_modeloptCIVITAI_AIRSplit text encoder used by native Comfy training nodes.
vae_modeloptCIVITAI_AIRSplit VAE used by native Comfy training nodes.
training_dtypeoptSTRING
lora_dtypeoptSTRING
quantized_backwardoptBOOLEANfalse
bypass_modeoptBOOLEANfalse
grad_accumulation_stepsoptINT00–2147483647
loss_functionoptSTRING
algorithmoptSTRING
checkpoint_depthoptINT00–2147483647
offloadingoptBOOLEANfalse
clip_typeoptSTRING
unet_weight_dtypeoptSTRING
model_sampling_shiftoptFLOAT0.000–2147483647
dataset_cachingoptBOOLEANfalse
api_configoptCIVITAI_CONFIGOptional Civitai Auth connection; defaults to CIVITAI_API_TOKEN or stored OAuth login.

Outputs (4)

NameTypeDescription
moderation_statusSTRING
epochsSTRING
workflow_idSTRING
raw_jsonSTRING