LocoFormer (wip)
LocoFormer - Generalist Locomotion via Long-Context Adaptation
The gist is they trained a simple Transformer-XL in simulation on robots with many different bodies (cross-embodiment) and extreme domain randomization. When transferring to the real-world, they noticed the robot now gains the ability to adapt to insults. The XL memories span across multiple trials, which allowed the robot to learn in-context adaptation.
Install
$ pip install locoformer
Usage
import torch
from locoformer.locoformer import Locoformer
# mock robot embodied with some state dimensions and action dimensions
locoformer = Locoformer(
embedder = dict(
dim = 512,
dim_state = [32, 16], # support multiple bodies / robots
),
unembedder = dict(
num_continuous = 12 + 6,
selectors = [
list(range(12)),
list(range(12, 12 + 6))
]
),
transformer = dict(
dim = 512,
depth = 6,
heads = 8,
window_size = 32
)
)
# mock state from one of the robots (0th one)
state = torch.randn(1, 1, 32)
# forward to get action logits
action_logits, _ = locoformer(
state,
state_embed_kwargs = dict(state_type = 'raw'),
state_id_kwarg = dict(state_id = 0),
action_select_kwargs = dict(selector_index = 0)
)
# sample action using the internal distribution
action = locoformer.unembedder.sample(action_logits, selector_index = 0) # (1, 1, 12)
Sim-to-Real Bipedal Locomotion (Microduck)
You can train an adaptive bipedal walking gait for the Microduck biped robot from scratch using Locoformer and PPO
An emergent bipedal walking gait starts emerging before 2M steps
$ uv run train_microduck.py
To render periodic evaluation videos or resume from the saved best checkpoint:
# render periodic evaluation videos to videos/
$ uv run train_microduck.py --eval_video True --eval_every 20
# resume training from best checkpoint
$ uv run train_microduck.py --resume True
Special thanks to Pollen Robotics 🤗 for their open sourcing of this sim2real env!
Sponsors
This open sourced work is sponsored by Safe Sentinel
Citations
@article{liu2025locoformer,
title = {LocoFormer: Generalist Locomotion via Long-Context Adaptation},
author = {Liu, Min and Pathak, Deepak and Agarwal, Ananye},
journal = {Conference on Robot Learning ({CoRL})},
year = {2025}
}
@inproceedings{anonymous2025flow,
title = {Flow Policy Gradients for Legged Robots},
author = {Anonymous},
booktitle = {Submitted to The Fourteenth International Conference on Learning Representations},
year = {2025},
url = {https://openreview.net/forum?id=BA6n0nmagi},
note = {under review}
}
@misc{ashlag2025stateentropyregularizationrobust,
title = {State Entropy Regularization for Robust Reinforcement Learning},
author = {Yonatan Ashlag and Uri Koren and Mirco Mutti and Esther Derman and Pierre-Luc Bacon and Shie Mannor},
year = {2025},
eprint = {2506.07085},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2506.07085},
}
@misc{osband2026delightfulpolicygradient,
title = {Delightful Policy Gradient},
author = {Ian Osband},
year = {2026},
eprint = {2603.14608},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2603.14608},
}
@misc{schwarzer2021dataefficientreinforcementlearningselfpredictive,
title = {Data-Efficient Reinforcement Learning with Self-Predictive Representations},
author = {Max Schwarzer and Ankesh Anand and Rishab Goel and R Devon Hjelm and Aaron Courville and Philip Bachman},
year = {2021},
eprint = {2007.05929},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2007.05929},
}
@misc{teoh2026nextlatentpredictiontransformerslearn,
title = {Next-Latent Prediction Transformers Learn Compact World Models},
author = {Jayden Teoh and Manan Tomar and Kwangjun Ahn and Edward S. Hu and Tim Pearce and Pratyusha Sharma and Akshay Krishnamurthy and Riashat Islam and Alex Lamb and John Langford},
year = {2026},
eprint = {2511.05963},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2511.05963},
}
Metadata
Release files for locoformer 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| locoformer-0.4.0.tar.gz | 28.4 kB | Without provenance | Details for locoformer-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| locoformer-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for locoformer-0.4.0-py3-none-any.whl |
Total release size: 56.0 kB
Release files / locoformer-0.4.0.tar.gz
| Download URL | locoformer-0.4.0.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
322d65fd99fba32fc830debbc4cd013977f4e0c2655f1df11829fb76fd706c53
|
|
BLAKE2b-256 checksum How to use checksums |
019790cda8a14ec0b9f1d6552cbde5147db05b18231be0ae18949a2cd89b4896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / locoformer-0.4.0-py3-none-any.whl
| Download URL | locoformer-0.4.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4f3d30b3e0a0ab354daf9eb50c4ccc080ee4ce24a2b3a3c284d51ec10c0e2d4
|
|
BLAKE2b-256 checksum How to use checksums |
7feca2f6e64c042c65b79ce6976fb335dfed651ba0c939848c278fc774e90a0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for locoformer 0.4.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.