Skip to content

Commit 6a7b9e0

Browse files
Adrian Orensteinvmoens
authored andcommitted
Move CompressedStorage to CompressedListStorage. Moved out all of the cursor logic to a view class. Passing all tests now.
1 parent dce0fa9 commit 6a7b9e0

File tree

7 files changed

+374
-205
lines changed

7 files changed

+374
-205
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
- libcst == 0.4.7
2121

2222
- repo: https://github.com/pycqa/flake8
23-
rev: 4.0.1
23+
rev: 6.0.0
2424
hooks:
2525
- id: flake8
2626
args: [--config=setup.cfg]

docs/source/reference/data.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ using the following components:
144144
:template: rl_template.rst
145145

146146

147-
CompressedStorage
148-
CompressedStorageCheckpointer
147+
CompressedListStorage
148+
CompressedListStorageCheckpointer
149149
FlatStorageCheckpointer
150150
H5StorageCheckpointer
151151
ImmutableDatasetWriter
@@ -197,10 +197,10 @@ Compressed Storage for Memory Efficiency
197197
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198198

199199
For applications where memory usage or memory bandwidth is a primary concern, especially when storing or transferring
200-
large sensory observations like images or audio, the :class:`~torchrl.data.replay_buffers.storages.CompressedStorage`
200+
large sensory observations like images, audio, or text. The :class:`~torchrl.data.replay_buffers.storages.CompressedListStorage`
201201
provides significant memory savings through compression.
202202

203-
The `CompressedStorage`` compresses data when storing and decompresses when retrieving,
203+
The `CompressedListStorage`` compresses data when storing and decompresses when retrieving,
204204
achieving compression ratios of 2-10x for image data while maintaining full data fidelity.
205205
It uses zstd compression by default but supports custom compression algorithms.
206206

@@ -214,11 +214,11 @@ Key features:
214214
Example usage:
215215

216216
>>> import torch
217-
>>> from torchrl.data import ReplayBuffer, CompressedStorage
217+
>>> from torchrl.data import ReplayBuffer, CompressedListStorage
218218
>>> from tensordict import TensorDict
219219
>>>
220220
>>> # Create a compressed storage for image data
221-
>>> storage = CompressedStorage(max_size=1000, compression_level=3)
221+
>>> storage = CompressedListStorage(max_size=1000, compression_level=3)
222222
>>> rb = ReplayBuffer(storage=storage, batch_size=32)
223223
>>>
224224
>>> # Add image data
@@ -241,16 +241,16 @@ For custom compression algorithms:
241241
>>> def my_decompress(compressed_tensor, metadata):
242242
... return compressed_tensor.to(metadata["dtype"])
243243
>>>
244-
>>> storage = CompressedStorage(
244+
>>> storage = CompressedListStorage(
245245
... max_size=1000,
246246
... compression_fn=my_compress,
247247
... decompression_fn=my_decompress
248248
... )
249249

250-
.. note:: The CompressedStorage requires the `zstandard` library for default compression.
250+
.. note:: The CompressedListStorage requires the `zstandard` library for default compression.
251251
Install with: ``pip install zstandard``
252252

253-
.. note:: An example of how to use the CompressedStorage is available in the
253+
.. note:: An example of how to use the CompressedListStorage is available in the
254254
`examples/replay-buffers/compressed_replay_buffer_example.py <https://github.com/pytorch/rl/blob/main/examples/replay-buffers/compressed_replay_buffer_example.py>`_ file.
255255

256256
Sharing replay buffers across processes

0 commit comments

Comments
 (0)