FlashDiffusionModel<T>
Models & Types · AiDotNet.Diffusion.FastGeneration
Flash Diffusion model for rapid few-step generation via progressive attention distillation.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → FlashDiffusionModel<T>
For Beginners
Most distillation methods match the final output of teacher and student. Flash Diffusion goes deeper — it matches the internal “attention patterns” (how the model decides which parts of the prompt affect which parts of the image). This means the fast model better understands complex prompts like “a red car next to a blue house” even in just 4 steps.
How It Works
Flash Diffusion uses progressive attention distillation where the student learns to reproduce the teacher’s attention patterns at progressively fewer steps. This approach preserves the compositional abilities of the original model better than pure output distillation, maintaining text-image alignment at low step counts.
Reference: Chadebec et al., “Flash Diffusion: Accelerating Any Conditional Diffusion Model for Few Steps Image Generation”, 2024
Example
var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 4 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 4, 64, 64 });
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 FlashDiffusionModel<float>(options: options))
.Build(trainX, trainY);
var generated = result.Predict(noise);
Constructors
| Constructor | Summary |
|---|---|
FlashDiffusionModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed) |
Initializes a new Flash Diffusion 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() |