Skip to main content

A Python wrapper for RLtools

Project description

TinyRL

A Python wrapper for RLtools (https://rl.tools). PyTorch is only used for its utils that allow convenient wrapping of C++ code to compile RLtools. The RLtools training code needs to be compiled at runtime because properties like the observation and action dimensions are not known at compile time. One of the fundamental principles of RLtools is that the sizes of all data structures and loops are known at compile-time so that the compiler can maximally reason about the code and heavily optimize it. Hence this wrapper takes an environment (Gymnasium interface) factory function as an input to infer the observation and action shapes and compile a bridge environment that is compatible with RLtools.

This wrapper is work in progress and for now just exposes the SAC training loop and does not allow much modification of hyperparameters etc. yet. Stay tuned.

Installation:

pip install tinyrl

For the following example:

pip install gymnasium

Example:

from tinyrl import loop_sac
import gymnasium as gym

def env_factory():
    return gym.make("Pendulum-v1")

loop = loop_sac(env_factory)

loop_state = loop.LoopState()
loop.init(loop_state, 0)

finished = False
step = 0
while not finished:
    if(step % 100 == 0):
        print(f"Step {step}")
    finished = loop.step(loop_state)
    step += 1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinyrl-0.1.1.tar.gz (123.5 kB view hashes)

Uploaded Source

Built Distribution

tinyrl-0.1.1-py3-none-any.whl (274.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page