Giter Club home page Giter Club logo

robojax's Introduction

Robojax (WIP)

A high-performance reinforcement learning library in jax specialized for robotic learning. Works out of the box with jax based environments/engines like Gymnax and Brax, as well as non-jax based environments/engines like Mujoco, SAPIEN, MetaWorld etc.

How is it specialized? It includes popular algorithms often used in robotic learning research like PPO and SAC, as well as eventually supporting architectures and workflows often used for visual / 3D RL like transformers, point nets, etc. It further will include more robotics specific approaches such as Transporter Networks (Zeng et al., 2020).

If you use robojax in your work, please cite this repository as so:

@misc{robojax,
  author = {Tao, Stone},
  month = {3},
  title = {{Robojax: Jax based Reinforcement Learning Algorithms and Tools}},
  url = {https://github.com/StoneT2000/robojax},
  year = {2023}
}

Setup

It's highly recommended to use mamba/conda. Otherwise you can try and install all the packages yourself (at your own risk of not getting reproducible results)

conda env create -f environment.yml

Jax must be separately installed. To install jax with cuda support, follow the instructions on their README.

pip install --upgrade "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

Docker

cd docker
docker build -t stonet2000/robojax . 

Organization

The following modules are usually shared between RL algorithms

  • JaxLoop / Environment Loop for collecting rollouts
  • Evaluation Protocol for evaluating agent during training
  • Loggers for logging training and test data
  • Generic Model interface

Everything else is usually kept inside the RL algorithm module e.g. robojax.agents.ppo contains the PPO Config, Actor Critic models, loss functions etc. all separate from e.g. robojax.agents.sac.

General Structure of an Algorithm

Each algorithm/agent comes equipped with a env loop and optionally a eval env loop for training and evaluation. We expect environments used already have truncation and auto reset in them.

During training they sample from the loop for some number of steps then update the policy and repeat.

Creating an instance of a Agent e.g. SAC will initialize a starting train_state and set the configuration. All functionality is completely dependent on only the current train state and the stored configuration.

train

  1. Reset environment, If self.train_state is None, initialize it. Train from there.
  2. Call train_step which returns a new TrainState and TrainStepMetrics structs.
  3. Optionally evaluate model on eval envs (optionally jittable), returning a EvalMetrics struct.
  4. Log TrainStepMetrics and EvalMetrics

train_step

  1. Collect interaction data (optionally jittable)
  2. Update using the interaction data (and potentially older data e.g. in SAC) (jittable)

What's done at thee wrapper level and what's done at the agent level?

TimeLimits and Truncations - Wrapper

Auto Reset - Wrapper

Vectorization - Env looper

Benchmarking

See https://wandb.ai/stonet2000/robojax?workspace=user-stonet2000 for all benchmarked results on this library

To benchmark the code yourself, see https://github.com/StoneT2000/robojax/tree/main/scripts/baselines.md

robojax's People

Contributors

stonet2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

umfundii

robojax's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.