[Feature] Collector.fake_tensordict() / MultiCollector.fake_tensordict()#3764
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3764
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: ❌ 3 New Failures, 1 Cancelled JobAs of commit 7ef328e with merge base 0a01ee8 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced May 15, 2026
vmoens
added a commit
that referenced
this pull request
May 15, 2026
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 env
first.
``Collector.fake_tensordict()`` (single-process):
- Reuses the existing ``_final_rollout`` template; builds it lazily via
``_maybe_make_final_rollout(make_rollout=True)`` even when
``use_buffers=False`` so the public API is consistent.
- Mirrors the rollout post-pipeline: ``_maybe_attach_final_obs``,
``_maybe_set_truncated``, then ``_postproc`` (which runs
``split_trajectories``, the user ``postproc``, and private-key
exclusion).
- Result: env keys + policy out-keys + ``("collector", "traj_ids")``,
``compact_obs`` exclusions and ``final_obs`` ``UnbatchedTensor``
leaves applied, last dim named ``"time"``.
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
Honoring the contract on the parent process would either require
creating an env there (which defeats the purpose of a multi-process
collector — Isaac Lab / mujoco-mjx etc. can only run in workers) or
routing a request to a worker over the pipe (which requires live
workers and adds protocol surface). Neither is in scope here; users
who need a fake tensordict can call it on a single-process
:class:`~torchrl.collectors.Collector`.
Tests pin: shape / names / keys / zero-fill parity between
``fake_tensordict()`` and ``next(iter(collector))`` (with and without
buffers); ``compact_obs`` drops ``("next", obs)`` and ``final_obs``
attaches ``("final", obs)`` as ``UnbatchedTensor``; and that
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
ghstack-source-id: c2b5dbb
Pull-Request: #3764
vmoens
added a commit
that referenced
this pull request
May 15, 2026
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 env
first.
``Collector.fake_tensordict()`` (single-process):
- Reuses the existing ``_final_rollout`` template; builds it lazily via
``_maybe_make_final_rollout(make_rollout=True)`` even when
``use_buffers=False`` so the public API is consistent.
- Mirrors the rollout post-pipeline: ``_maybe_attach_final_obs``,
``_maybe_set_truncated``, then ``_postproc`` (which runs
``split_trajectories``, the user ``postproc``, and private-key
exclusion).
- Result: env keys + policy out-keys + ``("collector", "traj_ids")``,
``compact_obs`` exclusions and ``final_obs`` ``UnbatchedTensor``
leaves applied, last dim named ``"time"``.
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
Honoring the contract on the parent process would either require
creating an env there (which defeats the purpose of a multi-process
collector — Isaac Lab / mujoco-mjx etc. can only run in workers) or
routing a request to a worker over the pipe (which requires live
workers and adds protocol surface). Neither is in scope here; users
who need a fake tensordict can call it on a single-process
:class:`~torchrl.collectors.Collector`.
Tests pin: shape / names / keys / zero-fill parity between
``fake_tensordict()`` and ``next(iter(collector))`` (with and without
buffers); ``compact_obs`` drops ``("next", obs)`` and ``final_obs``
attaches ``("final", obs)`` as ``UnbatchedTensor``; and that
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
ghstack-source-id: 38de918
Pull-Request: #3764
vmoens
added a commit
that referenced
this pull request
May 15, 2026
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 env
first.
``Collector.fake_tensordict()`` (single-process):
- Reuses the existing ``_final_rollout`` template; builds it lazily via
``_maybe_make_final_rollout(make_rollout=True)`` even when
``use_buffers=False`` so the public API is consistent.
- Mirrors the rollout post-pipeline: ``_maybe_attach_final_obs``,
``_maybe_set_truncated``, then ``_postproc`` (which runs
``split_trajectories``, the user ``postproc``, and private-key
exclusion).
- Result: env keys + policy out-keys + ``("collector", "traj_ids")``,
``compact_obs`` exclusions and ``final_obs`` ``UnbatchedTensor``
leaves applied, last dim named ``"time"``.
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
Honoring the contract on the parent process would either require
creating an env there (which defeats the purpose of a multi-process
collector — Isaac Lab / mujoco-mjx etc. can only run in workers) or
routing a request to a worker over the pipe (which requires live
workers and adds protocol surface). Neither is in scope here; users
who need a fake tensordict can call it on a single-process
:class:`~torchrl.collectors.Collector`.
Tests pin: shape / names / keys / zero-fill parity between
``fake_tensordict()`` and ``next(iter(collector))`` (with and without
buffers); ``compact_obs`` drops ``("next", obs)`` and ``final_obs``
attaches ``("final", obs)`` as ``UnbatchedTensor``; and that
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
ghstack-source-id: f46dbe7
Pull-Request: #3764
This was referenced May 15, 2026
This was referenced May 17, 2026
This was referenced May 18, 2026
vmoens
added a commit
that referenced
this pull request
May 18, 2026
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 env
first.
``Collector.fake_tensordict()`` (single-process):
- Reuses the existing ``_final_rollout`` template; builds it lazily via
``_maybe_make_final_rollout(make_rollout=True)`` even when
``use_buffers=False`` so the public API is consistent.
- Mirrors the rollout post-pipeline: ``_maybe_attach_final_obs``,
``_maybe_set_truncated``, then ``_postproc`` (which runs
``split_trajectories``, the user ``postproc``, and private-key
exclusion).
- Result: env keys + policy out-keys + ``("collector", "traj_ids")``,
``compact_obs`` exclusions and ``final_obs`` ``UnbatchedTensor``
leaves applied, last dim named ``"time"``.
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
Honoring the contract on the parent process would either require
creating an env there (which defeats the purpose of a multi-process
collector — Isaac Lab / mujoco-mjx etc. can only run in workers) or
routing a request to a worker over the pipe (which requires live
workers and adds protocol surface). Neither is in scope here; users
who need a fake tensordict can call it on a single-process
:class:`~torchrl.collectors.Collector`.
Tests pin: shape / names / keys / zero-fill parity between
``fake_tensordict()`` and ``next(iter(collector))`` (with and without
buffers); ``compact_obs`` drops ``("next", obs)`` and ``final_obs``
attaches ``("final", obs)`` as ``UnbatchedTensor``; and that
``MultiCollector.fake_tensordict()`` raises ``NotImplementedError``.
ghstack-source-id: 6db6382
Pull-Request: #3764
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 envfirst.
Collector.fake_tensordict()(single-process):_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".MultiCollector.fake_tensordict()raisesNotImplementedError.Honoring the contract on the parent process would either require
creating an env there (which defeats the purpose of a multi-process
collector — Isaac Lab / mujoco-mjx etc. can only run in workers) or
routing a request to a worker over the pipe (which requires live
workers and adds protocol surface). Neither is in scope here; users
who need a fake tensordict can call it on a single-process
:class:
~torchrl.collectors.Collector.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; and thatMultiCollector.fake_tensordict()raisesNotImplementedError.