Skip to main content

LocoFormer

Project description

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)

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},
}

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

locoformer-0.2.4.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

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

locoformer-0.2.4-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file locoformer-0.2.4.tar.gz.

File metadata

  • Download URL: locoformer-0.2.4.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for locoformer-0.2.4.tar.gz
Algorithm Hash digest
SHA256 a232fce64498f6ac4b4c163edef3fe2f16485f0c74b064675ff054482856be17
MD5 97fa35e1c3e6411ccbe23d5aff2a8a05
BLAKE2b-256 926cef2105be3fd45cb261b222b037d6bfbc4e8fee39f0deec0b72b2339acb30

See more details on using hashes here.

File details

Details for the file locoformer-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: locoformer-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for locoformer-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cd08261bf55da84fde34dcf2eaba76a4ac33feff9e98b8f6f5e046ecfaa7e901
MD5 7429bca53a4b085b5f964245a01deedf
BLAKE2b-256 24e56fc63b4ff2b6a70e6636c0e703bf4c1c736d699b41221f90bf1f90e77e93

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