Init SDXL LoRA Training
Train an SDXL or Illustrious LoRA without leaving ComfyUI
- SDXL_models
- dataset
- optimizer_settings
- resume_args
- block_args
- loss_args
- network_config
- network_trainer
- epochs_count
- args
Despite living in a pack called Flux Trainer, this node trains SDXL LoRAs - and by extension anything on the SDXL lineage, including Illustrious and Pony checkpoints. If you already inference SDXL in ComfyUI and want to train a character or style LoRA on the same machine, in the same environment, without setting up Kohya's GUI, this is the node that runs the show.
It's a wrapper around kohya-ss/sd-scripts, so the settings are the settled, decade-of-guides SDXL vocabulary. That's actually the strong case for training SDXL here: SDXL recipes are done. The rank/alpha tables and learning rates stopped moving years ago, and this node's defaults reflect them, unlike the more experimental Flux side of the pack.
How it works
InitSDXLLoRATraining takes your models, your dataset, and an optimizer config, and builds a trainer object you then step through with a FluxTrainLoop node (yes, the loop node is shared across model types). The three inputs it can't run without: SDXL_models (from an SDXLModelSelect node), dataset (a JSON describing your image folder and captions), and optimizer_settings (from an OptimizerConfig node). Out comes network_trainer (NETWORKTRAINER) that drives the loop, plus epochs_count and the raw args.
The inputs that matter
The good news is the defaults here are genuinely usable for SDXL:
network_dim(default 16) andnetwork_alpha(default 16) - 16/16 is a solid, community-backed starting point for an SDXL person LoRA. If you want the classic alpha-at-half-rank behavior, drop alpha to 8. For styles, people often go lower on dim.learning_rate(default 1e-6) - note this is deliberately conservative. SDXL commonly trains anywhere from 1e-5 to 1e-4; you'll likely want to raise this, especially with a plain constant scheduler.max_train_steps(default 1500) - the old SDXL rule of thumb is 100-200 steps per image, so scale this to your dataset size.train_text_encoder(disabledorclip_l) - SDXL is one of the last architectures where training the text encoder still helps. Flip it toclip_land setclip_l_lr/clip_g_lrif you want it; leave it off for a faster, safer run.blocks_to_swapandfp8_base- the VRAM levers. SDXL LoRA fits comfortably in 12GB at rank 32, so you often won't need either, but they're there for tight cards.
Installing the pack
Through ComfyUI Manager, search ComfyUI Flux Trainer, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-FluxTrainer
pip install -r ComfyUI-FluxTrainer/requirements.txt
Torch 2.4.0+ recommended, and the example workflows lean on kijai's ComfyUI-KJNodes, so install that too. For SDXL you just point SDXLModelSelect at a normal SDXL checkpoint - no separate VAE juggling like the Flux side needs.
Common issues
Your dataset isn't set up right. This is the most common wall people hit with the whole pack. Captions live in .txt files next to your images, the folder path has to resolve (Windows portable users sometimes have to keep the dataset folder inside the ComfyUI directory), and a bad or empty dataset JSON throws a cryptic parse error rather than a friendly message. Sort the dataset before touching training knobs.
Anime bases want tag captions, not sentences. If you're training on Illustrious, Pony, or NoobAI, caption with WD14-style Danbooru tags - comma-separated tags matching how those models were trained - not natural-language descriptions. Natural language is for Flux-class models.
The default learning rate looks tiny. It is. Don't assume the shipped 1e-6 is optimal; kijai's own README warns the defaults "aren't necessarily any good." Start from a known SDXL recipe and use the pack's validation nodes to sanity-check before committing to a long run.
Inputs (28)
| Name | Type | Default | Description |
|---|---|---|---|
| SDXL_models | TRAIN_SDXL_MODELS | — | |
| dataset | JSON | — | |
| optimizer_settings | ARGS | — | |
| output_name | STRING | SDXL_lora | — |
| output_dir | STRING | SDXL_trainer_output | path to dataset, root is the 'ComfyUI' folder, with windows portable 'ComfyUI_windows_portable' |
| network_dim | INT | 161–100000 | network dim |
| network_alpha | FLOAT | 16.000–2048 | network alpha |
| learning_rate | FLOAT | 00–10 | learning rate |
| max_train_steps | INT | 15001–100000 | max number of training steps |
| cache_latents | COMBO | caches text encoder outputs | |
| cache_text_encoder_outputs | COMBO | caches text encoder outputs | |
| highvram | BOOLEAN | false | memory mode |
| blocks_to_swap | INT | 00–100 | option for memory use reduction. The maximum number of blocks that can be swapped is 36 for SDXL.5L and 22 for SDXL.5M |
| fp8_base | BOOLEAN | false | use fp8 for base model |
| gradient_dtype | COMBO | fp32 | the actual dtype training uses |
| save_dtype | COMBO | fp16 | the dtype to save checkpoints as |
| attention_mode | COMBO | sdpa | memory efficient attention mode |
| train_text_encoder | COMBO | disabled | also train the selected text encoders using specified dtype, T5 can not be trained without clip_l |
| clip_l_lr | FLOAT | 0.00000–10 | text encoder learning rate |
| clip_g_lr | FLOAT | 0.00000–10 | text encoder learning rate |
| sample_prompts_pos | STRING | illustration of a kitten | photograph of a turtle | validation sample prompts, for multiple prompts, separate by `|` |
| sample_prompts_neg | STRING | validation sample prompts, for multiple prompts, separate by `|` | |
| gradient_checkpointing | COMBO | enabled | use gradient checkpointing |
| additional_argsopt | STRING | additional args to pass to the training command | |
| resume_argsopt | ARGS | resume args to pass to the training command | |
| block_argsopt | ARGS | limit the blocks used in the LoRA | |
| loss_argsopt | ARGS | loss args | |
| network_configopt | NETWORK_CONFIG | additional network config |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| network_trainer | NETWORKTRAINER | — |
| epochs_count | INT | — |
| args | KOHYA_ARGS | — |