Skip to content
module

TVM

8 members
lucid.models.generative.tvm

Terminal Velocity Matching — one- and few-step generation from scratch.

Zhou, Parger, Haque and Song, ICLR 2026 (arXiv:2511.19797). MeanFlow's dual: where MeanFlow differentiates the learned displacement at the interval's start, TVM differentiates it at the terminal time and matches it to the velocity where the jump lands — an objective that bounds the 2-Wasserstein distance once the network is made Lipschitz, which is what its RMS-normalised DiT is for.

Image Generation
Paper

Zhou, Linqi, Mathias Parger, Ayaan Haque, and Jiaming Song. "Terminal Velocity Matching." International Conference on Learning Representations (ICLR), 2026. [arXiv:2511.19797](https://arxiv.org/abs/2511.19797).

Overview

Write the ground-truth flow map from time tt to time ss as ψ(xt,t,s)=xt+∫tsu(xr,r) dr\psi(x_t, t, s) = x_t + \int_t^s u(x_r, r)\,dr and its net displacement as f(xt,t,s)=ψ(xt,t,s)−xtf(x_t, t, s) = \psi(x_t, t, s) - x_t. The displacement satisfies two conditions: it is the integral, and its derivative at s=ts = t is the instantaneous velocity. One two-time network parameterises both,

fθ(xt,t,s)=(s−t) Fθ(xt,t,s),uθ(xt,t)=Fθ(xt,t,t),f_\theta(x_t, t, s) = (s - t)\,F_\theta(x_t, t, s), \qquad u_\theta(x_t, t) = F_\theta(x_t, t, t),

and the scaling (s−t)(s - t) makes fθ(xt,t,t)=0f_\theta(x_t, t, t) = 0 hold by construction.

The integral condition cannot be trained directly — it would need an ODE solve per sample. Differentiating it with respect to the terminal time ss instead gives a condition with no integral in it,

ddsf(xt,t,s)=u(ψ(xt,t,s),s),\frac{d}{ds} f(x_t, t, s) = u\bigl(\psi(x_t, t, s), s\bigr),

and the squared error in that condition, integrated over s∈[0,t]s \in [0, t], upper-bounds the displacement error. The unknowns on the right are replaced by the model itself — the jump lands at xt+fθ(xt,t,s)x_t + f_\theta(x_t, t, s) and the velocity there is uθu_\theta — which is only sound if uθu_\theta is right, so Flow Matching is trained jointly. It is the same condition at zero displacement:

LTVMt,s=∥ddsfθ(xt,t,s)−uθ∗ ⁣(xt+fθ(xt,t,s),s)∥2+∥uθ(xs,s)−vs∥2.\mathcal{L}^{t,s}_{\mathrm{TVM}} = \Bigl\lVert \tfrac{d}{ds} f_\theta(x_t, t, s) - u_{\theta^*}\!\bigl(x_t + f_{\theta}(x_t, t, s), s\bigr) \Bigr\rVert^2 + \bigl\lVert u_\theta(x_s, s) - v_s \bigr\rVert^2 .

θ∗\theta^* is an exponential moving average of the weights, held under a stop-gradient, and the derivative expands to Fθ+(s−t) ∂sFθF_\theta + (s - t)\,\partial_s F_\theta — one Jacobian-vector product along ss, whose result is itself back-propagated through. A weighted integral of this objective over ss bounds W22W_2^2 between the data and the model's push-forward when uθ(⋅,s)u_\theta(\cdot, s) is Lipschitz (Theorem 1).

MeanFlow's dual. MeanFlow enforces ddtfθ=−u(xt,t)\frac{d}{dt} f_\theta = -u(x_t, t), differentiating at the start; the tangent of that derivative contains the sampled velocity vtv_t, whose magnitude under guidance varies widely. TVM's tangent is a unit step in ss, independent of xtx_t and tt, which is why it trains stably even with random guidance.

Guidance is learned, not applied. The class-conditional field is the guided one, w u(x,r,c)+(1−w) u(x,r)w\,u(x, r, c) + (1 - w)\,u(x, r), with the unconditional half supplied by the EMA network. Its magnitude grows linearly in ww, so the loss is weighted by 1/w21/w^2 and the network optionally predicts FF with the factor ww pulled out — the scaled parameterisation.

Semi-Lipschitz control. Every LayerNorm becomes a parameter-free RMSNorm, queries and keys are RMS-normalised, every adaLN modulation vector is itself RMS-normalised so its scale cannot grow without bound, and linear layers start at unit spectral norm.

Where Lucid departs from the authors' release, on purpose. The model matches the authors' code to float32 rounding (forward pass, terminal derivative, loss, every gradient and the sampler), but three choices differ, and they matter to anyone reproducing a released run from scratch:

  • The patch embedding starts at unit spectral norm. Lucid divides the patch-embedding weight by its largest singular value, as the paper prescribes for linear layers. The release's initialiser divides a rebound alias of the weight (w.data = w.data / s[0]) rather than the parameter, so its patch embedding keeps the Xavier-normal draw, σmax⁡≈1.53\sigma_{\max} \approx 1.53 at full size.
  • Precision. The release trains under bf16 autocast, and its Jacobian-vector product runs attention in bf16 even when autocast is off. Lucid computes in the model's own dtype throughout — float32 unless the model is cast — including the terminal derivative. A converted checkpoint sampled in Lucid is therefore not rounded where the authors' bf16 sampler is.
  • No NaN masking. The release replaces a NaN loss with zero before the backward pass; Lucid returns the loss as computed, so a diverging step is seen instead of trained through.

Classes

Functions