Skip to content

LpWM ​

INFO

本页尚未翻译。 阅读英文版

Kuang et al., LpWM: A Case for Sparse Representations in World Models, 2026. Paper · Code · Notebook

LpWM is a LeWM-style world model whose latents are non-negative and sparse. Each frame is encoded to one embedding (the encoder's CLS token), projected and passed through a RepReLU link h (ReLU forward, GELU gradient backward), so most units are exactly zero. A causal transformer, conditioned on action embeddings through adaLN-zero, predicts the next code from the last history frames, through the same link. In place of SIGReg, RDMReg matches the codes of each timestep to a rectified Laplace with a sliced 2-Wasserstein distance, which prevents collapse and sets the share of active units:

L=‖z^t+1−zt+1‖2+λEc∼U(Sd−1)W22(c⊤z, c⊤y),y∼∏iReLU(GNp(μ,σ))

With p = 1 and mu = 0 half of the target's units are zero. The paper finds that which units fire encodes the discrete regime of the dynamics, and their magnitudes the continuous state within it. Planning is LeWM's: CEM toward the code of a goal image.

Usage ​

python
from torch_world.models import LpWM
from torch_world.nn import CLSEncoder

model = LpWM(CLSEncoder(img_size=64, patch_size=8, embed_dim=192), action_dim=2, history=1, depth=6, num_heads=8,
             head_dim=32, mlp_dim=768, proj_dim=768, lamb=10.0)

out = model(pixels, actions)        # (B, history + 1, C, H, W), (B, history + 1, A)
# out: {"loss", "pred_loss", "rdmreg_loss"}

z = model.encode(pixels)            # (B, T, embed_dim), non-negative with exact zeros
active = z > 0                      # which units fire

encoder maps images (N, C, H, W) to embeddings (N, embed_dim); a ViT-tiny CLS token in the paper, which CLSEncoder provides. RDMReg(num_slices, p, mu, rectify) sets the target: p = 1 is the paper's sparse default, mu < 0 makes codes sparser, and p = 2, rectify=False recovers LeWM's isotropic Gaussian. The paper uses history = 1 on its Wall environment and 3 elsewhere, and lamb = 10 with 1024 slices.

The projectors use BatchNorm: call recompute_batchnorm before planning.

Reference ​

Arguments and methods: LpWM in the API reference.