dew.diffusion.schedules.source_grids
The schedules that sampling on a published diffusion checkpoint’s grid uses.
source_policy resolves a scheduler file’s controls once. sampling_grid
uses those controls to build the numerical tables and Process that
SourceSchedule caches. Each table is an ordinary Dew schedule, so a solver
reads its rates, model time and prior the same way as any other’s.
There are four kinds: the training beta table indexed by t (TabulatedVP);
a paired sigma and model-time table, in variance-exploding (SigmaGrid) or
normalized-VP (VPGrid) coordinates; the variance-exploding table with the
stage rows a two-evaluation solver reads (StageSigmaGrid); and a
rectified-flow table whose signal and noise sum to one (FlowGrid). A
paired table is read at a coordinate t that counts down from
T = len(sigmas) - 1, so a non-integer t interpolates between two prepared
rows.
| Name | Summary |
|---|---|
FlowGrid | A rectified-flow grid, where alpha is 1 - sigma. |
SigmaGrid | A variance-exploding schedule on a prepared grid of paired sigmas and model times. |
StageSigmaGrid | A source’s variance-exploding grid that includes the stage rows of a two-evaluation solver. |
TabulatedVP | The training beta table used as the sampling schedule, indexed by t. |
VPGrid | A paired sigma and model-time grid in normalized VP coordinates. |
published_betas | Return a scheduler class’s beta table, rescaled for zero terminal SNR when zero_snr is set. |
FlowGrid
Section titled “FlowGrid”class FlowGrid(_UniformGrid, RectifiedFlow)A rectified-flow grid, where alpha is 1 - sigma.
The source’s forward process is x_t = (1 - sigma) x_0 + sigma eps, so
signal and noise sum to one; in a normalized VP pair, their squares do.
Model times are the sigmas times the training step count, which is where
the source’s timesteps come from. The prior at sigma 1 is the unit
Gaussian. Training draws times uniformly with a constant loss weight.
FlowGrid.rates
Section titled “FlowGrid.rates”def rates(t)SigmaGrid
Section titled “SigmaGrid”class SigmaGrid(sigmas: np.ndarray, model_times: np.ndarray, prior: float)A variance-exploding schedule on a prepared grid of paired sigmas and model times.
sigma_min and sigma_max are the grid’s smallest positive sigma and
its largest sigma, which is the domain a source’s noise sampler is built
over.
StageSigmaGrid
Section titled “StageSigmaGrid”class StageSigmaGrid(sigmas: np.ndarray, model_times: np.ndarray, prior: float)A source’s variance-exploding grid that includes the stage rows of a two-evaluation solver.
Even coordinates are the grid points the outer loop visits. The odd
coordinate between each pair is the source’s own interpolated
evaluation, at the sigma the source places there and the model time it
computes for that sigma. t_of_sigma maps a sigma to a stage
coordinate. That is the only inversion these solvers need from a
schedule, because KDPM2’s midpoint and DPMSolverSDE’s proposal both land
on a stage row.
StageSigmaGrid.t_of_sigma
Section titled “StageSigmaGrid.t_of_sigma”def t_of_sigma(sigma)TabulatedVP
Section titled “TabulatedVP”class TabulatedVP(betas: np.ndarray, *, final_alpha_cumprod: float, stride: int | None)The training beta table used as the sampling schedule, indexed by t.
stride is the fixed training transfer that DDIM and PNDM step over,
whatever their evaluation grid is. None keeps the grid’s own interval,
which DDPM’s previous-timestep policy and the distilled schedules use. A
t below zero is the source’s “no previous alpha” end, where the rates
come from final_alpha_cumprod.
TabulatedVP.rates
Section titled “TabulatedVP.rates”def rates(t)TabulatedVP.variances
Section titled “TabulatedVP.variances”def variances(t)TabulatedVP.model_time
Section titled “TabulatedVP.model_time”def model_time(t)TabulatedVP.step_interval
Section titled “TabulatedVP.step_interval”def step_interval(t, t_next)Return the published DDIM and PNDM transfer stride, independent of the evaluation spacing.
Without a stride, this is the grid’s own interval.
TabulatedVP.half_interval
Section titled “TabulatedVP.half_interval”def half_interval(t, t_next)Return half the integer transfer stride, rounded down, as published PRK uses it.
VPGrid
Section titled “VPGrid”class VPGrid(_UniformGrid)A paired sigma and model-time grid in normalized VP coordinates.
A grid sigma gives alpha = 1 / sqrt(1 + sigma^2) and a noise rate of sigma alpha. Training draws times uniformly with a constant loss weight.
VPGrid.rates
Section titled “VPGrid.rates”def rates(t)published_betas
Section titled “published_betas”def published_betas( *, count: JSON, start: JSON, end: JSON, schedule: JSON, trained: JSON | np.ndarray, zero_snr: bool, schedules: tuple[str, ...],) -> np.ndarrayReturn a scheduler class’s beta table, rescaled for zero terminal SNR when zero_snr is set.
Every control arrives already resolved against the class’s own declared
default. So a file that omits one gets that class’s value, and a control
the class does not declare never reaches the table. trained, when
given, is the table itself. schedules lists the beta_schedule tables
the class implements. Every class accepts the three common ones, DDPM
adds GeoDiff’s sigmoid, and Heun adds the exponential alpha-bar. A table
that does not have count finite entries in [0, 1] raises ValueError.
The source rescales in float32, where 1 - bars[t] / bars[t - 1] cancels
and leaves alpha-bar about 1e-6 off its float64 value, by roundings no
port can repeat (torch’s CPU float32 sqrt is not correctly rounded). A
rescaled table is instead evaluated in float64, base table included, and
rounded once; every other table is the source’s float32 one to the bit.