Skip to content

Use pointer-based pixel storage in memory efficient replay buffer#8

Open
rojas70 wants to merge 1 commit intomainfrom
codex/use-pointers-in-replay-buffer
Open

Use pointer-based pixel storage in memory efficient replay buffer#8
rojas70 wants to merge 1 commit intomainfrom
codex/use-pointers-in-replay-buffer

Conversation

@rojas70
Copy link

@rojas70 rojas70 commented Mar 11, 2026

Motivation

  • Reduce memory duplication from storing full pixel stacks per transition by storing only integer pointers in the replay dataset and keeping pixel frames in a shared ring buffer.
  • Keep existing API for sampling stacked observations while significantly lowering memory pressure for large capacities and long stacks.

Description

  • Allocate per-pixel-key ring buffers (self._pixel_buffers) and expose observation pixel entries as int32 pointer Box spaces instead of full images.
  • Add helper methods _insert_pixel_frame and _advance_pixel_pointer to write frames into the ring buffer and advance the frame pointer.
  • Update insert() to write incoming pixel frames into the ring buffer and store pointer indices in observations/next_observations instead of copying images into each transition.
  • Update sample() to reconstruct stacked observation tensors by resolving pointer histories from the dataset and indexing into the pixel ring buffer (replacing the previous sliding_window_view over stored images).

Testing

  • Successfully type-checked/compiled the modified file with python -m py_compile serl_launcher/serl_launcher/data/memory_efficient_replay_buffer.py.
  • Ran a small runtime validation script that constructs the buffer, inserts random transitions, and samples a batch to verify output shapes and that dataset pixel entries are int32 pointers; the script completed and returned expected shapes and pointer dtype.

Codex Task

@rojas70
Copy link
Author

rojas70 commented Mar 11, 2026

also done with code/chatGPT have not tested. but @ryanvanderstelt wanted to throw this idea out into the datastore...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant