LMSDiscreteScheduler<T>

Models & Types · AiDotNet.Diffusion.Schedulers

Linear Multi-Step (LMS) discrete scheduler for diffusion model sampling.

Inheritance: NoiseSchedulerBase<T> → LMSDiscreteScheduler<T>

For Beginners

LMS uses memory of past steps to predict the future better:

Imagine navigating a winding road:

  • Euler: Looks only at the current direction
  • LMS: Remembers the last 4 turns and uses that pattern to predict the road ahead

Key characteristics:

  • Multi-step method using derivative history (order 1-4)
  • Better accuracy than single-step methods at the same cost
  • One model evaluation per step
  • Deterministic: same seed always produces the same result

The method integrates the Lagrange basis of the recent sigmas over each step to get the linear multistep coefficients and applies them to the stored derivative history.

How It Works

The LMS scheduler uses a linear multi-step method to solve the diffusion ODE. It maintains a history of previous derivatives and uses polynomial interpolation to predict the next step more accurately.

Reference: Karras et al., “Elucidating the Design Space of Diffusion-Based Generative Models”, 2022, as implemented by k-diffusion’s sample_lms and diffusers’ LMSDiscreteScheduler (get_lms_coefficient).

Constructors

Constructor Summary
LMSDiscreteScheduler(SchedulerConfig<T> config, int order) Initializes a new instance of the LMS discrete scheduler.

Methods

Method Summary
LMSDiscreteScheduler<T> CreateDefault() Creates an LMS scheduler with default Stable Diffusion settings.
Vector<T> Step(Vector<T> modelOutput, int timestep, Vector<T> sample, T eta, Vector<T> noise) Performs one LMS denoising step using stored derivative history.
void SetTimesteps(int inferenceSteps)