What is LoRA?
LoRA (Low-Rank Adaptation) is a technique for fine-tuning large neural networks without retraining all of their weights. Instead of updating every parameter in the model, LoRA inserts small trainable adapter matrices into the network’s layers. The original model weights stay frozen; only the adapter weights change. In practice this means you can teach a Stable Diffusion model to generate a specific character, art style, or concept by training on a few hundred images and a modest GPU, then distribute the result as a file that is a few megabytes instead of several gigabytes.How it works
A LoRA adapter decomposes a weight updateΔW into two low-rank matrices:
A has shape [in_features, rank] and B has shape [rank, out_features]. The rank (also called the dimension, controlled by --network_dim) determines how expressive the adapter is. A rank of 16 is a common starting point; higher ranks capture more detail at the cost of a larger file and higher overfitting risk.
Benefits of LoRA over full fine-tuning
| Property | LoRA | Full fine-tuning |
|---|---|---|
| VRAM required | Low (8–16 GB for SD 1.x) | Very high (40+ GB) |
| Training time | Minutes to hours | Hours to days |
| Output file size | 2–200 MB | 2–7 GB |
| Overfitting risk | Lower | Higher |
| Stackable | Yes — multiple LoRAs can be combined | No |
| Base model untouched | Yes | No |
LoRA types in sd-scripts
The repository uses two named LoRA variants:- LoRA-LierLa — applies LoRA to Linear layers and Conv2d layers with a 1×1 kernel. This is the default when you use
--network_module=networks.lora. - LoRA-C3Lier — extends LoRA-LierLa to also cover Conv2d layers with a 3×3 kernel. Enable it by passing
conv_dimin--network_args.
Model-specific training scripts
Each model architecture requires a dedicated script. Choose the page that matches your base model:SD 1.x / 2.x
Train LoRA with
train_network.py for Stable Diffusion v1 and v2 models.SDXL
Train LoRA with
sdxl_train_network.py for Stable Diffusion XL.FLUX.1
Train LoRA with
flux_train_network.py for FLUX.1 dev and schnell.SD3 / SD3.5
Train LoRA with
sd3_train_network.py for Stable Diffusion 3 and 3.5.Common workflow
Prepare your dataset
Collect training images and write captions. Organize them into a folder and create a TOML dataset config file that points to that folder, sets the resolution, and configures repetition count and bucketing options.
Configure your training command
Choose the script for your model architecture and set the required arguments — at minimum the base model path, dataset config, output directory, network module, rank, and alpha.
Run training
Launch training through
accelerate launch. Monitor the loss in the console or with TensorBoard.Key parameters at a glance
| Parameter | What it controls | Typical range |
|---|---|---|
--network_dim | LoRA rank — expressiveness vs. file size | 4 – 128 |
--network_alpha | Scaling factor for the LoRA output | 1 – same as dim |
--learning_rate | How fast the adapter learns | 1e-4 – 1e-3 |
--max_train_epochs | Total training epochs | 5 – 20 |
--mixed_precision | Numeric format for training | fp16 or bf16 |
