Package Overview#
TorchWM is organized into focused modules so you can use only the pieces you need.
Quick Import (Public API)#
For applications and examples, prefer the installed package name, torchwm. It
mirrors the TorchWM implementation package and exposes the same lazy public
API without importing optional training backends until you use them.
import torchwm
print(torchwm.list_models())
agent = torchwm.create_model("dreamer", env="walker-walk", total_steps=1_000_000)
env = torchwm.make_env("CartPole-v1", backend="gym")
op = torchwm.get_operator("dreamer", image_size=64, action_dim=6)
Use torchwm for direct component imports as well as factory helpers:
from torchwm import DreamerAgent, DreamerConfig
cfg = DreamerConfig()
cfg.env = "walker-walk"
agent = DreamerAgent(cfg)
Available Exports#
Category |
Exports |
|---|---|
Friendly factories |
|
Models / Agents |
|
State-space models |
|
Vision |
|
Quantization |
|
Configs |
|
Environments |
|
Memory |
|
Operators |
|
Inference |
|
Reward / Value |
|
Controllers |
|
Transformer blocks |
|
Diffusion |
|
Genie subcomponents |
|
Export |
|
Registry / plugins |
|
Deprecation |
|
Utilities |
|
Example usage:
import torchwm
# Training
agent = torchwm.create_model("dreamer", env="walker-walk", total_steps=1_000_000)
agent.train()
# Inference preprocessing
op = torchwm.get_operator("dreamer", image_size=64, action_dim=6)
processed = op.process({"image": image, "action": action})
Core Modules#
The module paths below are the public torchwm.* surface. They mirror the
internal world_models implementation package one-to-one, so every submodule is
importable either way (from torchwm.models import Dreamer).
torchwm.models: High-level models and agents (Dreamer,DreamerAgent,Planet,JEPAAgent)torchwm.configs: Configuration containers for Dreamer, JEPA, and diffusion runstorchwm.training: Script-style training entrypoints for world models (VAE, MDNRNN, Controller, Planet, RSSM, JEPA)
Environment Integration#
torchwm.envs: DMC, Gym/Gymnasium, Atari, MuJoCo, Unity ML-Agents adapterstorchwm.envs.wrappers: Action repeat, normalization, time limits
World Model Building Blocks#
torchwm.models.dreamer_rssm: Recurrent state-space model used by Dreamertorchwm.models.modular_rssm: Modular RSSM with swappable encoder/decoder/backbone for research experimentstorchwm.vision: Encoders/decoders and action heads for latent dynamics modelstorchwm.reward: Reward and value prediction headstorchwm.observations: Symbolic and visual observation reconstruction modules
Representation Learning and Diffusion#
torchwm.models.vit: Vision Transformer and JEPA predictor componentstorchwm.models.diffusion: DDPM scheduler and DiT model implementationtorchwm.masks: Mask collators for JEPA-style context/target masking
Data and Memory#
torchwm.datasets: CIFAR-10, ImageNet-1K, and genericImageFolderdataset loaderstorchwm.memory: Replay buffers for Dreamer and episode-based memory for PlaNet/RSSM
Utilities#
torchwm.utils: Logging, parameter freezing, transformstorchwm.transforms: Data augmentation pipelinestorchwm.benchmarks: CLI and reporting utilities
Which API Should I Use?#
End-to-end Dreamer training:
DreamerAgentEnd-to-end JEPA training:
JEPAAgentWorld model training scripts:
torchwm.trainingmodules (e.g.,train_world_modelfor VAE+MDNRNN+Controller pipeline)Low-level model experimentation:
Dreamer,RSSM, decoder/encoder modulesCustom world model architectures:
ModularRSSMwith swappable encoder/decoder/backboneCustom data pipelines:
make_cifar10,make_imagenet1k,make_imagefolder