-
-
Notifications
You must be signed in to change notification settings - Fork 2
Configuration
The training system uses two auto-generated TOML files and a preset system for sharing configurations.
Training configurations flow through three layers:
- Frontend form (web UI) → user fills in parameters across multiple tabs
-
Pydantic validation (backend) →
TrainingConfigmodel validates all fields -
TOML generation (service layer) →
kohya_toml.pygenerates two files consumed by Kohya SS
The backend API generates two TOML files in trainer/runtime_store/:
| File | Purpose |
|---|---|
dataset.toml |
Dataset paths, resolution, batch size, bucketing |
config.toml |
Training hyperparameters (optimizer, scheduler, learning rate, etc.) |
These are consumed directly by the Kohya SS training scripts. Do not modify the TOML generation logic in services/trainers/kohya_toml.py without checking git history — mistakes here affect real training runs.
The TrainingConfig Pydantic model contains ~140 fields organized into categories:
-
pretrained_model_name_or_path— HuggingFace path or local.safetensorspath -
model_type— SDXL, SD1.5, Flux, SD3, Lumina, Anima, HunyuanImage -
vae_path/vae— optional VAE override
-
train_data_dir— path to training images -
resolution— target resolution (e.g. 1024 for SDXL) -
num_repeats— how many times to repeat the dataset per epoch -
enable_bucket— automatic aspect ratio bucketing -
max_token_length— 225 (default), 450, or 900
-
max_train_epochs— total training epochs -
max_train_steps— alternative to epochs (overrides epochs if set) -
save_every_n_epochs/save_every_n_steps -
train_batch_size— images per batch -
gradient_checkpointing— reduces VRAM at the cost of speed -
noise_offset/multires_noise_iterations— regularization
| Optimizer | Description |
|---|---|
| AdamW8bit | Default — stable, widely tested |
| CAME | Memory-efficient, uses weight decomposition |
| Prodigy | Adaptive learning rate |
| AdaFactor | Low-memory factorized optimizer |
| Lion8bit | Fast convergence |
| Compass | Composite optimizer |
| LPFAdamW | Low-pass filtered AdamW |
| RMSProp | Classic RMSProp |
Selectable from the UI dropdown. Some optimizers (Compass, LPFAdamW, RMSProp) are wired but not yet exposed in the UI dropdown.
- Constant, Linear, Cosine, Cosine with Restarts, Polynomial
- Rex and CosineAnnealing are vendored but not yet exposed in the UI
-
network_module—lora,locon,loha,lokr -
rank/alpha— LoRA rank and alpha -
network_train_unet_only/network_train_text_encoder_only -
no_token_padding— recommended disabled for models with short caption conventions -
min_snr_gamma— SNR weighting, gated bymin_snr_gamma_enabled
-
gradient_accumulation_steps,lr_scheduler_num_cycles -
optimizer_args— extra kwargs for custom optimizers -
weight_decay— auto-injected intooptimizer_argsfor custom optimizers -
clip_skip/keep_tokens— token retention
Presets provide reusable training configurations stored in presets/ as JSON files.
{
"name": "Preset Name",
"description": "What this preset is optimized for",
"model_type": "SDXL",
"config": {
"optimizer": "AdamW8bit",
"lr": 1e-4,
"train_batch_size": 2
}
}- Built-in presets — shipped with the application, read-only
-
User presets — created by users, stored in
presets/ - Import/Export — share preset files between setups
The preset list includes templates for SDXL, Illustrious, Pony, Anima, and more.
- Start from a preset matching your model type and optimizer
-
Use
bf16instead offp16for CAME and similar optimizers (prevents NaN) -
Set
save_every_n_epochs=1during initial testing to verify training works - Enable gradient checkpointing if VRAM-limited
- Match resolution to your base model (1024 for SDXL, 512 for SD1.5)
- Training-Guide — end-to-end training workflow
- Upstream-Reference — detailed parameter documentation from Kohya SS