rl-blox

Modular JAX-based toolbox for implementing RL algorithms.

https://github.com/mlaux1/rl-blox

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.1%) to scientific vocabulary

Keywords

algorithms jax reinforcement-learning
Last synced: 4 months ago · JSON representation ·

Repository

Modular JAX-based toolbox for implementing RL algorithms.

Basic Info
Statistics
  • Stars: 15
  • Watchers: 3
  • Forks: 4
  • Open Issues: 37
  • Releases: 4
Topics
algorithms jax reinforcement-learning
Created over 2 years ago · Last pushed 5 months ago
Metadata Files
Readme License Citation

README.md

Tests Code style: black pre-commit DOI

RL-BLOX

This project contains modular implementations of various model-free and model-based RL algorithms and consists of deep neural network-based as well as tabular representation of Q-Values, policies, etc. which can be used interchangeably. The goal of this project is for the authors to learn by reimplementing various RL algorithms and to eventually provide an algorithmic toolbox for research purposes.

[!CAUTION] This library is still experimental and under development. Using it may lead to experiencing bugs or changing interfaces. If you encounter any bugs or other issues, please let us know via the issue tracker. If you are an RL developer and want to collaborate, feel free to contact us.

Design Principles

The implementation of this project follows the following principles:

  1. Algorithms are functions!
  2. Algorithms are implemented in single files.
  3. Policies and values functions are data containers.

Dependencies

  1. Our environment interface is Gymnasium.
  2. We use JAX for everything.
  3. We use Chex to write reliable code.
  4. For optimization algorithms we use Optax.
  5. For probability distributions we use TensorFlow Probability.
  6. For all neural networks we use Flax NNX.
  7. To save checkpoints we use Orbax.

Installation

Install via PyPI

The easiest way to install is via PyPI: bash pip install rl-blox

Install from source

Alternatively, e.g. if you want to develop extensions for the library, you can also install rl-blox from source:

bash git clone git@github.com:mlaux1/rl-blox.git

After cloning the repository, it is recommended to install the library in editable mode.

bash pip install -e .

Optional dependencies

To be able to run the provided examples use pip install 'rl-blox[examples]'.

To install development dependencies, please use pip install 'rl-blox[dev]'.

To enable logging with aim, please use pip install 'rl_blox[logging]'

You can install all optional dependencies (except logging) using pip install 'rl_blox[all]'.

Algorithm Implementations

We currently provide implementations of the following algorithms (ordered from SotA to classic RL algorithms): MR.Q, TD7, TD3+LAP, PE-TS, SAC, TD3, DDPG, DDQN, DQN, double Q-learning, CMA-ES, Dyna-Q, actor-critic, REINFORCE, Q-learning, MC.

Getting Started

RL-BLOX relies on gymnasium's environment interface. This is an example with the SAC RL algorithm.

```python import gymnasium as gym

from rlblox.algorithm.sac import createsacstate, trainsac from rlblox.logging.checkpointer import OrbaxCheckpointer from rlblox.logging.logger import AIMLogger, LoggerList

envname = "Pendulum-v1" env = gym.make(envname) seed = 1 verbose = 1 env = gym.wrappers.RecordEpisodeStatistics(env)

hparamsmodels = dict( policyhiddennodes=[128, 128], policylearningrate=3e-4, qhiddennodes=[512, 512], qlearningrate=1e-3, seed=seed, ) hparamsalgorithm = dict( totaltimesteps=11000, buffersize=11000, gamma=0.99, learningstarts=5000, )

if verbose: print( "This example uses the AIM logger. You will not see any output on " "stdout. Run 'aim up' to analyze the progress." ) checkpointer = OrbaxCheckpointer("/tmp/rl-blox/sacexample/", verbose=verbose) logger = LoggerList([ AIMLogger(), # uncomment to store checkpoints # checkpointer, ]) logger.defineexperiment( envname=envname, algorithmname="SAC", hparams=hparamsmodels | hparamsalgorithm, ) logger.definecheckpointfrequency("policy", 1000)

sacstate = createsacstate(env, **hparamsmodels) sacresult = trainsac( env, sacstate.policy, sacstate.policyoptimizer, sacstate.q, sacstate.qoptimizer, logger=logger, **hparamsalgorithm, ) env.close() policy, _, q, _, _, _, _ = sacresult

Do something with the trained policy...

```

API Documentation

You can build the sphinx documentation with

bash pip install -e '.[doc]' cd doc make html

The HTML documentation will be available under doc/build/html/index.html.

Contributing

If you wish to report bugs, please use the issue tracker. If you would like to contribute to RL-BLOX, just open an issue or a pull request. The target branch for merge requests is the development branch. The development branch will be merged to master for new releases. If you have questions about the software, you should ask them in the discussion section.

The recommended workflow to add a new feature, add documentation, or fix a bug is the following:

  • Push your changes to a branch (e.g. feature/x, doc/y, or fix/z) of your fork of the RL-BLOX repository.
  • Open a pull request to the main branch.

It is forbidden to directly push to the main branch.

Testing

Run the tests with

bash pip install -e '.[dev]' pytest

Releases

Semantic Versioning

Semantic versioning must be used, that is, the major version number will be incremented when the API changes in a backwards incompatible way, the minor version will be incremented when new functionality is added in a backwards compatible manner, and the patch version is incremented for bugfixes, documentation, etc.

Funding

This library is currently developed at the Robotics Group of the University of Bremen together with the Robotics Innovation Center of the German Research Center for Artificial Intelligence (DFKI) in Bremen.

Owner

  • Name: Melvin Laux
  • Login: mlaux1
  • Kind: user
  • Location: Bremen
  • Company: University of Bremen

Researcher @ AG Robotik at University of Bremen

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Laux"
  given-names: "Melvin"
  orcid: "https://orcid.org/0000-0003-3517-7386"
- family-names: "Fabisch"
  given-names: "Alexander"
  orcid: "https://orcid.org/0000-0003-2824-7956"
title: "RL-BLOX"
version: 0.4.4
doi: 10.5281/zenodo.15746631
date-released: 2025-06-26
url: "https://github.com/mlaux1/rl-blox"

GitHub Events

Total
  • Create event: 50
  • Release event: 2
  • Issues event: 59
  • Watch event: 6
  • Delete event: 45
  • Issue comment event: 50
  • Push event: 348
  • Public event: 1
  • Pull request review comment event: 48
  • Pull request event: 84
  • Pull request review event: 82
  • Fork event: 3
Last Year
  • Create event: 50
  • Release event: 2
  • Issues event: 59
  • Watch event: 6
  • Delete event: 45
  • Issue comment event: 50
  • Push event: 348
  • Public event: 1
  • Pull request review comment event: 48
  • Pull request event: 84
  • Pull request review event: 82
  • Fork event: 3

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 44
  • Total pull requests: 53
  • Average time to close issues: 3 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 3
  • Total pull request authors: 3
  • Average comments per issue: 0.68
  • Average comments per pull request: 0.38
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 40
  • Pull requests: 53
  • Average time to close issues: 25 days
  • Average time to close pull requests: 8 days
  • Issue authors: 3
  • Pull request authors: 3
  • Average comments per issue: 0.7
  • Average comments per pull request: 0.38
  • Merged pull requests: 37
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • mlaux1 (24)
  • AlexanderFabisch (19)
  • Agandaur55 (1)
Pull Request Authors
  • AlexanderFabisch (35)
  • mlaux1 (16)
  • smandic5 (1)
Top Labels
Issue Labels
new-algorithm (10) interface (10) bug (8) test (4) discussion (3) jax-flax (3) easy (2) documentation (1) refactor (1) dependency (1)
Pull Request Labels
bug (2) new-algorithm (2) interface (1) dependency (1) documentation (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 262 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
pypi.org: rl-blox

Modular RL building blocks in JAX

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 262 Last month
Rankings
Dependent packages count: 8.7%
Average: 29.0%
Dependent repos count: 49.3%
Maintainers (1)
Last synced: 4 months ago

Dependencies

pyproject.toml pypi
  • aim *
  • chex *
  • distrax *
  • flax *
  • gymnasium *
  • jax *
  • jaxlib *
  • numpy *
  • optax *
  • orbax *
  • tqdm *
requirements.txt pypi
  • chex *
  • distrax *
  • flax *
  • gymnasium *
  • jax *
  • jaxlib *
  • matplotlib *
  • numpy *
  • optax *
  • pre-commit *
  • tqdm *