UniPCScheduler<T>
Models & Types · AiDotNet.Diffusion.Schedulers
UniPC (Unified Predictor-Corrector) scheduler for fast, high-quality diffusion sampling.
Inheritance: NoiseSchedulerBase<T> → UniPCScheduler<T>
For Beginners
UniPC is like a “guess and check” approach to denoising.
Most schedulers just predict the next step (predict only):
- Step 1: Predict the cleaner image → use as-is
UniPC adds a correction step for better accuracy:
- Step 1: Predict the cleaner image (predictor step)
- Step 2: Check how good the prediction was and improve it (corrector step)
This two-phase approach means:
- Better quality at the same number of steps (e.g., 10-step UniPC ≈ 15-step DDIM)
- Or same quality with fewer steps (faster generation)
Key characteristics:
- Combines predictor-corrector methodology with multi-step methods
- Supports orders 1-3 (higher = more accurate per step)
- Deterministic by default
- Particularly effective at very low step counts (5-15 steps)
Used by:
- ComfyUI, A1111, and many Stable Diffusion UIs as an alternative scheduler
- Effective with SD 1.5, SDXL, and other diffusion models
How It Works
UniPC combines predictor and corrector steps into a unified framework, achieving superior sampling quality with fewer function evaluations compared to pure predictor methods like DDIM or DPM-Solver++.
Reference: Zhao et al., “UniPC: A Unified Predictor-Corrector Framework for Fast Sampling of Diffusion Models”, NeurIPS 2023
Constructors
| Constructor | Summary |
|---|---|
UniPCScheduler(SchedulerConfig<T> config, int solverOrder, bool useCorrectorStep) |
Initializes a new instance of the UniPC scheduler. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, object> GetState() |
|
Vector<T> Step(Vector<T> modelOutput, int timestep, Vector<T> sample, T eta, Vector<T> noise) |
Performs one UniPC step: the UniC corrector refines the previous predictor output with the new model evaluation, then the UniP predictor advances to the next timestep. |
void LoadState(Dictionary<string, object> state) |
|
void SetTimesteps(int inferenceSteps) |
Sets up the inference timesteps and computes lambda/sigma/alpha schedules. |