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.tar.gz (7.3 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-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sb3_extra_buffers-0.1.tar.gz
  • Upload date:
  • Size: 7.3 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.tar.gz
Algorithm Hash digest
SHA256 d03bd23c421fb1ccddbfc10b6e84c74bfeed757f0c1470901eec093710b81a0f
MD5 acc238cc5d80031cc7ecd8bba657e286
BLAKE2b-256 5231d94188afd547c5202dab34e6289706a0f383f8ec1ed8f0e84a687462b5ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sb3_extra_buffers-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8fe4089dc373d8eb386e8546fec2234bb8ce4afba4daa9b605e0f75803f0cec
MD5 51fecf62c7ecfc6e9fd555e4498a716d
BLAKE2b-256 8be94f46740c00499cf7a14aa113baa4d17d9051558e64bb571cc2d5b0fbffa5

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