ComfyUI Node

kohya

The entire kohya training UI, moved to the cloud

By civitai·Created 2 months ago·Updated about a month ago· 42
kohya
  • model
  • api_config
  • moderation_status
  • epochs
  • sample_images_prompts
  • sample_input_images
  • stored_as_assets
  • eta
  • workflow_id
  • raw_json
training_data
training_data_images_count0
lora_namemy-lora
sample_prompts_json
negative_prompt
max_train_epochs5
num_repeats8
train_batch_size1
resolution512
enable_buckettrue
shuffle_captionfalse
keep_tokens0
clip_skip1
flip_augmentationfalse
unet_lr0.00
text_encoder_lr0.00
lr_scheduler
lr_scheduler_num_cycles3
min_snr_gamma0
network_dim1
network_alpha1
noise_offset0.00
optimizer_type
target_steps0

If you've ever trained a LoRA with kohya's GUI, you know the feeling of staring at a screen full of fields that each sound like a personal attack: num_repeats, network_alpha, min_snr_gamma, keep_tokens... This node is that entire form, lifted into a ComfyUI node and run on Civitai's servers. Same knobs, same names, same tooltips (the tooltips here are kohya's own words - "Num Repeats defines how many times each individual image gets put into VRAM" - which tells you exactly where this recipe came from). The only difference is you're not renting a GPU to run it; Civitai's farm does, and you pay in Buzz.

The audience is clear: the person who knows exactly what they want from kohya-style SD/SDXL LoRA training but doesn't have the rig or the patience for a local kohya setup. If you've never touched kohya, start with this node's simpler siblings and come back when you need the control.

Inputs and outputs

Required, same as all training nodes: model (CIVITAI_AIR from a Civitai Model Selector), training_data (URL), training_data_images_count. Then the kohya firehose, and the ones that actually matter for a beginner:

  • max_train_epochs (default 5) - the tooltip is genuinely generous: it saves up to 20 epochs, evenly distributed, all downloadable. More epochs = more chances to pick a good checkpoint, more cost.
  • num_repeats (default 8) - how many times each image enters training. This and train_batch_size (default 1) control effective training volume; the tooltip explains the distinction clearly.
  • resolution (default 512) - max training image resolution; images get scaled down to fit.
  • network_dim / network_alpha (both default 1) - the rank/alpha pair the KB's training doc covers in depth: dim is capacity, alpha is how hard you apply it. The tooltip's 16/32 → 0.5 example is the whole concept in one sentence.
  • clip_skip (default 1) - "for anime, use 2. For everything else, 1." Straight from the tooltip, and the fastest way to burn a run is to ignore it.
  • unet_lr / text_encoder_lr (5e-05 each), lr_scheduler, min_snr_gamma, noise_offset, optimizer_type, shuffle_caption, keep_tokens, flip_augmentation, enable_bucket (default true), target_steps - the rest of the kohya surface, and the tooltips are the best documentation you'll get.

Outputs: the training status set - moderation_status, epochs, sample_images_prompts, sample_input_images, stored_as_assets, eta, workflow_id, raw_json.

Install

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

Or ComfyUI Manager → "Civitai Comfy Nodes" → Install → restart. Authenticate; this is the most expensive training node in the pack when you use it fully.

Gotchas

The tooltips are not decoration - they're kohya's actual documentation, and this node's authors kept them because they're the right answer to half the questions you'd ask. The real gotcha is that every one of those knobs multiplies cost, and max_train_epochs at 20 with num_repeats at 8 is a much bigger bill than the defaults suggest. Start at defaults, train one, look at sample_images_prompts, then touch knobs one at a time - same discipline as local kohya, just with a meter running. And remember the data leaves your machine to a URL Civitai can fetch. Early preview, so expect the recipe surface to shift between releases.

CategoryCivitai/Training/kohya

Inputs (26)

NameTypeDefaultDescription
modelCIVITAI_AIRThe primary model to train upon.
training_dataSTRINGA url referring data to use in training.
training_data_images_countINT00–2147483647The number of images embedded in this training data. This is used to calculate the cost of training.
lora_nameoptSTRINGmy-loraThe desired lora name.
sample_prompts_jsonoptSTRINGA selection of sample prompts.
negative_promptoptSTRINGAn optional negative prompt that will get applied when generating samples
max_train_epochsoptINT50–20An epoch is one set of learning. By default, we will save a maximum of 20 epochs (evenly distributed), and they are all available for download.
num_repeatsoptINT81–5000Num Repeats defines how many times each individual image gets put into VRAM. As opposed to batch size, which is how many images are placed into VRAM at once.
train_batch_sizeoptINT11–9Batch size is the number of images that will be placed into VRAM at once. A batch size of 2 will train two images at a time, simultaneously.
resolutionoptINT512512–1024Specify the maximum resolution of training images. If the training images exceed the resolution specified here, they will be scaled down to this resolution
enable_bucketoptBOOLEANtrueSorts images into buckets by size for the purposes of training. If your training images are all the same size, you can turn this option off, but leaving it on has no effect.
shuffle_captionoptBOOLEANfalseRandomly 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–3If 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 Tags option is off.
clip_skipoptINT11–4Determines which layer's vector output will be used. There are 12 layers, and setting the skip will select "xth from the end" of the total layers. For anime, we use 2. For everything else, 1.
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.
unet_lroptFLOAT0.000–1Sets the learning rate for U-Net. This is the learning rate when performing additional learning on each attention block (and other blocks depending on the setting) in U-Net
text_encoder_lroptFLOAT0.000–1Sets the learning rate for the text encoder. The effect of additional training on text encoders affects the entire U-Net.
lr_scheduleroptCOMBOYou can change the learning rate in the middle of learning. A scheduler is a setting for how to change the learning rate.
lr_scheduler_num_cyclesoptINT31–4This option specifies how many cycles the scheduler runs during training. It is only used when "cosine_with_restarts" or "polynomial" is used as the scheduler.
min_snr_gammaoptINT00–20Learning is performed by putting noise of various strengths on the training image, but depending on the difference in strength of the noise on which it is placed, learning will be stable by moving closer to or farther from the learning target. Min SNR gamma was introduced to compensate for that. When learning images have little noise, it may deviate greatly from the target, so try to suppress this jump.
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.
optimizer_typeoptSTRINGThe 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" or "Adafactor" for SDXL.
target_stepsoptINT00–2147483647
api_configoptCIVITAI_CONFIGOptional Civitai Auth connection; defaults to CIVITAI_API_TOKEN or stored OAuth login.

Outputs (8)

NameTypeDescription
moderation_statusSTRING
epochsSTRING
sample_images_promptsSTRING
sample_input_imagesSTRING
stored_as_assetsSTRING
etaSTRING
workflow_idSTRING
raw_jsonSTRING