Deep Reinforcement Learning with JAX and Equinox.
Project description
Lerax
This is a work in progress implementation of a JAX based reinforcement learning library using Equinox. The main feature is Neural Differential Equation based models. This is meant as a cleaner and more complete continuation of earlier work in this repo NCDE-RL NDEs can be extraordinarily computationally intensive, this library is intended to provide an optimized implementation of NDEs and other RL algorithms using just in time compilation (JIT). Paired with environments that support JIT, high performance is possible using the Anakin architecture for fully GPU based RL.
I'm working on this in my free time, so it may take a while to get to a usable state. I'm also mainly developing this for personal research, so it may not be suitable for all use cases.
Credit
A ton of the code is a slight translation of the code found in the Stable Baselines 3 and Gymnasium libraries which are both under the MIT license. The developers of these excellent libraries have done a great job of creating a solid foundation for reinforcement learning in Python, and I have learned a lot from their code.
In addition, the NDE code is heavily inspired by the work of Patrick Kidger and the entire library is based on his excellent Equinox library along with some use of Diffrax and jaxtyping.
Usage
Installation
Install via pip:
pip install lerax@git+https://github.com/RunnersNum40/lerax.git
Or clone the repo and install in editable mode:
git clone https://github.com/RunnersNum40/lerax.git
cd lerax
pip install -e .
Running an example
python examples/ppo.py
Running TensorBoard
tensorboard --logdir runs
Then open your browser to http://localhost:6006.
Creating your own models and environments
Check out the MLP Actor Critic for a simple example of how to create your own actor critic model. Check out the PPO example for how to use your model in training. Check out the CartPole environment for how to create your own environment. Check out the Gymnasium wrapper for how to wrap Gymnasium environments (this will be slower to run than a fully Jax environment).
TODO
- Optimise for performance under JIT compilation
- Sharding support for distributed training
- Expand policy support beyond Box and Discrete spaces
- Documentation
- Standardize docstring formats
- Write documentation for all public APIs
- Add API to docs when Zensical supports it
- Testing
- Unit testing
- Integration testing
- Full Jaxtyping
- Ensure all functions and classes have proper type annotations
- Use it
- Personal research
- Round out features
- Expand RL variants to include more algorithms
- Create a more comprehensive set of environments
- Brax based environments
- Save and load models
Code Style
This code is written to follow the Equinox's abstract/final pattern for code structure and Black formatting. This is intended to make the code more readable and maintainable, and to ensure that it is consistent with the Equinox library. If you want to contribute, please follow these conventions.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lerax-0.0.2.tar.gz.
File metadata
- Download URL: lerax-0.0.2.tar.gz
- Upload date:
- Size: 52.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3220bb0ac98397582188051376fbf745881c18fea6443f82d6f70bc85751dfca
|
|
| MD5 |
5bfe5fc355353f211a34cfd08f91359f
|
|
| BLAKE2b-256 |
1ceda1108cc9e292ff400f56d981c5855322c7a38aa35dc7144c5a0d2dd30be7
|
Provenance
The following attestation bundles were made for lerax-0.0.2.tar.gz:
Publisher:
release.yml on RunnersNum40/lerax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lerax-0.0.2.tar.gz -
Subject digest:
3220bb0ac98397582188051376fbf745881c18fea6443f82d6f70bc85751dfca - Sigstore transparency entry: 702429436
- Sigstore integration time:
-
Permalink:
RunnersNum40/lerax@28c9f3a7b42f9a4c745dbcdbe475a4229eabe807 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/RunnersNum40
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@28c9f3a7b42f9a4c745dbcdbe475a4229eabe807 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lerax-0.0.2-py3-none-any.whl.
File metadata
- Download URL: lerax-0.0.2-py3-none-any.whl
- Upload date:
- Size: 82.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fac3e2ca265bda5056448df2b805e12f5d8cf9e0af04199b8963aad5b7834fe6
|
|
| MD5 |
0c94131dee68b06024d680a316c97896
|
|
| BLAKE2b-256 |
f781cd9ae7970974a9116f0fbd07c216a4ef7d6f1f246a8866ce07949f1b93f7
|
Provenance
The following attestation bundles were made for lerax-0.0.2-py3-none-any.whl:
Publisher:
release.yml on RunnersNum40/lerax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lerax-0.0.2-py3-none-any.whl -
Subject digest:
fac3e2ca265bda5056448df2b805e12f5d8cf9e0af04199b8963aad5b7834fe6 - Sigstore transparency entry: 702429440
- Sigstore integration time:
-
Permalink:
RunnersNum40/lerax@28c9f3a7b42f9a4c745dbcdbe475a4229eabe807 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/RunnersNum40
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@28c9f3a7b42f9a4c745dbcdbe475a4229eabe807 -
Trigger Event:
push
-
Statement type: