Skip to content

Conversation

@s1lent4gnt
Copy link
Contributor

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.

- Restrict sampling indices to valid transitions when buffer is not full, avoiding uninitialized memory access in next_state
- Maintain full sampling range when buffer is full (circular behavior)
@s1lent4gnt s1lent4gnt force-pushed the lilkm/fix-next-state-uninitialized-memory branch from 12f7db5 to 610ac46 Compare March 29, 2025 07:21
@AdilZouitine
Copy link
Collaborator

lgtm thank you 😄

@AdilZouitine AdilZouitine merged commit 66c3672 into huggingface:user/adil-zouitine/2025-1-7-port-hil-serl-new Mar 31, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants