Skip to main content

pytorch-world

PyPI Python PyTorch CI Docs License Open in Colab

PyTorch World (torch_world) is a library of world models for PyTorch. It gives world-model research shared parts (layers, masking, objectives, planners, environments) so that a new model is a short file and existing models are easy to compare.

Main benchmark on Two-Rooms: PLDM reaches the other room 88% of the time in 23 ms per step; V-JEPA 2-AC 44%, LeWM 34%, DINO-WM 28% and TD-MPC2 0%, while most reach goals in the same room

Benchmark results · notebook

uv add torch_world                 # core: depends only on torch
uv add "torch_world[examples]"     # + matplotlib, for the notebooks' figures
uv add "torch_world[action]"       # + mujoco, for the RobotCube arms and Push-T

Quick start

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; train with any optimizer

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

Train it end to end and plan in a few minutes: examples/quickstart.ipynb, or open it in Colab.

Structure

module contents
torch_world.nn VisionTransformer (image and video), MaskedPredictor, Transformer, Block, AdaLNBlock, Attention, MLP, sin-cos and rotary positions; ready encoders CLSEncoder, PixelPatches, PatchTokens.from_hub (DINOv2) and VideoTokens.from_hub (V-JEPA 2); TextEncoder and WordTokenizer; video autoencoders VideoVAE (Wan 2.1) and ConvVideoAE; flow-matching helpers
torch_world.masks MultiBlockMask (2D), MultiBlock3DMask (video), frame_causal_mask, apply_masks
torch_world.losses SIGReg, RDMReg, info_nce
torch_world.models the JEPA, WorldModel and WorldActionModel base classes and the models below
torch_world.planning CEM, for any WorldModel, scoring the final or every imagined step; MPPI, for reward (TD-MPC2) or toward a goal; GRASP, by gradient descent; HierarchicalPlanner, for two-level models; WAMPlanner and DreamZeroPolicy for world action models
torch_world.safety the Latent Safety Filter for any WorldModel: FailureMargin on latents, SafetyValue (reachability by DDPG in imagination, fit_safety_value), and SafetyFilter, which overrides a task policy only when its next state would be unsafe
torch_world.envs MuJoCo worlds: RobotCube (reach or pick-and-place with a UR10e or SO-101 arm, after OGBench cube-single) and PushT; the batched pixel worlds Macaw, PointMass and TwoRooms (PLDM's long-horizon task, with optional drifting distractors and a floor tint); run_policy
torch_world.datasets TrajectoryDataset, sliding windows over episodes; MedMNIST and MedicalVQA, templated medical VQA in the style of MMBU
torch_world.evaluation goal_reaching for planners in any environment, with success rates and recorded videos, and goal_policy to plan toward goal images; vqa and compare for retrieval question answering, with a shuffled-image control
torch_world.metrics the metrics of the papers: linear, k-NN and attentive probes, RankMe, LiDAR, rollout error, SSIM, PSNR, Chamfer distance, recall@k; calibration of sampled predictions (CRPS, energy score, interval coverage, spread / skill); for robotics, success rates with confidence intervals, steps to success, progress, SPL and smoothness
torch_world.utils fit, a short training loop; ema_update, linear_schedule, recompute_batchnorm
torch_world.hub save, load and share checkpoints: safetensors weights, a config that rebuilds the model, a model card (pip install torch-world[hub])
torch_world.plots matplotlib figures for notebooks (optional dependency)

Models

JEPA

model paper reference code notebook
IJEPA Assran et al., 2023 facebookresearch/ijepa vision/ijepa
VJEPA (and V-JEPA 2) Bardes et al., 2024, Assran et al., 2025 facebookresearch/jepa, facebookresearch/vjepa2 vision/vjepa
LeJEPA Balestriero & LeCun, 2025 galilai-group/lejepa vision/lejepa
VJEPA21 Mur-Labadia et al., 2026 facebookresearch/vjepa2 vision/vjepa21
LeVJEPA Kuhn et al., 2026 galilai-group/levjepa vision/levjepa
VLJEPA Chen et al., 2026 not released vqa/vljepa
PLDM Sobal et al., 2025 vladisai/PLDM action/pldm
LpWM Kuang et al., 2026 YilunKuang/lpworldmodel action/lpwm
FlowJEPA Huo et al., 2026 HuoYanchen/Flow-JEPA action/flowjepa
VariationalJEPA Huang, 2026 YongchaoHuang/VJEPA action/varjepa
AdaJEPA Wang et al., 2026 agentic-learning-ai-lab/adajepa action/adajepa
CausalJEPA Nam et al., 2026 galilai-group/cjepa action/causaljepa
CFJEPA Byrd et al., 2026 not released action/cfjepa
TDJEPA Bagatella et al., 2025 not released action/tdjepa
HWM Zhang et al., 2026 kevinghst/HWM_PLDM action/hwm
HJEPA Zhang et al., 2026 kevinghst/H-JEPA action/hjepa
LeWAM Fu et al., 2026 MinghaoFu/lewam action/lewam
LeWM Maes et al., 2026 lucas-maes/le-wm action/lewm
RoboJEPA Zholus et al., 2026 facebookresearch/robo_jepa action/robojepa
VLAJEPA Sun et al., 2026 ginwind/VLA-JEPA action/vlajepa

Joint-embedding predictive architectures (JEPAs) predict the representation of a target from the representation of a context, instead of reconstructing pixels. Action-conditioned JEPAs are world models: they predict the next latent state from the current one and an action, and planning searches for the actions that bring the imagined latent closest to a goal.

DINO

model paper reference code notebook
DINOv2 Oquab et al., 2024 facebookresearch/dinov2 vision/dinov2
DINOWM Zhou et al., 2025 gaoyuezhou/dino_wm action/dinowm

Self-distillation: a student matches an EMA teacher's assignments of image crops to learned prototypes, on [cls] tokens (DINO) and masked patches (iBOT). The notebook trains it next to LeVJEPA on the same photos and footage. DINO-WM learns latent dynamics over the patch features of a frozen DINOv2 encoder and plans with CEM.

TD-MPC

model paper reference code notebook
TDMPC2 Hansen et al., 2024 nicklashansen/tdmpc2 action/tdmpc2

TD-MPC world models have no decoder: latent dynamics are trained to predict the next latent, the reward and, by temporal-difference learning, the value. MPPI plans for the highest imagined return, with proposals from a learned policy prior.

Dreamer

model paper reference code notebook
DreamerV3 Hafner et al., 2023 danijar/dreamerv3 action/dreamerv3

Dreamer learns a recurrent state-space model by reconstructing pixels, rewards and episode ends, and trains an actor and a critic on imagined rollouts. It is the library's non-JEPA reference: the same WorldModel interface, so CEM plans on its states as well.

World action models

model paper reference code notebook
DreamZero Ye et al., 2026 not used action/dreamzero

World action models denoise future video and the actions that produce it together, so the model is both the policy and the world model. DreamZero is an autoregressive joint video-action diffusion transformer on Wan 2.1 video-VAE latents (pip install torch-world[wam]); its notebook trains it from scratch on a UR10e arm and compares it with LeWAM.

Planners

planner paper notebook
CEM Rubinstein, 1999 action/lewm
MPPI Williams et al., 2017 action/tdmpc2
GRASP Psenka et al., 2026 planning/grasp
HierarchicalPlanner Zhang et al., 2026 action/hwm

Pretrained checkpoints

Load a trained model in one line with torch_world.hub (pip install "torch-world[hub]"):

from torch_world import hub

model = hub.from_pretrained("latenthorizon/lewm-pusht")
checkpoint model trained on Push-T success
latenthorizon/lewm-pusht LeWM, 18M Push-T expert data, MuJoCo PushT 80.4% (500 tasks)
latenthorizon/lewm-pusht-pymunk LeWM, 18M Push-T expert data, reference pymunk env 83.8% (500 tasks)
latenthorizon/dinowm-pusht DINO-WM on frozen DINOv2 ViT-S/14 Push-T expert data, MuJoCo PushT 94.0% (50 tasks)

Each model card gives the recipe, the evaluation protocol and intermediate checkpoints. See the reproduction report for how they compare with the papers.

Comparisons

Models and planners side by side on the same data and tasks, with success rates and their 95% intervals. Results: benchmark results; each model against its paper: reproduction report.

notebook compares
comparisons/main_benchmark LeWM, PLDM, DINO-WM, V-JEPA 2-AC and TD-MPC2
comparisons/frozen_vs_end_to_end frozen DINOv2 and V-JEPA 2.1 encoders against LeJEPA and end-to-end LeWM
comparisons/planners CEM, MPPI and GRASP at several horizons
comparisons/flat_vs_hierarchical LeWM against HWM and H-JEPA on long-horizon tasks

Environment benchmarks

Work with 190 environments: 33 built-in tasks (28 new tasks and five benchmark recipes for the original environments), 13 from OGBench, 52 from the DeepMind Control Suite, Meta-World, ManiSkill and MyoSuite, 50 from RoboCasa and 42 from RoboDojo. Discover the registered tasks with torch_world.envs.list_envs() and create them with make(id): planning puzzles, MuJoCo manipulation and control, Newton articulated dynamics, Isaac Lab robotics, continuous control, musculoskeletal control and kitchen tasks. RoboDojo's dual-arm tasks are evaluated by RoboDojo's own client, which a torch-world policy serves through XPolicyLab. Setup and contributor API.

from torch_world.envs import KeyDoor
from torch_world.benchmarks import run_experiment

world = KeyDoor()
world.show_env()  # initial state and GT
result = run_experiment(world, output_dir="runs/benchmarks")
world.show_success()
world.close()

Adding a model

Subclass JEPA (representation learning) or WorldModel (action-conditioned dynamics) and build it from the shared modules. A WorldModel that implements encode, predict and forward gets rollout, cost and CEM planning with no extra code. See examples/custom_model.ipynb and CONTRIBUTING.md.

Tests

pytest

Releases

Releases follow semantic versioning; before 1.0, a minor version (0.x) may change public APIs, and its release notes say how to migrate. A minor release ships about once a month, or sooner when a model lands; patch releases ship as soon as a fix is merged. Only the latest release gets fixes (see SECURITY.md). The changelog collects the release notes.

To cut a release, a maintainer:

  1. bumps __version__ in torch_world/__init__.py on main, through a pull request;
  2. tags that commit vX.Y.Z (or vX.Y.ZrcN for a pre-release) and pushes the tag.

The release workflow then checks that the tag matches __version__, runs CI, builds the wheel and sdist, publishes them to PyPI by trusted publishing (no stored token, with attestations), creates the GitHub release with generated notes and rebuilds the docs.

Contributors

Contributors

Contributions are welcome: see CONTRIBUTING.md, the Code of Conduct and how the project is governed. Report vulnerabilities privately, as SECURITY.md explains.

Supported by

Latent Horizon

License

Apache 2.0

Metadata

Release files for torch-world 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-world 0.2.1
File Size Uploaded Provenance Actions
torch_world-0.2.1.tar.gz 1.3 MB With provenance Details for torch_world-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-world 0.2.1
File Interpreter ABI Platform Actions
torch_world-0.2.1-py3-none-any.whl Python 3 none any Details for torch_world-0.2.1-py3-none-any.whl

Total release size: 2.7 MB

Release files / torch_world-0.2.1.tar.gz

Download URL torch_world-0.2.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
b6e50d76b10ea99d370a663114bb02030c00123f3c9b0e29471a3def5ac52889
BLAKE2b-256 checksum
How to use checksums
ab31d752549fe3ef2b59372df9e4fc4dcd9c6414e91b69306ab1e98935c1b638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / torch_world-0.2.1-py3-none-any.whl

Download URL torch_world-0.2.1-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c34b2732fb6a7a522cf880c6eb6a9d9f89231b89d969341f604e58d4f8d8297c
BLAKE2b-256 checksum
How to use checksums
6a0106f052833865172d0a5eb60356ab31440743eb8bd3645fcfd8e7b76b1090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for torch-world 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for torch_world-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page