Skip to content

[BugFix] Fix offline-to-online training with a mixed replay buffer - #4768

Draft
sramireddy2 wants to merge 2 commits into
pytorch:mainfrom
sramireddy2:fix/offline-to-online-mixed-buffer
Draft

sramireddy2 wants to merge 2 commits into
pytorch:mainfrom
sramireddy2:fix/offline-to-online-mixed-buffer

Conversation

@sramireddy2

@sramireddy2 sramireddy2 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #4765. The offline-to-online example stopped on its first online batch:

  • OfflineToOnlineReplayBuffer now has write_count (the online buffer's) and batch_size, which UTDRHook reads when logging is enabled.
  • OfflineToOnlineReplayBuffer.sample drops the keys that the offline sampler reports (e.g. the index that TensorDictReplayBuffer-based datasets add) and the online sample lacks, before concatenating the two. Mismatches in any other key still raise.
  • The example env adds RewardSum, so the default r_total logging finds reward_sum.

test_train_grows_online_and_anneals now also runs with logging enabled and a TensorDictReplayBuffer offline dataset.

Motivation and Context

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

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Example (update in the folder of examples)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

I used an AI assistant (Claude Code) to help find the bug and write and test the change. I'm still reviewing it, so this is a draft.

- OfflineToOnlineReplayBuffer exposes write_count and batch_size, which
  UTDRHook reads when logging is enabled (the default).
- Mixed samples drop the offline buffer's sampling metadata (e.g. "index"
  from TensorDictReplayBuffer-based datasets) so the concat with the online
  sample works.
- The offline_to_online example adds RewardSum so the default r_total
  logging finds reward_sum.
@pytorch-bot

pytorch-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 16 Awaiting Approval

As of commit 85f4944 with merge base df1db3d (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 Nov 23, 2026
@sramireddy2
sramireddy2 marked this pull request as draft November 29, 2026 23:10
SliceSampler reports done keys in its info, so dropping every info key broke the concat. Drop only those missing from the online sample.

This branch has not been deployed

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

Labels

BugFix CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. ReplayBuffers sota-implementations/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The offline-to-online example crashes on its first online batch

1 participant