Skip to content

Configuration

The Duskfall Portal Crew edited this page Jun 12, 2026 · 1 revision

Configuration

The training system uses two auto-generated TOML files and a preset system for sharing configurations.


Overview

Training configurations flow through three layers:

  1. Frontend form (web UI) → user fills in parameters across multiple tabs
  2. Pydantic validation (backend) → TrainingConfig model validates all fields
  3. TOML generation (service layer) → kohya_toml.py generates two files consumed by Kohya SS

TOML Configuration Files

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.


Configuration Parameters

The TrainingConfig Pydantic model contains ~140 fields organized into categories:

Model Settings

  • pretrained_model_name_or_path — HuggingFace path or local .safetensors path
  • model_type — SDXL, SD1.5, Flux, SD3, Lumina, Anima, HunyuanImage
  • vae_path / vae — optional VAE override

Dataset Settings

  • 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

Training Settings

  • 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

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.

Scheduler

  • Constant, Linear, Cosine, Cosine with Restarts, Polynomial
  • Rex and CosineAnnealing are vendored but not yet exposed in the UI

LoRA / Network Settings

  • network_modulelora, 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 by min_snr_gamma_enabled

Advanced

  • gradient_accumulation_steps, lr_scheduler_num_cycles
  • optimizer_args — extra kwargs for custom optimizers
  • weight_decay — auto-injected into optimizer_args for custom optimizers
  • clip_skip / keep_tokens — token retention

Preset System

Presets provide reusable training configurations stored in presets/ as JSON files.

Format

{
  "name": "Preset Name",
  "description": "What this preset is optimized for",
  "model_type": "SDXL",
  "config": {
    "optimizer": "AdamW8bit",
    "lr": 1e-4,
    "train_batch_size": 2
  }
}

Usage

  • 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.


Best Practices

  1. Start from a preset matching your model type and optimizer
  2. Use bf16 instead of fp16 for CAME and similar optimizers (prevents NaN)
  3. Set save_every_n_epochs=1 during initial testing to verify training works
  4. Enable gradient checkpointing if VRAM-limited
  5. Match resolution to your base model (1024 for SDXL, 512 for SD1.5)

See Also

Clone this wiki locally