SDTurboModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

SD Turbo / SDXL Turbo model for real-time single-step image generation.

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

For Beginners

SD Turbo generates images almost instantly:

How SD/SDXL Turbo works:

  1. Uses the same architecture as SD 1.5 / SDXL
  2. Trained with Adversarial Diffusion Distillation (ADD)
  3. A discriminator network enforces realism at each step
  4. Can generate high-quality images in just 1-4 denoising steps

Key characteristics:

  • SD Turbo: 512x512, based on SD 2.1 architecture
  • SDXL Turbo: 512x512, based on SDXL architecture
  • 1-4 steps instead of 20-50 (10-50x faster)
  • No classifier-free guidance needed (guidance scale = 0)
  • Uses ADD (Adversarial Diffusion Distillation) training

Advantages:

  • Near real-time generation (~0.1 seconds)
  • Single-step generation possible
  • Same quality as multi-step at much lower latency

Limitations:

  • Lower diversity than full multi-step models
  • Less control via guidance scale (guidance=0 recommended)
  • Smaller effective resolution than full SDXL
  • Non-commercial license for Turbo models

How It Works

SD Turbo and SDXL Turbo are distilled versions of Stable Diffusion and SDXL that can generate images in 1-4 steps using Adversarial Diffusion Distillation (ADD).

Technical specifications:

  • Architecture: Distilled SD 2.1 / SDXL via Adversarial Diffusion Distillation
  • SD Turbo: SD 2.1 U-Net (865M params), 1024-dim cross-attention
  • SDXL Turbo: SDXL U-Net (2.6B params), dual text encoders
  • Steps: 1-4 (optimal: 1 for speed, 4 for quality)
  • Guidance scale: 0.0 (no CFG needed)
  • Resolution: 512x512 (both variants)
  • Distillation: ADD with adversarial loss + diffusion loss

Reference: Sauer et al., “Adversarial Diffusion Distillation”, 2023

Example

// Create SD Turbo for ultra-fast generation
var turbo = new SDTurboModel<float>();
            
// Generate in just 1 step
var image = turbo.GenerateFromText(
    prompt: "A photo of a cat wearing sunglasses",
    width: 512,
    height: 512,
    numInferenceSteps: 1,
    guidanceScale: 0.0,
    seed: 42);

Constructors

Constructor Summary
SDTurboModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> unet, StandardVAE<T> vae, IConditioningModule<T> conditioner, bool isXLVariant, int? seed) Initializes a new instance of SDTurboModel with full customization support.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> VAE { get; }
bool IsXLVariant { get; } Gets whether this is the SDXL Turbo variant (true) or SD Turbo variant (false).
int LatentChannels { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
Tensor<T> GenerateFromText(string prompt, string negativePrompt, int width, int height, int numInferenceSteps, double? guidanceScale, int? seed)
Tensor<T> ImageToImage(Tensor<T> inputImage, string prompt, string negativePrompt, double strength, int numInferenceSteps, double? guidanceScale, int? seed)

Fields

Field Summary
int DefaultHeight Default image height for SD Turbo generation.
int DefaultWidth Default image width for SD Turbo generation.