Trajectory World Models for Heterogeneous Environments

Shaofeng Yin, Jialong Wu, Siqiao Huang, Xingjian Su, Xu He, Jianye Hao, Mingsheng Long · DOI

Abstract

In reinforcement learning (RL), world models serve as learned simulators that enable agents to anticipate the consequences of their actions. However, traditional world models are typically trained from scratch for specific robotic platforms, limiting their ability to generalize across different morphologies. This paper introduces TrajWorld, a foundation world model designed to handle heterogeneous environments. By representing trajectory data as a 2D grid of scalars and utilizing a dual-axis attention mechanism, TrajWorld enables zero-shot and few-shot transfer across diverse robotic systems. Pre-trained on the massive UniTraj dataset, the model demonstrates state-of-the-art performance in dynamics prediction, off-policy evaluation, and model-based control.

Introduction

The success of foundation models in natural language processing and computer vision has largely been driven by the ability to train on massive, diverse datasets. In contrast, world models for robotic control have remained largely specialized. A model trained for a quadruped is typically incompatible with a humanoid due to differences in state and action dimensions—a challenge known as structural heterogeneity.

TrajWorld addresses this gap by shifting the focus from high-dimensional vector representations to a granular, scalar-based approach. This allows the model to learn the fundamental "language of physics" that remains consistent across different robot bodies, facilitating a more generalizable approach to sequence modeling in control tasks.

The Challenge of Heterogeneity

In standard RL benchmarks, a robot's state is represented as a vector (e.g., joint positions and velocities). Because different robots have different numbers of joints, these vectors vary in length. Previous attempts to bridge this gap often relied on zero-padding vectors to a fixed maximum size. However, this approach is inefficient and frequently results in "negative transfer," where the inclusion of diverse data actually degrades the model's performance on specific tasks. TrajWorld avoids these pitfalls by rethinking how trajectory data is structured and processed.

Methodology

1. Scalarization and Discretization

TrajWorld decomposes high-dimensional state and action vectors into individual scalars. Each scalar is then discretized into categorical bins. This transformation treats a trajectory as a 2D grid where one axis represents time and the other represents individual variables (variates). The core insight is that while a 17-dimensional vector for a Walker and a 6-dimensional vector for a Reacher are structurally different, the underlying physics governing a single joint torque or velocity scalar are shared across platforms.

2. Dual-Axis (2D) Attention

To process this 2D grid, TrajWorld employs an interleaved attention mechanism:

  • Temporal Attention: This mechanism captures how a specific variable evolves over time, modeling the temporal dynamics of individual components.
  • Variate Attention: This mechanism captures the dependencies between different variables at a single timestep, such as how a specific motor torque influences the velocity of a connected joint.

This 2D approach is more computationally efficient than standard 1D transformers for long sequences and allows the model to learn complex inter-variable relationships more effectively.

3. In-Context Learning

TrajWorld does not require explicit environment identifiers. Instead, it utilizes in-context learning: by observing a short history of transitions, the model implicitly infers the dynamics and physical properties of the current environment. This allows the model to adapt to new, unseen robots on the fly.

Experimental Framework

The UniTraj Dataset

To support large-scale pre-training, the authors curated UniTraj, a unified trajectory dataset comprising over 1.3 million trajectories (approximately 719 million steps). The dataset aggregates 80 distinct environments from six major sources, including ExORL, RL Unplugged, and TD-MPC2. To evaluate generalization, standard benchmarks like HalfCheetah, Hopper, and Walker2D were held out during pre-training.

Key Results

Transition Prediction

When fine-tuned on downstream tasks, TrajWorld achieved significantly lower Mean Absolute Error (MAE) in state prediction compared to models trained from scratch. It consistently outperformed 1D transformer baselines (TDM) and traditional MLP ensembles, demonstrating the benefits of its pre-trained physical priors.

Off-Policy Evaluation (OPE)

TrajWorld set a new state-of-the-art on the DOPE benchmark. The model's ability to accurately simulate trajectories allowed for more precise estimation of policy values using only offline data, which is critical for safety-sensitive applications where real-world testing is expensive or dangerous.

Model Predictive Control (MPC)

In practical control scenarios, TrajWorld served as a highly effective simulator for planning. It led to higher episode returns in "fragile" environments like Hopper, where precise physics modeling is essential to prevent the agent from losing balance. Furthermore, the model demonstrated zero-shot capabilities, successfully predicting the movement of novel configurations (e.g., a "Cart-2-Pole" system) it had never encountered during training.

Limitations and Future Work

While TrajWorld represents a significant step toward foundation models for control, it has limitations. The use of discretization means the model may struggle to predict values outside the ranges seen during training. Additionally, the 2D attention mechanism, while more efficient than some alternatives, remains more computationally intensive than simple MLP-based models. Future research will focus on integrating visual (camera) data with proprioceptive sensors to create multimodal world models capable of handling more complex manipulation and navigation tasks.

Summary updated

BibTeX
@inproceedings{yin2025trajectory,
  author = {Shaofeng Yin and Jialong Wu and Siqiao Huang and Xingjian Su and Xu He and Jianye Hao and Mingsheng Long},
  title = {{Trajectory World Models for Heterogeneous Environments}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Py2KmXaRmi},
}
Figure