PCMModel<T>

Models & Types · AiDotNet.Diffusion.FastGeneration

Phased Consistency Model (PCM) for flexible-step generation with phase-based training.

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

For Beginners

Standard consistency models work great at 1-2 steps but lose quality at higher steps. PCM fixes this by dividing the generation process into phases and handling each phase separately. This means you get good results from 1 to 16 steps, giving you maximum flexibility in the speed/quality tradeoff.

How It Works

PCM divides the diffusion trajectory into phases and enforces consistency within each phase rather than across the entire trajectory. This phased approach allows the model to maintain high quality across different step configurations (1, 2, 4, 8, 16 steps) without the quality degradation seen in standard consistency models at higher steps.

Reference: Wang et al., “Phased Consistency Model”, NeurIPS 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 PCMModel<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
PCMModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, bool isXLVariant, int? seed) Initializes a new Phased Consistency 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()