Skip to content

pytorch-worldpytorch-world

World models for PyTorch. Learn how a world evolves, then plan by imagining what comes next. Shared parts keep every model short and easy to compare.

bash
uv add torch_world
  • Model families


    Models grouped by how they learn: JEPA, from image pretraining to multi-robot control; DINO; TD-MPC, for reward-driven control; and world action models, which imagine video and act. More families are coming.

    Models

  • One world-model interface


    encode, predict and rollout are the same for every world model, so they can be trained, compared and planned with interchangeably.

    Concepts

  • Planning


    Search for actions inside a model's imagination. The cross-entropy method works with any world model, with no extra code.

    Planning guide

  • Environments


    190 environments: 33 built-in tasks from planning puzzles to Franka manipulation, plus OGBench, DMControl, Meta-World, ManiSkill, MyoSuite, RoboCasa and RoboDojo.

    Environments

  • Datasets


    Windows over collected experience for training dynamics, plus medical images and questions for vision-language models.

    Datasets

  • Building blocks


    Vision transformers for images and video, conditioned predictors, masking strategies and objectives, shared by every family.

    API reference

Environments ​

190 environments: 33 built-in, 13 from OGBench, 20 from DMControl, 10 from Meta-World, 12 from ManiSkill, 10 from MyoSuite, 50 from RoboCasa and 42 from RoboDojo. Built-in tasks show a verified successful episode; OGBench tasks replay an episode of their dataset, Meta-World tasks its scripted expert, DMControl, ManiSkill and MyoSuite tasks a random policy, RoboCasa tasks a human demonstration, and RoboDojo tasks its official task video. See Environments for each one.

Contributors ​

pytorch-world is built in the open. Thank you to everyone who contributes code, models, environments and ideas.

Thirty seconds ​

python
from torch_world.envs import PointMass
from torch_world.models import LeWM
from torch_world.nn import CLSEncoder
from torch_world.planning import CEM

model = LeWM(CLSEncoder(img_size=32, patch_size=8, embed_dim=64), action_dim=2, embed_dim=64)
episodes = PointMass(batch_size=64).collect(4)                 # pixels (64, 4, 3, 32, 32), actions (64, 4, 2)
loss = model(episodes["pixels"], episodes["actions"])["loss"]  # prediction + SIGReg

model.eval()
z, goal = model.encode(episodes["pixels"][:, :1]), model.encode(episodes["pixels"][:, -1:])[:, 0]
actions = CEM(horizon=5, action_dim=2)(model, z, goal)         # (64, 5, 2)

This trains LeWM, a JEPA world model, on a point mass and plans toward a goal image. Read the quick start for what each line does, or open the tour notebook.