research28 min studyLesson 774 in Engineering

Timestep sampling: preserve the intended objective under a new proposal

Derive importance corrections, support conditions, and variance considerations for nonuniform diffusion-timestep sampling.

On this page

What you’ll understand

  • Construct an unbiased loss estimator for a stated timestep objective.
  • Identify when missing proposal support or clipped weights changes that objective.
  • Distinguish loss-estimator variance from gradient-estimator variance.

Choosing noisy examples more often can improve the efficiency of learning, but sampling frequency is not the same thing as an objective weight. If a proposal distribution replaces the intended timestep distribution, a correction is needed to retain that objective. State the desired sum, the executed proposal, and the support condition before interpreting a loss curve from an adaptive sampler.

Separate base mass, objective weight, and proposal mass

Let pi_t be the desired discrete timestep probability and lambda_t its explicit nonnegative objective weight. A proposal q_t determines how often a timestep is sampled. Multiplying a sampled loss by pi_t lambda_t/q_t produces the desired weighted expectation when the proposal covers every nonzero contribution. For a uniform objective over T timesteps, pi_t is one over T. The ratio is not generally just one over q_t; omitting pi changes scale and can affect comparisons or the optimizer's effective step size.

If q_t is zero where the desired weighted loss can contribute, no finite weight can recover that missing term from samples. Keep a positive exploration floor where needed. Additional clean-data and noise randomness remains inside the timestep loss expectation. An adaptive proposal can use detached historical statistics, with sampling and correction treated as proposal machinery rather than differentiated objective terms in the stated estimator. Document how distributed ranks update that history and whether their effective proposals and weights agree.

L=∑tπtλt E[ℓt],L^=πtλtqtℓt,t∼qL=\sum_t\pi_t\lambda_t\,\mathbb E[\ell_t],\qquad \widehat L=\frac{\pi_t\lambda_t}{q_t}\ell_t,\quad t\sim q
π and q are normalized discrete masses, λ_t≥0, and q_t>0 wherever the desired weighted contribution is nonzero. Expectations also include clean data and noise. Finite integrability is assumed, and the proposal/correction is held fixed for ordinary per-step differentiation of this stated objective.↔ Scroll wide equations horizontally.

A variance target must name the estimated quantity

For a scalar loss estimator, the ideal proposal depends on the second moment of the per-timestep loss, not merely its mean. Improved DDPM explores loss-aware importance sampling for its objective. The ideal values are unknown during training, so implementations estimate them and need startup behavior and support safeguards. A proposal that helped a likelihood-related objective may not be optimal for another weighted denoising objective. Re-derive the contribution after changing the target, lambda, or normalization.

Gradient variance is another target: it depends on gradient-vector second moments, not simply scalar loss second moments. A high loss can have a small gradient under a particular parameterization, or vice versa. Importance weights with a large dynamic range can create unstable finite-sample updates. Clipping them or self-normalizing by their observed batch sum generally changes the finite-sample estimator and can introduce bias. Those may be deliberate algorithms, but they should not be described as the original unbiased estimator without qualification.

qt⋆∝πtλtE[ℓt2]q_t^\star\propto \pi_t\lambda_t\sqrt{\mathbb E[\ell_t^2]}
This scalar-loss second-moment minimizer assumes the stated nonnegative weights, finite second moments with positive total normalization, unrestricted normalized proposals, and appropriate support. It is not a universal optimum for gradient variance, convergence speed, or sample quality; zero-contribution timesteps need an explicit support policy.↔ Scroll wide equations horizontally.

Compare sampling changes under a fixed validation measure

Log the proposal distribution, effective weights, per-bin sample counts, and both proposal-weighted and fixed-reference validation losses. Keep held-out noise and timestep draws fixed when isolating a sampler change, or evaluate under a declared reference distribution with enough samples. A proposal-weighted training mean can fall merely because the sampled mix changed. Measure wall-clock cost, gradient behavior, and downstream sampling metrics at matched compute or data budgets. Check rare timesteps and rank-local distributions rather than relying only on the aggregate mean.

The probability lab models how often one of two timestep classes is selected in independent draws. Reset, set p=0.25 and n=20, predict five selections on average, then Play or Step. Separately Reset, set p=0.75 and n=20, predict fifteen, then Play or Step. Playback highlights the exact binomial distribution, not an adaptive training run. The instrument has no loss values or importance correction. Use the changed counts to distinguish proposal frequency from the paper calculation that preserves the desired objective.

An unequal proposal can estimate the same mean

Two timesteps have deterministic losses two and eight. The desired distribution is uniform with lambda one. Sample them with proposal q=[0.25,0.75].

  1. The desired objective is 0.5×2+0.5×8=5.

  2. Importance factors are 0.5/0.25=2 and 0.5/0.75=2/3. The sampled estimator values are four and 16/3.

  3. Their proposal expectation is 0.25×4+0.75×16/3=1+4=5. With deterministic positive losses, the ideal scalar-loss proposal [0.2,0.8] would instead make both corrected values five; real losses also vary with data and noise.

The result

Correcting proposal frequency preserves the stated objective. The zero-variance observation applies only to this deterministic two-value example.

Explore the model

Interactive lab

Interactive lab · probability

Proposal frequency and objective mass are separate

Reset, set p=0.25 and n=20, predict mean 5, then Play or Step. Separately Reset, set p=0.75 and n=20, predict mean 15, then Play or Step. The exact iid binomial has no adaptive timestep history, losses, or importance weights.

Proposal frequency and objective mass are separateThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA more frequent timestep needs the appropriate correction if the intended objective is unchanged.

Check your understanding

What happens if a proposal assigns zero mass to a timestep with a nonzero desired weighted contribution?

Try it yourself

Three deterministic losses are [1,2,3], desired masses are uniform, and proposal masses are [0.5,0.25,0.25]. Compute the corrected estimator values and their proposal expectation.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Multiply each loss by (1/3)/q_t.

Compare with the solution

The corrected values are 2/3,8/3,4. Their expectation is 0.5×2/3+0.25×8/3+0.25×4=1/3+2/3+1=2, matching the uniform mean. Sampling without correction would instead weight the first loss more strongly and change that mean.

Take it with you

  • Base timestep mass, objective weighting, and proposal frequency are distinct.
  • Unbiased correction needs support and the correct probability ratio.
  • Loss variance, gradient variance, and end-to-end convergence are different optimization targets.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.