Skip to main content

Fast reinforcement learning 💨

Project description

flashrl

RL in seconds 💨 with ~200 lines of code (+ ~150 per env) 🤓

🛠️ pip install flashrl, or if you want to modify envs, clone the repo and pip install -r requirements.txt

Quick Start 🚀

  1. If installed via clone, compile envs: python setup.py build_ext --inplace
  2. Train: python train.py
  3. See the magic unfold in the terminal 🪄

Usage 💡

flashrl will always be short: Read the code (+paste into ChatGPT) to understand it!

Here's a minimal example to get you going:

flashrl uses a Learner that holds an env and a model (default: LSTMPolicy)

import flashrl as frl

learn = frl.Learner(env=frl.envs.Pong(n_agents=2**14))
curves = learn.fit(40, steps=16, pbar_desc='done')
frl.print_ascii_curve(curves['loss'], label='loss')
frl.render_ascii(learn, fps=10)
learn.env.close()

.fit triggers RL with

  • 40 iterations...
  • ...16 steps per iteration...
  • ...in Pong holding 2**14=16384 agents

resulting in training with (40 * 16 * 16384=)~10 million steps!

Click here, to read a tiny doc 📑

.fit takes the arguments

  • iters: Number of iterations
  • steps: Number of steps in rollout
  • pbar_desc: Progress bar description (default: 'reward')
  • log: If True, tensorboard logging is enabled
    • run tensorboard --logdir=runsand visit http://localhost:6006 in the browser!
  • lr, anneal_lr, target_fl + all args of ppo: Hyperparameters

Take a look at train.py to see how to use the utils-functions

  • print_ascii_curve: Visualizes the loss across the iters
  • render_ascii: Shows data of the last rollout in the terminal
  • render_gif: Shows the same, saved as a GIF
  • print_table: Shows a table of values, acts, logprobs, reward and dones of the last rollout

Environments 🕹️

Each env is one Cython(=.pyx) file in flashrl/envs. That's it!

To add custom envs, use grid.pyx, pong.pyx or multigrid.pyx as a template:

  • grid.pyx for single-agent envs
  • pong.pyx for 1 vs. 1 agent envs (AlphaZero-style)
  • multigrid.pyx for multi-agent envs
Grid Pong MultiGrid
Agent must reach goal grid Good old pong (1 vs. 1) pong Agent must reach goal first multigrid

Acknowledgements 🙌

I want to thank

and last but not least...

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

flashrl-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

flashrl-0.1.0-cp313-cp313-musllinux_1_2_i686.whl (1.7 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

flashrl-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

flashrl-0.1.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

flashrl-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

flashrl-0.1.0-cp312-cp312-musllinux_1_2_i686.whl (1.7 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

flashrl-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

flashrl-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

flashrl-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

flashrl-0.1.0-cp310-cp310-musllinux_1_2_i686.whl (1.5 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ i686

flashrl-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

flashrl-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

File details

Details for the file flashrl-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 438ee473d3da7d2e94388aee5ebd69a151e8a758496ddd32b6fdcca6e10b8b34
MD5 18ffd9d30324fd8854d06d1517395e20
BLAKE2b-256 06ab1087e20fc51b20bcc350b0966eb3d6d3fdd94ce0389cd6dce3d0436e83ef

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp313-cp313-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.13, musllinux: musl 1.2+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 2b369071f534c62f082dd6373c2b52be7590ceb76456db73fe914c60a0bbd763
MD5 345240fbf118348118347efe399dd2d8
BLAKE2b-256 6515e3671044bdb7b87f20478fe259c6601f786a4cc3cf5a1cb7de95c518146b

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c238042eac6feb0a9a34ccae35ba946b006ef288f949aae5f67eeb0d147d9669
MD5 c7f3fef7533a08048c78fddfeb47e28c
BLAKE2b-256 47855f6127417968fbda52118475e55c624915cda39e9ac093210340663cd74d

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for flashrl-0.1.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 09270c6af9df56c1856fe389035ebff71cffe94dc37fcf16be266016b8619bde
MD5 09368f0401e29ca3ad162a99a1fca7c9
BLAKE2b-256 a2edb410b5a94c0fd6fed440620e10a85c9b5c214938d03d8684cc14b7db95dd

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3c0e81064a5078d2b93e35c32cf69fb5ffe17b3b538ef2cdb3aa61001f3df715
MD5 67373aafc41d246dc289746f30575633
BLAKE2b-256 12e179acf5376eabd8973c40bae77410096d03a2e989618baf962938141bd01e

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp312-cp312-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, musllinux: musl 1.2+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7ec926d50191b86804d15a97efce07e535539962df73da9bc533cc41ef2f0ea9
MD5 708d7ef6129fbf9a91bd02edd844e969
BLAKE2b-256 238c2d6d9e0eb3d01349a10136d4831d7b5cf24ca1870002aa6c893ff86ae438

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1550536059879b95df197815f30ae0f49a2d4e547eb7eb16906986633fd8a4b5
MD5 aa8840a9595ffa0082f2c4505ded1f37
BLAKE2b-256 a8c5373de761e1fd5bc16d219cbe394c58bc0f76fe3770ca34af133f802b0505

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for flashrl-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 515a2c69aa76fc2d34fb7c4d40641d96de49222eee63fafd39294b3d9b6fc8c7
MD5 2c0990a526eda6092ac0117d595f41fd
BLAKE2b-256 4459df521b21910b626321adc087f887d04e3f2cf10759a973bb1c3ffd64e7e6

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f4d24e5b403beaad3452033e81ecaaff36ab2d006c965df25e5f129e59bc32c3
MD5 56f7f0bd115db0bba9ac2007575e89e9
BLAKE2b-256 5fe6da90aa96a656cd10ddc3ed284d071553f90b1cedd51328ca5d10e3ccfd1d

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp310-cp310-musllinux_1_2_i686.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp310-cp310-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, musllinux: musl 1.2+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 5d9d8211ec05deec405408bd35736141df79a99f017b886a9b5794f38d3ed4cf
MD5 37d0eafd89de66c93b7a6ad9679aeb5b
BLAKE2b-256 faa5170a2b4b331e9c06de38620fcdd58dd9ff08462fe4b855a5c90183ee70b5

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: flashrl-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for flashrl-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fdb0a7f258ef96184139f667df03b95f3c3a1242e4eb1b9ea4e76506dd7706d
MD5 dff8764161bad1a934d03cf34049b790
BLAKE2b-256 1be4c4e5421e94b18db7cb55f8e8d3c4e1ce697273ceca9599586aaa569b4c2e

See more details on using hashes here.

File details

Details for the file flashrl-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for flashrl-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8e15d7a36f9a1b67221ddf2406bb20061e2e56a38edccea5b5b6759bd47e2ab5
MD5 9d550f4d70aee79ccf7fe43115f38bf5
BLAKE2b-256 e82cefeda2bd7e93c97044bd238b332748a8c98349a257458b84003916a47c3e

See more details on using hashes here.

Supported by

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