SDXLLightningModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

SDXL Lightning model for 2-8 step high-quality generation via progressive distillation.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → SDXLLightningModel<T>

For Beginners

SDXL Lightning is ByteDance’s answer to SDXL Turbo. It generates beautiful 1024x1024 images in 2-8 steps (vs SDXL’s 25-50). Unlike Turbo which works best at 1 step, Lightning excels at 2-4 steps with slightly higher quality. It also comes as a LoRA, so you can apply it to existing SDXL fine-tunes.

How It Works

SDXL Lightning combines progressive distillation with adversarial training for high-quality few-step generation. Available as both full UNet checkpoints and LoRA adapters. Achieves superior quality to SDXL Turbo at 2-4 steps while maintaining SDXL-level aesthetics.

Reference: Lin et al., “SDXL-Lightning: Progressive Adversarial Diffusion Distillation”, 2024

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 4 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 4, 128, 128 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new SDXLLightningModel<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
SDXLLightningModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) Initializes a new SDXL Lightning model.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> VAE { get; }
int LatentChannels { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()