Skip to content
data

TVMConfig

extendsGenerativeModelConfig
TVMConfig(sample_size: int | tuple[int, int] = 32, in_channels: int = 4, out_channels: int = 4, act_fn: GenerativeActivation = 'silu', patch_size: int = 2, hidden_size: int = 1152, depth: int = 28, num_heads: int = 18, mlp_ratio: float = 4.0, frequency_embedding_size: int = 256, num_classes: int = 1000, class_dropout: float = 0.1, qk_norm: bool = True, modulation_norm: bool = True, time_embedding_init: TimeEmbeddingInit = 'spectral', guidance_scale: float = 2.0, guidance_range: tuple[float, float] | None = None, scaled_parameterization: bool = True, time_sampler: TimeSampler = 'gap', gap_mean: float = -0.8, gap_std: float = 1.0, t_mean: float = 1.0, t_std: float = 1.0, s_mean: float = -0.4, s_std: float = 1.0, separate_flow_matching_time: bool = True, ratio_t_equals_s: float = 0.0, target_ema_decay: float = 0.99, eval_ema_decay: float | None = 0.9999, detach_jvp: bool = False, latent_mean: tuple[float, ...] = (0.86488, -0.27787343, 0.21616915, 0.3738409), latent_std: tuple[float, ...] = (4.85503674, 5.31922414, 3.93725398, 3.9870003))

Configuration for the Terminal Velocity Matching family.

Parameters

sample_sizeint= 32
Side of the latent the network operates on — 32 for 256-pixel ImageNet, 64 for 512-pixel, after the Stable Diffusion VAE's factor of eight.
in_channelsint= 4, 4
Latent channels. The network predicts a velocity in the latent's own space, which the loss and the sampler add to the input, so the two must be equal.
out_channelsint= 4, 4
Latent channels. The network predicts a velocity in the latent's own space, which the loss and the sampler add to the input, so the two must be equal.
patch_sizeint= 2
Side of the square patch each token covers.
hidden_sizeint= 1152
Transformer width.
depthint= 28
Number of transformer blocks.
num_headsint= 18
Attention heads per block. DiT-XL uses 16; the paper uses 18 so the head dimension is 64, which its attention kernel runs 1.25x faster at, and reports the two train to the same FID.
mlp_ratiofloat= 4.0
Feed-forward expansion inside each block.
frequency_embedding_sizeint= 256
Width of the sinusoid each scalar condition is expanded into before its MLP.
num_classesint= 1000
Label vocabulary. Index num_classes is the null label the guidance dropout substitutes.
class_dropoutfloat= 0.1
Probability of training a sample unconditionally — its label is replaced by the null token and its guidance scale by one.
qk_normbool= True
RMS-normalise queries and keys (with a learnable scale) before attention. Part of the semi-Lipschitz control.
modulation_normbool= True
RMS-normalise each adaLN shift, scale and gate vector (Eq. 16 and Appendix B.2). Without it the modulation's magnitude, and with it the layer's Lipschitz constant, can grow unbounded — the activation blow-up of Figure 4.
time_embedding_init(spectral, normal)= "spectral"
How the time and guidance MLPs start. Every other linear layer is initialised to unit spectral norm regardless.
guidance_scalefloat= 2.0
The classifier-free guidance weight ww trained at, and the default a sampler uses for labelled draws. The paper's best one-step 256-pixel model trains at 2.0.
guidance_rangetuple of float or None= None
(w_min, w_max) to train with a random guidance weight instead of a constant one: β=1/w\beta = 1/w is drawn uniformly from [1/wmax⁡,1/wmin⁡][1/w_{\max}, 1/w_{\min}]. Constant guidance wins in every comparison the paper makes (Table 4a), which is why None.
scaled_parameterizationbool= True
Predict FF with the guidance weight factored out, so the model's velocity is w Fθw\,F_\theta (Table 4c).
time_sampler(gap, trunc, clamp)= "gap"
Joint distribution of (t, s).
gap_meanfloat= -0.8, 1.0
Logit-normal parameters of t - s under "gap".
gap_stdfloat= -0.8, 1.0
Logit-normal parameters of t - s under "gap".
t_meanfloat= 1.0, 1.0
Logit-normal parameters of t under "trunc" and "clamp" — Table 3's best setting for both.
t_stdfloat= 1.0, 1.0
Logit-normal parameters of t under "trunc" and "clamp" — Table 3's best setting for both.
s_meanfloat= -0.4, 1.0
Logit-normal parameters of s, and of the Flow Matching time when that is drawn separately.
s_stdfloat= -0.4, 1.0
Logit-normal parameters of s, and of the Flow Matching time when that is drawn separately.
separate_flow_matching_timebool= True
Draw the Flow Matching term's time independently of the pair instead of reusing s — the sampler the paper names gap*, which lets the Flow Matching term keep the time distribution that works for Flow Matching on its own (Figure 9).
ratio_t_equals_sfloat= 0.0
Fraction of the batch trained with s = t, where the terminal term vanishes and only Flow Matching remains. The paper finds any non-zero share hurts one-step quality (Table 4d).
target_ema_decayfloat= 0.99
γ\gamma, the EMA rate of the network that supplies the terminal and unconditional targets. 0 uses the live weights under a stop-gradient; 0.99 is the paper's sweet spot (Table 4b).
eval_ema_decayfloat or None= 0.9999
γ∗∗\gamma^{**}, the rate of Algorithm 1's second average, the one that is evaluated and released (Table 6, "Eval EMA rate"). None keeps no such copy, saving a network's worth of memory.
detach_jvpbool= False
Stop the gradient at ∂sFθ\partial_s F_\theta. Faster and lighter, but biases the gradient — the paper's runtime study offers it as a trade, not a default (Figure 10).
latent_meantuple of float= (0.86488, -0.27787343, 0.21616915, 0.3738409)
Per-channel statistics the VAE latent is whitened with before the network sees it, z=(ℓ−μ)/σz = (\ell - \mu)/\sigma — IMM's setting, which the paper follows (Appendix F.1), in place of the usual single factor 0.18215. The defaults are the 256-pixel ones; the 512-pixel latent has its own.
latent_stdtuple of float= (0.86488, -0.27787343, 0.21616915, 0.3738409)
Per-channel statistics the VAE latent is whitened with before the network sees it, z=(ℓ−μ)/σz = (\ell - \mu)/\sigma — IMM's setting, which the paper follows (Appendix F.1), in place of the usual single factor 0.18215. The defaults are the 256-pixel ones; the 512-pixel latent has its own.

Notes

Reference: Zhou, Parger, Haque, and Song, "Terminal Velocity Matching", ICLR 2026 (arXiv:2511.19797). Training settings are Table 6; the defaults here are its first column, the 256-pixel model at w=2w = 2 behind the 3.29 one-step FID.

The released code agrees with the paper on every setting above, with one exception it does not exercise: its random-guidance path draws ww rather than 1/w1/w uniformly. The paper's description is followed here.

Examples

>>> from lucid.models.generative.tvm import TVMConfig
>>> config = TVMConfig()
>>> config.hidden_size, config.depth, config.num_heads
(1152, 28, 18)
>>> config.num_patches
256
The 512-pixel model is the same network over a wider latent:
>>> TVMConfig(sample_size=64).num_patches
1024

Used by 3

Properties

1
prop

num_patches

→int
num_patches: int

Tokens the latent is cut into — (sample_size / patch_size)^2.