A lightweight utility library for reinforcement learning projects in JAX and Equinox.
Project description
JymKit: A Lightweight Utility Library for JAX-based RL Projects
JymKit lets you
- 🕹️ Import your favourite environments from various libraries with a single API and automatically wrap them to a common standard.
- 🚀 Bootstrap new JAX RL projects with a single CLI command and get started instantly with a complete codebase.
- 🤖 JymKit comes equiped with standard general RL implementations based on a near-single-file philosophy. You can either import these as off-the-shelf algorithms or copy over the code and tweak them for your problem. These algorithms follow the ideas of PureJaxRL for extremely fast end-to-end RL training in JAX.
📖 More details over at the Documentation
🚀 Getting started
JymKit lets you bootstrap your new reinforcement learning projects directly from the command line. As such, for new projects, the easiest way to get started is via uv:
uvx jymkit <projectname> uv run example_train.py # ... or via pipx pipx run jymkit <projectname> # activate a virtual environment in your preferred way, e.g. conda python example_train.py
This will set up a Python project folder structure with (optionally) an environment template and (optionally) algorithm code for you to tailor to your problem.
For existing projects, you can simply install JymKit via pip and import the required functionality.
pip install jymkit
import jax import jymkit as jym from jymkit.algorithms import PPO env = jym.make("CartPole") env = jymkit.LogWrapper(env) rng = jax.random.PRNGKey(0) agent = PPO(total_timesteps=5e5, learning_rate=2.5e-3) agent = agent.train(rng, env)
🏠 Environments
JymKit is not aimed at delivering a full environment suite. However, it does come equipped with a jym.make(...) command to import environments from existing suites (provided that these are installed) and wrap them appropriately to the JymKit API standard. For example, using environments from Gymnax:
import jymkit as jym
from jymkit.algorithms import PPO
import jax
env = jym.make("Breakout-MinAtar")
env = jym.FlattenObservationWrapper(env)
env = jym.LogWrapper(env)
agent = PPO(**some_good_hyperparameters)
agent = agent.train(jax.random.PRNGKey(0), env)
# > Using an environment from Gymnax via gymnax.make(Breakout-MinAtar).
# > Wrapping Gymnax environment with GymnaxWrapper
# > Disable this behavior by passing wrapper=False
# > Wrapping environment in VecEnvWrapper
# > ... training results
For convenience, JymKit does include the 5 classic-control environments.
Currently, importing from external libraries is possible for Gymnax and Brax. More are coming up!
Environment API
The JymKit API stays close to the somewhat established Gymnax API for the reset() and step() functions, but allows for truncated episodes in a manner closer to Gymnasium.
env = jym.make(...)
obs, env_state = env.reset(key) # <-- Mirroring Gymnax
# env.step(): Gymnasium Timestep tuple with state information
(obs, reward, terminated, truncated, info), env_state = env.step(key, state, action)
🤖 Algorithms
Algorithms in jymkit.algorithms are built following a near-single-file implementation philosophy in mind. In contrast to implementations in CleanRL or PureJaxRL, JymKit algorithms are built in Equinox and follow a class-based design with a familiar Stable-Baselines API.
Each algorithm supports both discrete- and continuous action/observation space -- adjusting based on the provided environment observation_space and action_space. Additionally, the implementations support multi-agent environments out of the box.
from jymkit.algorithms import PPO
import jax
env = ...
agent = PPO(**some_good_hyperparameters)
agent = agent.train(jax.random.PRNGKey(0), env)
Currently, only a
PPOimplementation is implemented. More will be included in the near future. However, the current goal is not to include as many algorithms as possible.
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 jymkit-0.0.10.tar.gz.
File metadata
- Download URL: jymkit-0.0.10.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea1d28a29059ea2244f46642bf09e1aa0bc3c8206523ff52c6720a931b611eac
|
|
| MD5 |
faa6409231ca18041f9dafd8d6b5a695
|
|
| BLAKE2b-256 |
caf292292e8d039798a94457788f6adbd5dc1eac1ad936ad24ee227c59e8745f
|
File details
Details for the file jymkit-0.0.10-py3-none-any.whl.
File metadata
- Download URL: jymkit-0.0.10-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5a58a0309268609d34200c031e06a3947d697061b2d35cbac9712ef20e1a907
|
|
| MD5 |
d2024b61f8241c61c2bbb664131ef84e
|
|
| BLAKE2b-256 |
99a11b09b639a108aaa58796a8472368144d190c0d7b0626d0b3f0b1d7031900
|