Skip to content

Add AMP replay buffer state management#56

Open
GiulioRomualdi wants to merge 3 commits intomainfrom
save_replay_buffer
Open

Add AMP replay buffer state management#56
GiulioRomualdi wants to merge 3 commits intomainfrom
save_replay_buffer

Conversation

@GiulioRomualdi
Copy link
Collaborator

Add the possibility to save and load the replay buffer state during training.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds checkpoint persistence for the AMP replay buffer so training can resume with the same discriminator replay state.

Changes:

  • Implement ReplayBuffer.state_dict() / ReplayBuffer.load_state_dict() to snapshot/restore buffer tensors and counters.
  • Include the AMP replay buffer snapshot in AMPOnPolicyRunner.save() checkpoints.
  • Restore the AMP replay buffer snapshot in AMPOnPolicyRunner.load() when present.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
amp_rsl_rl/storage/replay_buffer.py Adds serialization/deserialization helpers for replay buffer contents.
amp_rsl_rl/runners/amp_on_policy_runner.py Saves/loads replay buffer state as part of training checkpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +134 to +141
def state_dict(self) -> dict:
"""Return a serialisable snapshot of the buffer contents."""
return {
"states": self.states[: self.num_samples].clone(),
"next_states": self.next_states[: self.num_samples].clone(),
"step": self.step,
"num_samples": self.num_samples,
}
Comment on lines +144 to +148
"""Restore the buffer from a snapshot produced by :meth:`state_dict`."""
n = state["num_samples"]
self.states[:n] = state["states"].to(self.device)
self.next_states[:n] = state["next_states"].to(self.device)
self.step = state["step"]
GiulioRomualdi and others added 2 commits March 17, 2026 11:40
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
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