Skip to main content

HELX: The RL experiments framework

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. CI CD GitHub release (latest by date)

Quickstart | Why helx? | Installation | Examples | Cite

What is HELX?

HELX is a JAX-based ecosystem that provides a standardised framework to run Reinforcement Learning experiments. With HELX you easily can:

  • Use the helx.envs namespace to use the most common RL environments (gym, gymnax, dm_env, atari, ...)
  • Use the helx.agents namespace to use the most common RL agents (DQN, PPO, SAC, ...)
  • Use the helx.experiment namespace to run experiments on your local machine, on a cluster, or on the cloud
  • Use the helx.base namespace to access the most common RL data structures and functions (e.g., a Ring buffer)

Why HELX?

HELX is designed to be easy to use, easy to extend, and easy to read.

  • No 2000 lines of code files
  • No multiple inheritance hierarchies where behaviours get lost in the middle
  • No complex abstractions that hide the underlying code

Each namespace provides a single, standardised interface to all agents, environments and experiment runners.

Installation

  • Stable

Install the stable version of helx and its dependencies with:

pip install helx
  • Nightly

Or, if you prefer to install the latest version from source:

pip install git+https://github.com/epignatelli/helx

Examples

A typical use case is to design an agent, and toy-test it on catch before evaluating it on more complex environments, such as atari, procgen or mujoco.

import bsuite
import gym

import helx.environment
import helx.experiment
import helx.agents

# create the enviornment in you favourite way
env = bsuite.load_from_id("catch/0")
# convert it to an helx environment
env = helx.environment.to_helx(env)
# create the agent
hparams = helx.agents.Hparams(env.obs_space(), env.action_space())
agent = helx.agents.Random(hparams)

# run the experiment
helx.experiment.run(env, agent, episodes=100)

Switching to a different environment is as simple as changing the env variable.

import bsuite
import gym

import helx.environment
import helx.experiment
import helx.agents

# create the enviornment in you favourite way
-env = bsuite.load_from_id("catch/0")
+env = gym.make("procgen:procgen-coinrun-v0")
# convert it to an helx environment
env = helx.environment.to_helx(env)
# create the agent
hparams = helx.agents.Hparams(env.obs_space(), env.action_space())
agent = helx.agents.Random(hparams)

# run the experiment
helx.experiment.run(env, agent, episodes=100)

Joining development

Adding a new agent (helx.agents.Agent)

An helx agent interface is designed as the minimal set of functions necessary to (i) interact with an environment and (ii) reinforcement learn.

from typing import Any
from jax import Array

from helx.base import Timestep
from helx.agents import Agent


class NewAgent(helx.agents.Agent):
    """A new RL agent."""
    def create(self, hparams: Any) -> None:
        """Initialises the agent's internal state (knowledge), such as a table,
        or some function parameters, e.g., the parameters of a neural network."""
        # implement me

    def init(self, key: KeyArray, timestep: Timestep) -> None:
        """Initialises the agent's internal state (knowledge), such as a table,
        or some function parameters, e.g., the parameters of a neural network."""
        # implement me

    def sample_action(
        self, agent_state: AgentState, obs: Array, *, key: KeyArray, eval: bool = False
    ):
        """Applies the agent's policy to the current timestep to sample an action."""
        # implement me

    def update(self, timestep: Timestep) -> Any:
        """Updates the agent's internal state (knowledge), such as a table,
        or some function parameters, e.g., the parameters of a neural network."""
        # implement me

Adding a new environment library (helx.environment.Environment)

To add a new library requires three steps:

  1. Implement the helx.environment.Environment interface for the new library. See the dm_env implementation for an example.
  2. Implement serialisation (to helx) of the following objects:
    • helx.environment.Timestep
    • helx.spaces.Discrete
    • helx.spaces.Continuous
  3. Add the new library to the helx.environment.to_helx function to tell helx about the new protocol.

Cite

If you use helx please consider citing it as:

@misc{helx,
  author = {Pignatelli, Eduardo},
  title = {Helx: Interoperating between Reinforcement Learning Experimental Protocols},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/epignatelli/helx}}
  }

A note on maintainance

This repository was born as the recipient of personal research code that was developed over the years. Its maintainance is limited by the time and the resources of a research project resourced with a single person. Even if I would like to automate many actions, I do not have the time to maintain the whole body of automation that a well maintained package deserves. This is the reason of the WIP badge, which I do not plan to remove soon. Maintainance will prioritise the code functionality over documentation and automation.

Any help is very welcome. A quick guide to interacting with this repository:

  • If you find a bug, please open an issue, and I will fix it as soon as I can.
  • If you want to request a new feature, please open an issue, and I will consider it as soon as I can.
  • If you want to contribute yourself, please open an issue first, let's discuss objective, plan a proposal, and open a pull request to act on it.

If you would like to be involved further in the development of this repository, please contact me directly at: edu dot pignatelli at gmail dot com.

Release files for HELX 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for HELX 1.1.5
File Size Uploaded
HELX-1.1.5.tar.gz 39.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for HELX 1.1.5
File Interpreter ABI Platform
HELX-1.1.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 92.1 kB

Release files / HELX-1.1.5.tar.gz

Download URL HELX-1.1.5.tar.gz
Size 39.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cab33f3d3790f29d9cc0038e302f70a008c863f6f7e59efff5cef4c0d3181143
BLAKE2b-256 checksum
How to use checksums
fa1298fdf10659be20c357c4f468927fe51fc82d9ff94fee3cc2503a818b24fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / HELX-1.1.5-py2.py3-none-any.whl

Download URL HELX-1.1.5-py2.py3-none-any.whl
Size 52.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9a76a3c74efc08ce67702c6a69b0ff994482fa7957bdd644bd9e14017ee164a7
BLAKE2b-256 checksum
How to use checksums
20bc2b5f880af4042a4fd351ae662773d57bed93e2722664c04fd3f70eb2b6d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page