TorchLean API

NN.MLTheory.Generative.Diffusion.Samplers

Diffusion sampler theorems #

This file collects the fully proved sampler facts that sit between TorchLean's executable diffusion specs and the stability/verification APIs used elsewhere in the library.

We separate sampler mechanics from measure-level claims. ELBO optimality, reverse-SDE/PF-ODE marginal equivalence, and consistency distillation require additional probability and regularity assumptions; the theorems here prove the sampler-side facts that downstream proofs and verifiers can reuse directly:

References:

@[simp]

The VP schedule convention is ᾱ₀ = 1.

@[simp]

With no reverse steps, DDPM returns its initial terminal-noise state.

@[simp]

With no reverse steps, deterministic DDIM returns its initial terminal-noise state.

@[simp]

With zero Euler steps, the probability-flow sampler returns the initial state.

@[simp]

The DDIM system adapter is definitionally the corresponding DDIM step.

Quantitative Euler stability for probability-flow samplers #

One explicit Euler step is stable in L2 up to the current state separation plus the RHS separation.

For an ODE x' = f(x,t), the Euler update is E(x)=x+dt f(x,t). This theorem proves the standard numerical-analysis estimate

‖E(x)-E(y)‖₂ ≤ ‖x-y‖₂ + |dt| ‖f(x,t)-f(y,t)‖₂.

This proof uses TorchLean's real tensor norm library: the algebraic Euler-difference identity above, the L2 triangle inequality, and L2 homogeneity of scalar multiplication. It is the bridge from the executable PF-ODE sampler to quantitative stability/verification arguments.

Reference: this is the elementary one-step stability estimate underlying explicit Euler analyses; see Hairer, Nørsett, and Wanner, Solving Ordinary Differential Equations I.

If the ODE right-hand side is L-Lipschitz in L2 at a fixed time, then one Euler step is (1 + |dt| L)-Lipschitz in L2.

This is a quantitative sampler theorem: once we prove or import a Lipschitz bound for the neural vector field, this theorem converts it into a certified bound for the actual update used by the sampler.

Probability-flow Euler systems inherit the concrete L2 Euler-step Lipschitz bound.

For the PF-ODE vector field pfOdeRhs sch model, any certified L-Lipschitz bound on the RHS at time t yields a (1 + |dt| L) Lipschitz bound on the DynamicalSystem.step used by TorchLean trajectories. This is the theorem downstream PF-ODE certificates should target first.

Lipschitz and contraction transport through sampler adapters #

If the underlying DDIM update is L-Lipschitz, then the DynamicalSystem wrapper around that update is also L-Lipschitz.

This is the compositional bridge we want at the API boundary: once a concrete DDIM step bound is available, the same bound is immediately available through the common dynamics API used elsewhere in TorchLean.

If the underlying probability-flow Euler update is L-Lipschitz, then its DynamicalSystem adapter is L-Lipschitz.

For quantitative PF-ODE certification, this is the bridge from an ODE-step bound (for example via IBP/CROWN on the vector field) to the reusable trajectory and iterate definitions in NN.Spec.Dynamics.System.

A contractive DDIM update remains contractive after packaging it as a DynamicalSystem.

This is the formal hook for fixed-point and stability arguments about deterministic diffusion samplers: once a concrete DDIM step bound is proved, the dynamics-level contraction predicate follows without re-opening the sampler definition.

A contractive PF-ODE Euler update remains contractive after packaging it as a DynamicalSystem.

This keeps the verification-facing statement compositional: prove the Euler map contracts under the chosen norm, then reuse the dynamics API for iterated sampler trajectories.