Skip to main content

A Modular Pytorch Based library for training world models

Project description

TorchWM

TorchWM Logo

PyPI version PyPI downloads License: MIT Documentation

Modular PyTorch Library for World Models


⚡ Quick Start

Train Dreamer agents in just 3 lines of code. TorchWM provides a unified interface for training and deploying world models.

Installation

# Core dependencies
pip install torchwm

# With extras
pip install torchwm[gym]       # Additional gym environments
pip install torchwm[ml-agents] # Unity ML-Agents
pip install torchwm[ml]        # TensorBoard, W&B logging
pip install torchwm[viz]       # FastAPI visualization
pip install torchwm[dev]       # Testing and linting

Training a Dreamer Agent

Use the friendly top-level API for the common path:

import torchwm

agent = torchwm.create_model(
    "dreamer",
    env="walker-walk",
    total_steps=1_000_000,
)
agent.train()

The lower-level research modules are still available when you need direct control:

from torchwm import DreamerAgent, DreamerConfig

cfg = DreamerConfig()
cfg.env = "walker-walk"
agent = DreamerAgent(cfg)

Creating Environments and Operators

import torchwm

env = torchwm.make_env("CartPole-v1", backend="gym")
op = torchwm.get_operator("dreamer", image_size=64, action_dim=6)
processed = op.process({"image": image, "action": action})

🚀 Features

  • 🎯 Unified Interface: Consistent API across all world model algorithms
  • 🔧 Modular Components: Swappable encoders, decoders, and backbones
  • 🚀 High Performance: Optimized for both training and inference
  • 🌍 Multi-Environment: Support for DMC, Gym, Unity, and custom environments
  • 📊 Rich Monitoring: Integrated logging with Weights & Biases and TensorBoard
  • 🧠 Research Ready: Easy experimentation with different architectures

🧠 Supported Algorithms

Algorithm Description Key Features
Dreamer Model-based RL with latent dynamics Imagination, actor-critic
JEPA Self-supervised visual representations Masked prediction, ViT
IRIS Sample-efficient RL with Transformers Discrete VAEs, world models
Diamond Diffusion + RL for continuous control EDM sampling, value functions

📖 Documentation

📖 Full Documentation

Get Started

User Guides

Algorithms

🤝 Community


TorchWM is under active development. APIs may change between versions.
:hidden:
:maxdepth: 1
:caption: Get Started

getting_started
installation
:hidden:
:maxdepth: 1
:caption: User Guides

operators_guide
training_guide
inference_guide
environments_guide
package_overview
:hidden:
:maxdepth: 1
:caption: Algorithms

dreamer
jepa
iris
dit
:hidden:
:maxdepth: 1
:caption: Reference

api_reference
configs_reference
:hidden:
:maxdepth: 1
:caption: Development

contributing
benchmarks
:hidden:
:maxdepth: 1
:caption: User Guides

operators_guide
training_guide
inference_guide
environments_guide
package_overview
:hidden:
:maxdepth: 1
:caption: Algorithms

dreamer
jepa
iris
dit
:hidden:
:maxdepth: 1
:caption: Reference

api_reference
configs_reference
:hidden:
:maxdepth: 1
:caption: Development

contributing
benchmarks

⚡ Quick Start

TorchWM provides a unified interface for training and deploying world models.

Installation

pip install torchwm
# or with uv
uv add torch torchvision torchaudio

Training a Dreamer Agent

Use the friendly top-level API for the common path:

import torchwm

agent = torchwm.create_model(
    "dreamer",
    env="walker-walk",
    total_steps=1_000_000,
)
agent.train()

The lower-level research modules are still available when you need direct control:

from torchwm import DreamerAgent, DreamerConfig

cfg = DreamerConfig()
cfg.env = "walker-walk"
agent = DreamerAgent(cfg)

Creating Environments and Operators

import torchwm

env = torchwm.make_env("CartPole-v1", backend="gym")
op = torchwm.get_operator("dreamer", image_size=64, action_dim=6)
processed = op.process({"image": image, "action": action})

Features

  • 🎯 Unified Interface: Consistent API across all world model algorithms
  • 🔧 Modular Components: Swappable encoders, decoders, and backbones
  • 🚀 High Performance: Optimized for both training and inference
  • 🌍 Multi-Environment: Support for DMC, Gym, Unity, and custom environments
  • 📊 Rich Monitoring: Integrated logging with Weights & Biases and TensorBoard
  • 🧠 Research Ready: Easy experimentation with different architectures

🧠 Supported Algorithms

Algorithm Description Key Features
Dreamer Model-based RL with latent dynamics Imagination, actor-critic
JEPA Self-supervised visual representations Masked prediction, ViT
IRIS Sample-efficient RL with Transformers Discrete VAEs, world models
Diamond Diffusion + RL for continuous control EDM sampling, value functions

🤝 Community


TorchWM is under active development. APIs may change between versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchwm-0.4.1.tar.gz (240.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchwm-0.4.1-py3-none-any.whl (251.5 kB view details)

Uploaded Python 3

File details

Details for the file torchwm-0.4.1.tar.gz.

File metadata

  • Download URL: torchwm-0.4.1.tar.gz
  • Upload date:
  • Size: 240.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for torchwm-0.4.1.tar.gz
Algorithm Hash digest
SHA256 6d2af08274bf76b3069e63dcab4ed618d9b02cb67ee2d1ae21b1e67a112821e9
MD5 68dc7672ff9f8c77d9965e877376af85
BLAKE2b-256 c800eb440f416d758614538fda385f94ab96e9eac8fcd8e16a7dbf83f995a66f

See more details on using hashes here.

File details

Details for the file torchwm-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: torchwm-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 251.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for torchwm-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9338350dac0a45e50b952170f2cdd1cd7ea490dfec507500f622eaa3d72ea9e5
MD5 dac6dbe126795d3fee77c2c8f01c1ba2
BLAKE2b-256 2efc64157538e12aadcaa78be7b7cf335241f2ebbff312974c23707dd8d962ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page