Repository navigation
Conversation
Makes ReplayBufferEnsemble usable for RLPD, offline-to-online and HIL-SERL style training, where each batch mixes data from several sources. Every new behavior is opt-in and the defaults are unchanged. - Mixed member samplers: a prioritized member next to a uniform member no longer crashes when infos are stacked. Uniform rows get priority_weight 1. Any other info key missing from some members raises a KeyError naming the key, and members with different index layouts raise a clear ValueError. - Routed priority updates: update_priority and update_tensordict_priority send each row to the member it came from, with member-local indices. - Exact quotas: fractions=[...] gives every batch the same per-member counts (largest-remainder rounding) and a flat [batch_size] batch ordered by member. With slice samplers the counts are in slices. A member that cannot serve its share blocks sampling instead of passing it on. fractions is settable between batches, saved in state_dict, kept (renormalized) by rb[...] sub-ensembles, and exposed on SamplerEnsembleConfig. - Multi-membership writes: routing_mode="mask" writes a record to every member marked in a boolean mask and returns [N, num_members] addresses with a present mask. update_if_present and update_priority skip absent copies, and a per-record patch reaches every copy. The mask is not stored. - Performance: ReplayBuffer.sample counted items with torch.as_tensor on the ensemble's index tensordict, which walks it row by row (the change proposed in pytorch#4720). Flat sampling, mask writes and priority updates avoid per-row work. Adds test_mixed_source_replay_buffer, which compares the ensemble against equivalent hand-wired code. CPU, batch 256, 1k-frame writes, median us (ensemble vs hand-wired): sample 585 vs 517, extend 778 vs 620, priority update 197 vs 168.
…hares Extends test_mixed_source_replay_buffer to every pair of uniform and prioritized members and to 10% or 100% of rows routed to both members. The hand-wired baseline now does the same work as the ensemble: writes return the write generation of every copy, and sampled batches carry each row's member, index and write generation, which routed write-back needs. CPU (Mac, under load), ensemble time over hand-wired time: sample 0.86 to 0.98, priority update 1.00 to 1.11, extend 1.09 to 1.17 with 10% shared rows and 0.85 to 0.87 with 100% shared rows.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4773
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New FailuresAs of commit 064ee84 with merge base df1db3d ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
4 of 6 tasks
update_priority with a plain tensor index goes to the ensemble's sampler as it did before, instead of raising a TypeError. Class-level defaults for routing_mode and the sampler's fractions let whole-object pickles saved before this change load, sample and extend.
Split flat batches by the sampled member ids instead of recomputing the quotas, so a fractions change during prefetch cannot mislabel rows, and take the replay lock in the fractions setter. dumps and loads now keep fractions, non-strict slice samplers are rejected with fractions, samples_returned counts records for multi-dim members, and mask-mode update_priority accepts one priority per record.
…e them unset too Assigning fractions after construction skipped the check that they cannot be combined with p, sample_from_all or num_buffer_sampled, which were then silently ignored; the setter now raises like the constructor. Checkpoints only stored fractions when set, so loading one saved without them kept the fractions already on the buffer; the current value is now always saved, None included. The docstrings also say a tensor is accepted.
This was referenced Nov 28, 2026
Priority updates now hold the ensemble's locks, so they cannot run while a prefetched sample reads the same priority trees. Samples drawn with fractions are pinned when pin_memory=True. Fractions are renormalized so large batches always get counts that add up to the batch size. update_priority skips members without a prioritized sampler, as documented.
theap06
marked this pull request as ready for review
November 29, 2026 09:13
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes
ReplayBufferEnsemblework for batches that mix data sources (RLPD, offline-to-online, HIL-SERL), all opt-in with unchanged defaults: prioritized and uniform members together, priority updates routed to each member, exact per-memberfractionswith a flat batch, androuting_mode="mask"writes that store a record in several members and return every copy's address forupdate_if_present. Benchmark numbers against two hand-wired buffers doing the same work are in the benchmark commit message.Motivation and Context
On main a prioritized member next to a uniform one crashes on sampling, a record can go to one member only, there is no
update_tensordict_priority, and thep=split is random per batch.Stack (merge in this order; #4771, #4772, #4773 and #4799 are independent of each other and each is based on
main, #4774 needs all four):Types of changes
Checklist