lerobot icon indicating copy to clipboard operation
lerobot copied to clipboard

Fix: Prevent Invalid next_state References When optimize_memory=True

Open s1lent4gnt opened this issue 9 months ago • 0 comments

What this does

When optimize_memory=True, the ReplayBuffer avoids redundant next_state storage by referencing state[i+1]. However, if the buffer is not full, sampling indices near self.size could reference uninitialized memory, leading to invalid next_state values (e.g., black images).

To address this, the sampling logic has been adjusted to:

  • Restrict indices to valid transitions when the buffer is not full.

  • Allow full sampling when the buffer is full (circular buffer behavior).

How it was tested

A training experiment was run, confirming no errors related to black images.

s1lent4gnt avatar Mar 29 '25 06:03 s1lent4gnt