Skip to content
class

TVMModel

extendsPretrainedModel
TVMModel(config: TVMConfig)

The two-time velocity network w Fθ(xt,t,s,c,w)w\,F_\theta(x_t, t, s, c, w).

Parameters

configTVMConfig
The variant to build.

Attributes

patch_embedlucid.nn.Conv2d
Patchifying projection — stride equals kernel.
pos_embedTensor
Frozen two-dimensional sine-cosine table, added to the tokens.
time_embed, interval_embed, guidance_embed_ScalarEmbedder
Embeddings of tt, t−st - s and 1/w1/w.
Class embedding, with the null label as its last row.
The semi-Lipschitz DiT blocks.
final_FinalLayer
Modulated norm and projection back to patch space.

Notes

Reference: Zhou, Parger, Haque, and Song, "Terminal Velocity Matching", ICLR 2026 (arXiv:2511.19797), Sections 3–4 and Appendix F.1.

The forward returns the average velocity over [s,t][s, t] — the displacement divided by its length — so that one step of the sampler is xs=xt+(s−t)⋅samplex_s = x_t + (s - t)\cdot\mathrm{sample}. Under the scaled parameterisation that is w Fθw\,F_\theta, the network's output times the guidance weight; otherwise it is FθF_\theta itself. At s=ts = t it is the instantaneous velocity uθ(xt,t)u_\theta(x_t, t).

Examples

>>> import lucid
>>> from lucid.models.generative.tvm import TVMConfig, TVMModel
>>> config = TVMConfig(sample_size=8, patch_size=2, hidden_size=32,
...                    depth=2, num_heads=4, num_classes=10)
>>> model = TVMModel(config).eval()
>>> x = lucid.randn((1, 4, 8, 8))
>>> t, s = lucid.tensor([1.0]), lucid.tensor([0.0])
>>> model(x, t, s, lucid.tensor([3])).sample.shape
(1, 4, 8, 8)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: TVMConfig)

Initialise the network. See the class docstring for parameters.

Instance methods

2
forward(x: Tensor, t: Tensor, s: Tensor, labels: Tensor | None = None, guidance_scale: Tensor | float | None = None)

Evaluate the average velocity from time t to time s.

Parameters

(B, in_channels, H, W) — the point on the path at t.
(B,) start times.
(B,) end times, s <= t. s = t gives the instantaneous velocity.
labelsTensor or None= None
(B,) class indices. None uses the null label, index num_classes.
guidance_scale(Tensor, float or None)= None
The guidance weight ww, per sample or shared. The network is conditioned on 1/w1/w. None resolves as resolve_guidance describes.

Returns

DiffusionModelOutput

sample of shape (B, out_channels, H, W) — the average velocity, w Fθw\,F_\theta under the scaled parameterisation and FθF_\theta otherwise.

fn

resolve_guidance

→float or Tensor
resolve_guidance(guidance_scale: Tensor | float | None, labels: Tensor | None)

The guidance weight a call runs at.

Parameters

guidance_scale(Tensor, float or None)
What the caller asked for. None picks the weight the model was trained at for a labelled call and w=1w = 1 for an unlabelled one — the only weight the null label is ever trained with.
labelsTensor or None
The call's labels.

Returns

float or Tensor

guidance_scale, or the default it resolves to.