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.2.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.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sb3_extra_buffers-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7bcf7b2a912f4e4bf041b17a49435ee8a1bbdc10876ebad72a744fc815108cdc
MD5 295bbcdfb6654d0e40ecb002d3372192
BLAKE2b-256 08a293ad24a789170d5830fdc2d1004d3be9bb860eb8d8130ca45c3eb1e8fb33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sb3_extra_buffers-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f2c91daca44c7db15295cfd74bd094badcfd5488b77e176aadb2192be8fbd20
MD5 52aeed64f84ffcfbaf53faa988aab693
BLAKE2b-256 8ae6a7eaa0cedcd035a9e8440d7b1141381ed1083118edd3ec58b7ac12952639

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