Skip to main content

Extra buffer classes for Stable-Baselines3

Reason this release was yanked:

RLE implementation flawed

Project description

sb3-extra-buffers

Unofficial implementation of extra Stable-Baselines3 buffer classes. Mostly a proof-of-concept in current state.


Compressed Buffers

Reinforcement Learning is quite memory-hungry due to massive buffer sizes, so let's try to tackle it by not storing raw frame buffers in full np.float32 directly and find something smaller instead. For any input data that are sparse and containing large contiguous region of repeating values, lossless compression techniques can be applied to reduce memory footprint.

One such kind of input data is Semantic Segmentation (SS) masks (with one color channel representing class labels as integers) and RGB / Color Palette game frames from retro video games should also benefit from compression. SS For 4 vectorized Doom environments each storing 4096 SS masks of 256x144 resolution:

method dtype shape size
Baseline np.float32 (4096, 4, 1, 144, 256) 2.3 GB
Cast to uint8 np.uint8 (4096, 4, 1, 144, 256) 576 MB
RLE-auto-slice np.uint8 for elements, lengths and positions (4096, 4, 145) x 3 306 MB
RLE-flatten np.uint8 for elements, np.uint16 for lengths and positions (4096, 4) x 3 20.4 MB
gzip-level-1 np.uint8 (4096, 4) x 3 11.1 MB
gzip-level-5 np.uint8 (4096, 4) x 3 7.65 MB
gzip-level-9 np.uint8 (4096, 4) x 3 5.17 MB

Currently implemented compression methods:

  • RLE (Run-Length Encoding)
  • gzip
Example Usage:
from sb3_extra_buffers.compressed import CompressedRolloutBuffer

buffer_dtypes = dict(len_type=np.uint16, pos_type=np.uint16, elem_type=np.uint8)
buffer_kwargs = dict(dtypes=buffer_dtypes, normalize_images=normalize_images, compression_method=compression_method, auto_slice=False, compression_kwargs=compression_kwargs)

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

sb3_extra_buffers-0.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

sb3_extra_buffers-0.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file sb3_extra_buffers-0.1.1.tar.gz.

File metadata

  • Download URL: sb3_extra_buffers-0.1.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for sb3_extra_buffers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 420ede4fdebafc0a725eea4a2b19ed925f6187e4f761b80cf2ee651529255afb
MD5 3edc5d7c2d695a6b11d9172cf2b9ef51
BLAKE2b-256 1eaf4ed1a1fbbfc370de6b2a05b9d0d32a70b3170197fdcb04fc8a19f0483504

See more details on using hashes here.

File details

Details for the file sb3_extra_buffers-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sb3_extra_buffers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7655920a40f98d5f4b25cfda064e34869f4502dadfddd1ea2a3b942a59a08d83
MD5 33b75cf97ec4a78e49bfeb15205ed264
BLAKE2b-256 a5b5043d800ff100e8060c8370164d05c3b5cb52331efbea6c5e8322feb0d59d

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