[Feature] Collector.fake_tensordict() / MultiCollector.fake_tensordict()#3761
Closed
vmoens wants to merge 1 commit into
Closed
[Feature] Collector.fake_tensordict() / MultiCollector.fake_tensordict()#3761vmoens wants to merge 1 commit into
vmoens wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3761
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced May 15, 2026
This was referenced May 15, 2026
vmoens
commented
May 15, 2026
| """ | ||
| # Build / borrow one env to read fake_tensordict, compact-obs leaf | ||
| # keys, and final-obs leaf shapes from. | ||
| env_fn = self.create_env_fn[0] |
Collaborator
Author
There was a problem hiding this comment.
I'm not a big fan of this implementation.
We are creating an env in the main process which defies the purpose of the MultiCollector.
If we cannot get the fake data from the inner collector easily, we should just raise a NotImplementedError. But we should not pretend we're doing that (which is the right thing) and do it via a ton of custom code on the main process.
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.
Stack from ghstack (oldest at bottom):
Public method that returns a zero-filled tensordict shaped exactly like
one batch yielded by the collector, useful for storage initialization
and
torch.compile/ cudagraph warmup without having to step the envor spin up the worker processes first.
On
Collector(single):_final_rollouttemplate; builds it lazily via_maybe_make_final_rollout(make_rollout=True)even whenuse_buffers=Falseso the public API is consistent._maybe_attach_final_obs,_maybe_set_truncated, then_postproc(which runssplit_trajectories, the userpostproc, and private-keyexclusion).
("collector", "traj_ids"),compact_obsexclusions andfinal_obsUnbatchedTensorleaves applied, last dim named
"time".On
MultiCollector:create_env_fn[0](mirroring thelegacy replay-buffer init path), applies
_add_policy_outputs_to_fake_td,expands to
(*env.batch_size, frames_per_worker), refines"time".MultiSyncCollector, stacksnum_workerscopies along dim 0(or concatenates along
cat_resultswhen an integer was provided);for
MultiAsyncCollector, returns a single worker's shape (asyncyields one batch at a time).
split_trajs/postproc/ private-key exclusion tomatch the iterator pipeline.
Tests pin: shape / names / keys / zero-fill parity between
fake_tensordict()andnext(iter(collector))(with and withoutbuffers);
compact_obsdrops("next", obs)andfinal_obsattaches
("final", obs)asUnbatchedTensor; multi-sync stacksalong worker dim 0.