Skip to content

[Feature] Adds HERReplayBuffer and HindsightStrategy to torchrl.data.#3734

Open
theap06 wants to merge 4 commits into
pytorch:mainfrom
theap06:feat/her-replay-buffer
Open

[Feature] Adds HERReplayBuffer and HindsightStrategy to torchrl.data.#3734
theap06 wants to merge 4 commits into
pytorch:mainfrom
theap06:feat/her-replay-buffer

Conversation

@theap06
Copy link
Copy Markdown
Contributor

@theap06 theap06 commented May 10, 2026

Description

Describe your changes in detail.

Motivation and Context

Fixes #3713

I have raised an issue to propose this change (required for new features and bug fixes)

##Summary

  • Adds HERReplayBuffer — a TensorDictReplayBuffer subclass that applies goal relabeling at sample time, turning failed goal-conditioned trajectories into useful training signal (Andrychowicz et al., NeurIPS 2017)
  • Adds HindsightStrategy enum with all four canonical strategies: FUTURE (recommended), FINAL, EPISODE, RANDOM
  • Exports both symbols from torchrl.data and torchrl.data.replay_buffers

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 10, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3734

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 16 Awaiting Approval

As of commit 12be7a3 with merge base eb90c5d (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ PR Title Label Error

PR title must start with a label prefix in brackets (e.g., [BugFix]).

Current title: Adds HERReplayBuffer and HindsightStrategy to torchrl.data.

Supported Prefixes (case-sensitive)

Your PR title must start with exactly one of these prefixes:

Prefix Label Applied Example
[BugFix] BugFix [BugFix] Fix memory leak in collector
[Feature] Feature [Feature] Add new optimizer
[Doc] or [Docs] Documentation [Doc] Update installation guide
[Refactor] Refactoring [Refactor] Clean up module imports
[CI] CI [CI] Fix workflow permissions
[Test] or [Tests] Tests [Tests] Add unit tests for buffer
[Environment] or [Environments] Environments [Environments] Add Gymnasium support
[Data] Data [Data] Fix replay buffer sampling
[Performance] or [Perf] Performance [Performance] Optimize tensor ops
[BC-Breaking] bc breaking [BC-Breaking] Remove deprecated API
[Deprecation] Deprecation [Deprecation] Mark old function
[Quality] Quality [Quality] Fix typos and add codespell

Note: Common variations like singular/plural are supported (e.g., [Doc] or [Docs]).

@theap06 theap06 changed the title Adds HERReplayBuffer and HindsightStrategy to torchrl.data. [Feature] Adds HERReplayBuffer and HindsightStrategy to torchrl.data. May 10, 2026
@github-actions github-actions Bot added the Feature New feature label May 10, 2026
@theap06
Copy link
Copy Markdown
Contributor Author

theap06 commented May 10, 2026

@vmoens Results utilizing HER. Wrote up a quick script for DDPG
image

Copy link
Copy Markdown
Collaborator

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

Amazing, I love this.
I left a couple of high level comments can you have a look?

Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py
Comment thread torchrl/data/replay_buffers/her.py Outdated
@theap06 theap06 requested a review from vmoens May 10, 2026 21:58
Copy link
Copy Markdown
Collaborator

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

Good progress, left a few more comments here

Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
Comment thread torchrl/data/replay_buffers/her.py Outdated
@theap06 theap06 requested a review from vmoens May 11, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Feature New feature ReplayBuffers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Implementing HER(Hindsight Experience Replay)

2 participants