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 Good old pong (1 vs. 1) Agent must reach goal first
grid pong 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.0.2-cp313-cp313-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.13musllinux: musl 1.2+ i686

flashrl-0.0.2-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.0.2-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.0.2-cp312-cp312-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.12musllinux: musl 1.2+ i686

flashrl-0.0.2-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.0.2-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.0.2-cp311-cp311-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

flashrl-0.0.2-cp311-cp311-musllinux_1_2_i686.whl (1.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

flashrl-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

flashrl-0.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view details)

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

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

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.10musllinux: musl 1.2+ i686

flashrl-0.0.2-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.0.2-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.0.2-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0d8962fe5fe122662bd813d17e5c0a08c90d3e7147b2778185b144450e569b6c
MD5 4d1ed9e265570fd2683e177ee9e2589c
BLAKE2b-256 a720297a983a884bf611d1284412edc55ec82477048025b0a81d7eee98482d9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 93218cb54dcbc6b653e4fb0e6df5794dafade16ffddf5f05f7b57e39191bc505
MD5 a01124017988cb3473546e2fc2177cc8
BLAKE2b-256 2f442979cef780d529403e72b52b63ffba2856f3cb2880666c402589f778e974

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a77477fd3d2f4c5ab6ed46bf50ac005842fcfaba29e56e1bf28a4f62129eea7
MD5 ec60f2463c06244e02f10405e1b76672
BLAKE2b-256 716751d53295f0a4e3ccce31ceb98eb6a6bd6ab0f607094e3dd0d41a52123436

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flashrl-0.0.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 d87f892645dc15021d6132d26849bd7b34310fbb054a67929b1dd99d6d1def7c
MD5 1629f57b182283d083253aa2d19c3fa8
BLAKE2b-256 4b4941dc0ada2253b422147bad7444fafb02c6aba915a6730b5a1eb749a1031b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 849d24fcb03f96a8aab3cf78f32ca7e4e05837dac654bcb52179acd1915ac552
MD5 b2ac90de891a3bf5fe1423a8f71283d2
BLAKE2b-256 ef165f747c11f56b67458211bc6c1ed4002e9760de27825f9e4cb8504844df22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 9035ddf854d2b697e77b713b7aca53cf9a9acc9b4b9712a1e0205ef9c684da19
MD5 c7797135813c9e41b7bd6b8977824d80
BLAKE2b-256 095709d66e6d83ac09b880257da8ea47da553f82738b7b763ad10f73ea6df2d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 384ea879a04f078821ad0efeab25de52c064ee287bf25753a055c12ea858bda8
MD5 e1374554e7484e57aac42e14c7440208
BLAKE2b-256 beb324d0802b7a43d540ac209634c9c24dcf70f9835ed4f2a807e05f525e4e01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flashrl-0.0.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1a5e4370953f3d0d88d7b3d05863cd6092b7e7f18251227aa20358943838199e
MD5 157f5126b99c12a8db907152ecc4e0c0
BLAKE2b-256 cbd040581601dcf5f18b8330320f463e7868daad4649b6b235a4924dbba13d80

See more details on using hashes here.

File details

Details for the file flashrl-0.0.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: flashrl-0.0.2-cp311-cp311-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, 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.0.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 840496ef7cc7bebcf4085feb26800c4e7f4000f66c3ed189d1053dbf42cc6675
MD5 702423bfa11553ab640a7278a855d416
BLAKE2b-256 a3b36a57ab5ab88114fc69445aff0323ccb2c61274170903dd1d32b155b8ed80

See more details on using hashes here.

File details

Details for the file flashrl-0.0.2-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

  • Download URL: flashrl-0.0.2-cp311-cp311-musllinux_1_2_i686.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, 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.0.2-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 87943171cf780c83c4fd85263d79befba8614915288b9281d3f8764ca21f7268
MD5 945fa09341ae0a063d81ca9cff779dae
BLAKE2b-256 726564285874e4c90bf4cea4f10116ae21a3517b7e4f30e6ec56f1b5997b3fcf

See more details on using hashes here.

File details

Details for the file flashrl-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: flashrl-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, 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.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 06b9db0e445aeea21fb2e1b39f31113e47d975aaf5ce2783886022222049a805
MD5 8ea14f0e756ba9eff0d8c67e0c5c70f4
BLAKE2b-256 69ebcac5f771b5a70e531ff560a3a59ff30ebbaa4f9699edb69fa9af7239900b

See more details on using hashes here.

File details

Details for the file flashrl-0.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for flashrl-0.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 aa42a8695b7d874cdccf70b0409248f0bb8a1c63153e1e6af7aef595ac658524
MD5 f12af27a0381d782d2bbda3ec12667ae
BLAKE2b-256 4189763043f3534e9f16f9ab3b21a4309e9f94d734267e355ed33c9161af1035

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6eabdc55fbbd47ae78689d41e94a68219dc021bd88a1e69c1e1b0121c2f02ffb
MD5 758a473ae9d3c8306857e5dfb7499377
BLAKE2b-256 92137b44b3a18dea72a208c1361ad9e41c58301d70e7400e072a42b24f547fad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 8a4cf648995326a255b7e987a6a4de57d7e24ed8888c1fab6eaade1c5c3fa03b
MD5 c23f1ebd4cdcd6ea0800c0befe115b6b
BLAKE2b-256 fd01c0bd7641e4f1328159f0b03f1bffc31469ebda50b10132588be4aa379cef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flashrl-0.0.2-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.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f751f66b2933fbdafd0ec41ad596870349aa639dc543e4e6427e18d978f684a
MD5 5cd2738d1a733678683125ba9824a32e
BLAKE2b-256 ace8eb842b4434879d05a7e323fa76d7153212a2f9bafda0b714758a2c7d40b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flashrl-0.0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 bc16d90e4e2abf8ad96c474bffdac81c90acc36f5684e13eb713c392790a2832
MD5 0f31f7473af953cb88be4ec02caea29e
BLAKE2b-256 c82953f1adb77ef1368c23dc7cb8c34384f1df54f67d14f0256adb88dcb25eba

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