Probability-flow ODE (spec layer) #
This file defines a small continuous-time VP schedule (linear β(t)) and the corresponding
probability-flow ODE drift field, using an ε_θ(x,t) model.
Why include this in the spec layer:
- the ODE is a deterministic dynamical system derived from the same diffusion model, and
- it is the natural interface for inference-time verification tooling (corridor certificates, IBP/CROWN bounds on the RHS, etc.).
We keep the implementation scalar-polymorphic (Context α) so it can be:
- executed with
Float/IEEE32Exec/NeuralFloat, and - reasoned about with
ℝ.
References (informal pointers):
- Song et al. (2021), "Score-Based Generative Modeling through Stochastic Differential Equations". The VP SDE and its probability-flow ODE share the same marginals.
Continuous-time linear VP schedule on t ∈ [0,1]: β(t) = β0 + t(β1-β0).
- beta0 : α
β(0). - beta1 : α
β(1).
Instances For
Linear interpolation β(t) on t ∈ [0,1].
Instances For
Closed-form ᾱ(t) for the VP SDE with linear β(t):
ᾱ(t) = exp(-∫₀ᵗ β(s) ds) = exp(-(β0 t + 0.5 (β1-β0) t^2)).
Instances For
σ(t) = sqrt(1-ᾱ(t)) (clamped to stay total).
Instances For
Probability-flow ODE drift for a VP schedule, expressed via an ε_θ(x,t) model.
For VP SDE:
dx = -0.5 β(t) x dt + sqrt(β(t)) dW
The probability-flow ODE is:
dx = (-0.5 β(t) x - β(t) score(x,t)) dt.
Using the ε-parameterization, an approximate score is score ≈ -(1/σ(t)) ε̂, so:
dx = (-0.5 β(t) x + (β(t)/σ(t)) ε̂(x,t)) dt.
Instances For
One explicit Euler step for an ODE x' = f(x,t):
xNext = x + dt * f(x,t).
To integrate the probability-flow ODE backwards from t=1 to t=0, use a negative dt.
Instances For
Deterministic probability-flow sampler using Euler integration on a uniform grid.
Inputs:
steps: number of Euler steps (typically large, e.g. 1000),x1: initial state att = 1(typically standard normal noise).
We integrate backwards in time on the grid:
t_i = 1 - i/steps, with dt = -1/steps.
Instances For
Instances For
Real-valued probability-flow Euler step as a DynamicalSystem.
This is the formal hook used by trajectory/fixed-point/contraction lemmas in
NN.Spec.Dynamics.System: at a fixed time and step size, Euler integration is an autonomous
discrete update on the current sample.