Skip to main content

What is LoRA?

LoRA (Low-Rank Adaptation) is a parameter-efficient fine-tuning technique that trains small adapter layers instead of the entire model. This makes training:
  • Faster: Train in minutes instead of hours
  • Cheaper: Use 80% less VRAM
  • Portable: LoRA files are 50-200MB vs 5-10GB for full models
  • Flexible: Easily switch between different LoRAs on the same base model

Basic Training

Simple Example

Train a LoRA with default settings:
That’s it! HyperGen handles everything automatically.

Training Parameters

Core Parameters

Dataset
required
Dataset to train on (from dataset.load())
int
default:1000
Number of training steps to run. More steps = better learning, but longer training.
  • Quick test: 100-500 steps
  • Normal training: 1000-2000 steps
  • High quality: 2000-5000 steps
float | 'auto'
default:0.0001
Learning rate for optimizer. Controls how quickly the model learns.
  • Default: 1e-4 (0.0001) works well for most cases
  • Higher (1e-3): Faster learning, risk of instability
  • Lower (1e-5): Slower but more stable
  • Auto: Let HyperGen choose (coming in Phase 2)

LoRA Configuration

int
default:16
LoRA rank - controls the number of parameters in the adapter.
  • Lower (4-8): Fewer parameters, faster training, smaller files
  • Medium (16-32): Good balance (recommended)
  • Higher (64-128): More capacity, larger files
Higher rank = more capacity to learn, but diminishing returns after 32-64.
int
default:32
LoRA alpha scaling parameter. Usually set to 2x the rank.
  • Affects the strength of the LoRA adapter
  • Common formula: alpha = 2 * rank
  • Higher alpha = stronger LoRA effect

Training Configuration

int | 'auto'
default:1
Number of images to process at once.
  • 1: Safest, works on 8GB VRAM
  • 2-4: Better training, needs 12-16GB VRAM
  • ‘auto’: Let HyperGen optimize (coming in Phase 2)
Larger batch size can improve training quality but uses more VRAM.
int
default:1
Accumulate gradients over multiple steps before updating.Effective batch size = batch_size * gradient_accumulation_stepsUse this to simulate larger batches without using more VRAM:
  • batch_size=1, gradient_accumulation_steps=4 H batch_size=4
int | None
Save a checkpoint every N steps.
  • None: Only save at the end
  • 500: Save every 500 steps
  • Useful for long training runs to avoid losing progress
str | None
Directory to save checkpoints and final LoRA weights.
  • None: Don’t save to disk (weights returned in memory only)
  • ”./checkpoints”: Save to this directory

Advanced Examples

Custom LoRA Configuration

Memory-Constrained Training

For GPUs with limited VRAM (8-12GB):

High-Quality Training

For best results with plenty of VRAM (24GB+):

Using the LoRATrainer Directly

For more control, use the LoRATrainer class:

Different Model Types

HyperGen’s API is the same for all models:

SDXL Training

FLUX.1 Training

Stable Diffusion 1.5 Training

Stable Diffusion 3 Training

Saving and Loading LoRAs

Saving During Training

This creates:

Loading LoRAs for Inference

LoRA loading for inference is coming in Phase 2. For now, LoRAs are saved but not yet loaded for generation.
Future API (coming soon):

Training Recommendations

Hyperparameter Guidelines

Goal: Learn an artistic style or aesthetic
  • Dataset: 50-200 images
  • Captions: Describe content, not style

VRAM Requirements

8GB VRAM

Models: SD 1.5, SDXL (with optimizations)

12GB VRAM

Models: SDXL, SD3

16GB VRAM

Models: SDXL, SD3, FLUX.1

24GB+ VRAM

Models: All models including FLUX.1

Troubleshooting

Out of Memory Errors

If you encounter CUDA out of memory errors:
  1. Reduce batch size:
  2. Lower LoRA rank:
  3. Use gradient accumulation:
  4. Use lower precision:

Training Too Slow

If training is taking too long:
  1. Reduce steps:
  2. Increase batch size (if you have VRAM):
  3. Enable optimizations (coming in Phase 2)

Poor Quality Results

If the trained LoRA doesn’t work well:
  1. Increase training steps:
  2. Increase LoRA rank:
  3. Improve dataset:
    • Add more images
    • Add captions
    • Increase image quality
    • Add more variety
  4. Adjust learning rate:

Current Limitations

HyperGen is in pre-alpha. The training loop is not fully implemented yet.
What Works:
  • Model loading and configuration
  • Dataset loading
  • LoRA setup with PEFT
  • Checkpoint saving structure
In Development:
  • Complete training loop with loss calculation
  • Noise scheduling
  • Validation and metrics
Coming in Phase 2:
  • Gradient checkpointing
  • Mixed precision training
  • Flash Attention
  • Auto-configuration
  • LoRA loading for inference

Next Steps

Datasets

Learn how to prepare training data

Training Overview

Understand the training architecture

Serving

Deploy trained models with the API

Examples

View complete training examples