Init Flux LoRA Training
The node that actually runs a Flux LoRA train inside ComfyUI
- flux_models
- dataset
- optimizer_settings
- resume_args
- block_args
- loss_args
- network_config
- network_trainer
- epochs_count
- args
This is the heart of the whole pack. If you want to train a Flux LoRA without ever leaving ComfyUI - no Kohya GUI, no ai-toolkit config file, no second Python environment - InitFluxLoRATraining is the node that sets the run up. Everything else in ComfyUI-FluxTrainer feeds into it or runs after it.
Under the hood, kijai is wrapping a slightly modified version of kohya-ss/sd-scripts, the same training code that powers the Kohya GUI. So the parameter names here are Kohya's parameter names - network_dim, network_alpha, learning_rate - which means any Flux LoRA guide written for Kohya translates almost directly. The pitch for doing it in Comfy at all is honest and small: you reuse the exact models you already inference with, you stay in one Python env, and you can wire up graphs to A/B settings. That's it. It won't be faster than ai-toolkit, and kijai himself says in the README that he has "very little previous experience in training anything" and that the default settings "aren't necessarily any good." Treat this as a capable Kohya front-end, not a magic beginner button.
How it fits together
Init doesn't train on its own - it initializes. You hand it three things it can't run without: flux_models (from a FluxTrainModelSelect node), a dataset JSON that points at your images and captions, and optimizer_settings (from one of the OptimizerConfig nodes). It builds a live trainer object and spits out network_trainer (type NETWORKTRAINER), which you then pipe into a FluxTrainLoop node to actually grind steps. It also outputs epochs_count so you know how many epochs your step count works out to, and args (the raw Kohya arguments) for debugging.
The inputs that actually matter
Most of the two-dozen knobs here you can leave alone on a first run. The ones a beginner should set:
network_dim(default 4) andnetwork_alpha(default 1) - rank and its scaling. Kijai's defaults are unusually low; for a Flux character LoRA most people run something closer to rank 16. Bigger dim = more capacity and a bigger file.learning_rate(default 0.0004) - this default of 4e-4 is the well-worn Flux.1 starting point, so it's a sane place to begin.max_train_steps(default 1500) - the Flux sweet spot for a 15-25 image dataset is roughly 1,500-3,000 steps. Save intermediate checkpoints, because the final step is often not the best one.blocks_to_swap- the VRAM lever. This is Kohya's block-swapping trick: it offloads transformer blocks to system RAM so a Flux LoRA fits in 12-16GB. Raise it if you OOM, leave it at 0 if you've got the headroom.fp8_base(default true) - keeps the base model in fp8 to save memory. Standard for consumer cards.
There's also an optional network_config input: plug a TrainNetworkConfig node in there to train a LyCORIS/LoKr instead of a plain LoRA, which is what most people now reach for on Flux-class models.
Installing the pack
ComfyUI Manager is easiest - search ComfyUI Flux Trainer, install, restart. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-FluxTrainer
pip install -r ComfyUI-FluxTrainer/requirements.txt
Torch 2.4.0 or newer is strongly recommended. The example workflows also use nodes from kijai's ComfyUI-KJNodes (and optional debug nodes from rgthree-comfy), so grab those too. For the models: use the normal fp8 or fp16 Flux files, and make sure your VAE is the non-diffusers ae.safetensors - the diffusers-format VAE will not work.
Common issues
Dataset errors on the first run. The number-one beginner trip is the dataset. If you get Expecting value: line 1 column 1 (char 0), your dataset JSON is malformed or empty - build it with the pack's dataset node rather than typing JSON by hand. On Windows portable installs people have also had to move their dataset folder inside the ComfyUI directory for the paths to resolve. Get 20 well-captioned images sitting in the right place before you touch any of the training knobs.
It's experimental, and it changes. Kijai's README says this outright: both his nodes and Kohya's underlying Flux code are work-in-progress. If a workflow breaks after an update, that's the deal you signed up for. Keep the pack current and expect the occasional churn.
Inputs (37)
| Name | Type | Default | Description |
|---|---|---|---|
| flux_models | TRAIN_FLUX_MODELS | — | |
| dataset | JSON | — | |
| optimizer_settings | ARGS | — | |
| output_name | STRING | flux_lora | — |
| output_dir | STRING | flux_trainer_output | path to dataset, root is the 'ComfyUI' folder, with windows portable 'ComfyUI_windows_portable' |
| network_dim | INT | 41–100000 | network dim |
| network_alpha | FLOAT | 1.000–2048 | network alpha |
| learning_rate | FLOAT | 0.00040–10 | learning rate |
| max_train_steps | INT | 15001–100000 | max number of training steps |
| apply_t5_attn_mask | BOOLEAN | true | apply t5 attention mask |
| cache_latents | COMBO | caches text encoder outputs | |
| cache_text_encoder_outputs | COMBO | caches text encoder outputs | |
| blocks_to_swap | INT | 0 | Previously known as split_mode, number of blocks to swap to save memory, default to enable is 18 |
| weighting_scheme | COMBO | 5 options: logit_normal, sigma_sqrt, mode, cosmap, none | |
| logit_mean | FLOAT | 0.000–1 | mean to use when using the logit_normal weighting scheme |
| logit_std | FLOAT | 1.000–1 | std to use when using the logit_normal weighting scheme |
| mode_scale | FLOAT | 1.290–10 | Scale of mode weighting scheme. Only effective when using the mode as the weighting_scheme |
| timestep_sampling | COMBO | Method to sample timesteps: sigma-based, uniform random, sigmoid of random normal and shift of sigmoid (recommend value of 3.1582 for discrete_flow_shift) | |
| sigmoid_scale | FLOAT | 1.00–10 | Scale factor for sigmoid timestep sampling (only used when timestep-sampling is sigmoid |
| model_prediction_type | COMBO | How to interpret and process the model prediction: raw (use as is), additive (add to noisy input), sigma_scaled (apply sigma scaling). | |
| guidance_scale | FLOAT | 1.001–32 | guidance scale, for Flux training should be 1.0 |
| discrete_flow_shift | FLOAT | 1.00000–10 | for the Euler Discrete Scheduler, default is 3.0 |
| highvram | BOOLEAN | false | memory mode |
| fp8_base | BOOLEAN | true | use fp8 for base model |
| gradient_dtype | COMBO | fp32 | the actual dtype training uses |
| save_dtype | COMBO | bf16 | the dtype to save checkpoints as |
| attention_mode | COMBO | sdpa | memory efficient attention mode |
| sample_prompts | STRING | illustration of a kitten | photograph of a turtle | validation sample prompts, for multiple prompts, separate by `|` |
| additional_argsopt | STRING | additional args to pass to the training command | |
| resume_argsopt | ARGS | resume args to pass to the training command | |
| train_text_encoderopt | COMBO | disabled | also train the selected text encoders using specified dtype, T5 can not be trained without clip_l |
| clip_l_lropt | FLOAT | 0.00000–10 | text encoder learning rate |
| T5_lropt | FLOAT | 0.00000–10 | text encoder learning rate |
| block_argsopt | ARGS | limit the blocks used in the LoRA | |
| gradient_checkpointingopt | COMBO | enabled | use gradient checkpointing |
| 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 | — |