Variational JEPA
Huang, VJEPA: Variational Joint Embedding Predictive Architectures as Probabilistic World Models, 2026. Paper · Code · Notebook
Variational JEPA makes the JEPA predictor probabilistic: it outputs a Gaussian
Usage
from torch_world.models import VariationalJEPA
from torch_world.nn import CLSEncoder
model = VariationalJEPA(CLSEncoder(img_size=64, patch_size=8, embed_dim=128, depth=4, num_heads=4), action_dim=10,
embed_dim=128, history=3, depth=4, num_heads=4, head_dim=32, mlp_dim=512, proj_dim=512)
out = model(pixels, actions) # (B, history + 1, C, H, W), (B, history + 1, A)
# out: {"loss", "nll_loss", "kl_loss", "sigreg_loss", "variance"}
model.update_target(0.99) # after each optimizer step
z = model.encode(pixels) # (B, T, embed_dim)
mean, logvar = model.distribution(z, actions)
futures = model.sample(z[:, :1], plan, 16) # (B, 16, T + 1, embed_dim)predict returns the predictive mean, so rollout and CEM plan on it by default. The paper shows this MAP plan is optimal for quadratic costs when the noise does not depend on the action. CEM(...)(model, z, goal, sample=True) plans on sampled rollouts instead, one per candidate, as in the paper's sampling-based latent MPC. Averaging the cost over several samples, or penalizing its variance, are the risk-sensitive variants the paper mentions.
The paper states the objective for general encoders. Its pixel-control experiments add VICReg against collapse; this implementation uses SIGReg for the same role. Log-variances are clamped to logvar_range, as in the reference. The projector and head use BatchNorm: call recompute_batchnorm before planning.
Reference
Arguments and methods: VariationalJEPA in the API reference.
