LocoFormer: Generalist Locomotion via Long-context Adaptation

Min Liu, Deepak Pathak, Ananye Agarwal

TL;DR

LocoFormer is a generalist foundation model for robot locomotion capable of controlling completely unseen legged and wheeled robots zero-shot. By combining massive-scale reinforcement learning on procedurally generated robots with a long-context Transformer-XL architecture, the model exhibits emergent, multi-episodic adaptation—allowing it to recover from extreme real-world physical alterations like locked joints, added stilts, or amputated limbs within seconds.

What Problem Does This Paper Address?

Traditional robotic locomotion controllers are "specialists." They are meticulously tuned for a specific robot morphology and rely on short context windows (typically a few hundred milliseconds) to handle minor environmental variations. Consequently, these myopic policies fail catastrophically when faced with major out-of-distribution (OOD) changes, such as a motor burning out, a limb breaking, or being deployed on an entirely new robot body.

To bridge this sim2real gap, engineers usually have to perform painstaking system identification for every single robot variant. LocoFormer aims to replace these fragmented, specialist controllers with a single, generalist "omni-bodied" locomotion model that can adapt to drastic morphological and dynamic changes on the fly without explicit prior knowledge of the robot's kinematics.

Methods

LocoFormer achieves its generality through two main pillars:

  1. Massive-Scale Procedural Pre-training: Instead of training on specific commercial robots, the authors train the policy using Proximal Policy Optimization (PPO) across a massive, randomized space of procedurally generated robots (including bipeds, quadrupeds, and wheeled variants). They apply aggressive domain randomization to physical attributes like mass, inertia, and joint limits.
  2. Long-Context Architecture (Transformer-XL): While prior policies only remember the last fraction of a second, LocoFormer utilizes a Transformer-XL backbone to extend the policy's memory by orders of magnitude (~18 seconds of history at 50 Hz). Crucially, this memory persists across trial boundaries within an episode, allowing the robot to learn from its own mistakes (e.g., a fall) in subsequent attempts.

To make real-time deployment computationally feasible, the policy maps observations to a unified joint space (a superset that subsumes most contemporary robot configurations) and leverages KV-caching to reduce the Transformer's inference complexity from quadratic to linear.

Figure 1: We propose LocoFormer: a generalist omni-bodied locomotion model that transfers zero-shot to any kind of robot body, whether completely different form-factor or bodily changes due to damaged limbs, without even training on them (top two rows). The key innovation is long-term multi-episodic adaptation trained with massively large-scale reinforcement learning – this allows generalization to a variety of real robots by just training on randomly generated procedural robots (bottom row). We see emergent adaptation behavior across very long contexts and even few-shot multi-episodic adaptation across a handful of trials where LocoFormer uses suboptimal initial rollouts to improve in subsequent ones. Videos are at generalist-locomotion.github.io.

Datasets

The model does not rely on a static dataset. Instead, it is trained on a procedurally generated task space in simulation consisting of over 100,000 randomized robot morphologies.

For evaluation, the authors tested the model on 10 previously unseen robots across simulation and reality, including:

  • Bipeds/Humanoids: Unitree G1, H1, Fourier GR1, LimX Dynamics TRON1, Berkeley Humanoid BK-H.
  • Quadrupeds: Unitree A1, Go2, Boston Dynamics Spot, ETH AnyMal C.
  • Wheeled Robots: TRON1-W, Unitree Go2-W.

Key Insights and Ideas

  • In-Context Learning for Control: Much like how large language models (LLMs) use long contexts to adapt to new tasks at test time without weight updates, LocoFormer uses its long history to perform implicit "system identification" online.
  • Emergent Multi-Episodic Adaptation: Because the context window spans across trial boundaries, the model displays an ability to learn from failure. If a robot falls in Trial 1 due to an unseen physical constraint, it utilizes that failure data to adjust its gait and walk successfully in Trial 2 or 3.
  • Dynamic Internal Representations: By analyzing the internal activations of the Transformer layers, the authors found that the model's embeddings naturally diverge over time into distinct clusters corresponding to specific robot types. The model dynamically builds an internal model of the robot's body without ever being given explicit structural descriptors.
Temporal evolution showing internal representations clustering into distinct embodiments over 5 seconds.

Key Results

  • Near-Expert Performance: In simulation benchmarks across 1,000 randomized environments, LocoFormer achieved an average normalized displacement score of 0.96 (zero-shot) and 0.98 (few-shot), nearly matching the performance of dedicated "expert" policies (0.99) trained specifically on individual robots, while vastly outperforming standard GRU baselines (0.37).
  • Extreme Real-World Robustness: When deployed zero-shot on real hardware, a single LocoFormer model successfully adapted to severe physical trauma and modifications:
  • Leg Locking & Amputation: When a quadruped's knee was locked or its lower leg was physically cut off, it adapted within seconds to walk using a stable three-legged or knee-walking gait.
  • Morphological Shifts: The model successfully controlled a quadruped forced to walk on elongated wooden stilts, adjusting its foot placement and step timing dynamically.
  • Propulsion Changes: When a wheeled quadruped's wheels were programmatically locked, it immediately switched from a rolling gait to a walking gait.
Real-world deployment showcasing zero-shot adaptation to locked wheels, stilts, and amputated limbs.

Limitations and Future Work

  • Compute Intensity: Training a generalist model across 100k robots with a large Transformer architecture is incredibly resource-intensive, requiring roughly 500 times more compute than training a single specialist policy.
  • Hand-Crafted Procedural Generation: The space of training robots was procedurally generated using human-designed heuristics. The authors suggest that future iterations could leverage LLMs to automate and infinitely scale the diversity of the training morphologies.

Summary updated

BibTeX
@inproceedings{liu2025locoformer,
  author = {Min Liu and Deepak Pathak and Ananye Agarwal},
  title = {{LocoFormer: Generalist Locomotion via Long-context Adaptation}},
  booktitle = {Conference on Robot Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=VqmAvBkFhw},
}
Figure