Skip to content

dew.diffusion.presets

Named conventions, as the dataclasses a run’s run.json stores.

A preset is a frozen dataclass of the numbers that define a convention, and calling it builds the Process. Both training and inference build from the same preset, so a model is always sampled with the convention it was trained with. A record that holds the preset’s fields rebuilds it exactly.

NameSummary
PresetEvery member of the presets registry is a frozen dataclass of a convention’s numbers, callable to the Process it describes.
EDMKarras et al.
KarrasThe EDM preconditioning trained on sigmas drawn uniformly along the rho-spaced grid it samples on.
CosineThe cosine beta table with v-prediction.
FlowRectified flow on the linear path, velocity prediction, logit-normal times, with SD3’s resolution shift.
SqrtDiffusion-LM (Li et al.

class source

class Preset(Protocol)

Every member of the presets registry is a frozen dataclass of a convention’s numbers, callable to the Process it describes.

dataclass source

class EDM(
sigma_min: float = 0.002,
sigma_max: float = 80.0,
rho: float = 7.0,
sigma_data: float = 0.5,
P_mean: float = -0.4,
P_std: float = 1.0,
min_snr_gamma: float | None = None,
)

Karras et al. 2022: log-normal training sigmas, the EDM preconditioning and lambda weighting, sampled on the rho-spaced Karras grid.

dataclass source

class Karras(
sigma_min: float = 0.002,
sigma_max: float = 80.0,
rho: float = 7.0,
sigma_data: float = 0.5,
min_snr_gamma: float | None = None,
)

The EDM preconditioning trained on sigmas drawn uniformly along the rho-spaced grid it samples on.

dataclass source

class Cosine(
timesteps: int = 1000,
beta_end: float = 1.0,
p2_loss_weight_k: float = 1.0,
p2_loss_weight_gamma: float = 1.0,
min_snr_gamma: float | None = None,
)

The cosine beta table with v-prediction.

The table’s P2 weight at its defaults (k = 1, gamma = 1) is 1 / (1 + SNR), which makes the v loss an unweighted x_0 loss. p2_loss_weight_gamma changes that.

dataclass source

class Flow(
shift: float = 1.0,
logit_mean: float = 0.0,
logit_std: float = 1.0,
min_snr_gamma: float | None = None,
)

Rectified flow on the linear path, velocity prediction, logit-normal times, with SD3’s resolution shift.

dataclass source

class Sqrt(min_snr_gamma: float | None = None)

Diffusion-LM (Li et al. 2022): the square-root schedule with the plain x_0 loss.