LeWM: Action-Conditioned Visual World Model

LeWM: Action-Conditioned Visual World Model#

LeWorldModel (LeWM) is a Joint-Embedding Predictive Architecture (JEPA) that learns how actions change a scene from RGB trajectories. It predicts the embedding of a future camera frame. A planner can use those predictions to choose actions that bring the scene closer to a goal image.

Architecture#

The encoder maps each camera frame to a single vector. The predictor uses recent vectors and the intervening actions to estimate where the next frame will land in that same space. The observed and predicted vectors can therefore be compared directly during training and planning. LeWM project · Authors’ training diagram

        flowchart TB
    accTitle: LeWM action-conditioned latent prediction
    RGB["Camera frames"] --> ENC["ViT encoder and MLP projector"]
    ENC --> HIST["Observation embeddings"]
    ACT["Controller actions"] --> AENC["Standardization and action embedding"]
    HIST --> PRED["Causal Transformer"]
    AENC -->|conditions each block| PRED
    PRED --> HEAD["MLP prediction head"]
    HEAD --> NEXT["Predicted next embedding"]
    
  • Image encoder. preprocess_rgb resizes RGB frames and applies ImageNet normalization. The default 12-layer ViT-Tiny takes 224 × 224 images with 14 × 14 patches. An MLP with batch normalization projects the final [CLS] token to a single 192-dimensional embedding per frame.

  • Action encoder. Each model step takes the raw controls issued between successive frames. A step can pack several consecutive controls into one vector. LeWM standardizes that vector using saved action means and standard deviations, then embeds it with a 1D convolution and an MLP.

  • Dynamics predictor. A six-layer Transformer uses learned temporal positions and causal attention over recent observation embeddings. The action embeddings condition its blocks through adaptive layer normalization (AdaLN-Zero). An MLP maps the output to the image embedding space.

Training and planning#

The original training objective jointly optimizes the encoder and predictor on offline image and action sequences. The prediction term measures mean squared error between the predicted embedding and the actual next frame’s embedding from the same encoder. The Sketched Isotropic Gaussian Regularizer (SIGReg) uses random one-dimensional projections to push the embeddings toward a standard Gaussian, which penalizes collapse to a constant representation.

\[\mathcal{L} = \mathrm{MSE}(\hat{z}_{t+1}, z_{t+1}) + \lambda\,\mathrm{SIGReg}(Z).\]

Here Z contains the encoded observations in the training batch and λ weights the regularizer.

The shared supervised-learning recipe in EmbodiChain reads HDF5 episodes containing T + 1 RGB frames and T outgoing actions. It samples aligned windows within each episode and exports weights with the model configuration and action statistics.

At inference, the planner encodes the live observation and the goal image with the same encoder. It feeds predicted embeddings back into the predictor to roll out candidate action sequences. The cross-entropy method (CEM) scores each sequence by the squared distance from its final embedding to the goal embedding and refits its sampling distribution to the lowest-cost candidates. Executing planned controls and replanning from fresh camera frames gives closed-loop model predictive control.

Inputs and outputs#

Images arrive as channels-last uint8 RGB or RGBA. preprocess_rgb converts them to normalized, channels-first RGB. For a batch of B histories, H is the number of observed frames, D the latent width and A the number of raw control values in one model-action block.

Operation

Inputs

Outputs

LeWM.encode

Images [B, H, 3, height, width]

Observed latents [B, H, D]

LeWM.rollout

Observed latents, executed actions [B, H-1, A] and S candidate sequences [B, S, T, A]

Future latents [B, S, T, D] for T model steps

LeWMCEMPlanner.plan_sequence

Observed latents, executed actions and a goal-image latent [B, D]

Raw action blocks [B, horizon, A] and a terminal goal cost [B]

The caller unpacks each selected block into consecutive controller actions. The LeWM API documents the model and planner.

Examples#

Reproduce image-goal planning with the OGBench Cube example.

The Cube example uses DexUni CPU rigid-body physics and the EmbodiChain camera. The paired training workflow starts from the published OGBench Cube weights. It adapts the visual encoder and projector to native camera images using targets computed by the published encoder from matching upstream frames. The predictor stays frozen, and action normalization uses statistics from the official dataset.

Before running the commands, set up Python, CUDA and the example dependencies from the Cube runtime guide.

Run from the repository root with the Cube environment active. Keep the resource directory for repeated runs and use a fresh run directory for each collection, training, and evaluation.

CUBE_PROFILE=reproduce
CUBE_RESOURCES=${CUBE_RESOURCES:-outputs/lewm-cube/resources}
CUBE_RUN=outputs/lewm-cube/$CUBE_PROFILE

# 1. Prepare the pinned dataset, weights, and simulator assets.
embodichain run-example learning/lewm/cube prepare --resource-root "$CUBE_RESOURCES"

# 2. Render native images from the archived poses.
embodichain run-example learning/lewm/cube collect \
  --resource-root "$CUBE_RESOURCES" --output "$CUBE_RUN/pairs" \
  --profile "$CUBE_PROFILE" --gpu-ids 0 --workers 8

# 3. Fit the visual encoder and projector and export the selected checkpoint.
embodichain run-example learning/lewm/cube train \
  --resource-root "$CUBE_RESOURCES" --data "$CUBE_RUN/pairs" \
  --output "$CUBE_RUN/vision" --profile "$CUBE_PROFILE" --device cuda:0

# 4. Evaluate the fixed queries and save frames for an optional preview.
embodichain run-example learning/lewm/cube eval \
  --resource-root "$CUBE_RESOURCES" --checkpoint "$CUBE_RUN/vision/export" \
  --output "$CUBE_RUN/evaluation" --device cuda:0 --gpu-id 0 --preview-query 12

# 5. Optionally render the saved frames as an MP4.
embodichain run-example learning/lewm/cube demo \
  --evaluation "$CUBE_RUN/evaluation" --query 12 --output "$CUBE_RUN/query-12.mp4"
  1. prepare fetches and verifies the public LeWM checkpoint and expert corpus, checks out pinned upstream revisions, and builds the native assets and seed-42 evaluation queries. It writes resources.json with the input digests.

  2. collect renders 40 poses per episode and saves the images and episode splits under pairs/. The reproduce preset uses 224 training episodes and 48 validation episodes, with the fixed evaluation episodes held out.

  3. train aligns native frame embeddings to embeddings from the upstream encoder at the same poses. It saves the checkpoint with the lowest held-out paired error as vision/export/weights.pt alongside manifest.json.

  4. eval runs the pinned upstream CEM on native initial, goal, and replanning images. Each plan covers 25 controller steps. If the cube has yet to reach the goal, the evaluator replans and executes up to 50 steps in total. Success means the cube center comes within 4 cm of the target after a control step. Check num_eval (50), success_count, and success_rate in evaluation/report.json. The evaluator also writes trace.npz and observations.npz.

  5. demo uses the frames saved by eval --preview-query 12 to write query-12.mp4, with the live camera on the left and the goal on the right.

For a shorter collection and training run, change CUBE_PROFILE to smoke and use --workers 1 in collect. This preset uses 8 training episodes, 2 validation episodes, and 40 updates. Evaluation still runs all 50 queries. Omit --checkpoint from eval to use the published weights on native images.

To train both the visual encoder and dynamics predictor on native RGB, follow the example’s expert-trajectory fine-tuning instructions.

References#

Lucas Maes, Quentin Le Lidec, Damien Scieur, Yann LeCun, and Randall Balestriero (2026). LeWorldModel: Stable End-to-End Joint-Embedding Predictive Architecture from Pixels. arXiv:2603.19312

@misc{leworldmodel2026,
  author = {Maes, Lucas and Le Lidec, Quentin and Scieur, Damien and
            LeCun, Yann and Balestriero, Randall},
  title = {{LeWorldModel}: Stable End-to-End Joint-Embedding Predictive Architecture from Pixels},
  year = {2026},
  eprint = {2603.19312},
  archivePrefix = {arXiv},
  primaryClass = {cs.LG},
  url = {https://arxiv.org/abs/2603.19312}
}