[Feature] collectors internals docs - #3796
Conversation
Adds the architecture/internals layer between API reference and tutorials that contributors and debuggers have been missing for the collector and key TorchRL-specific vocabulary. - New collectors_internals.rst: per-timestep rollout flow diagram, carrier (formerly "shuttle") lifecycle, the three sync points (_sync_policy / _sync_env / _sync_storage), and the device-cast flags (_cast_to_policy_device / _cast_to_env_device / _shuttle_has_no_device). - New glossary.rst with entries for carrier/shuttle, in_keys/out_keys, _AcceptedKeys, set_keys, recurrent mode, TensorDictPrimer, is_init, trajectory ID, storing/policy/env_device, no_cuda_sync, compact_obs, functional loss, tensor_keys. - Expanded SyncDataCollector.rollout docstring with a 5-bullet high-level outline of the per-timestep flow, cross-linking to the new internals page. - collectors_basics.rst gains a track_traj_ids paragraph and a short Trajectory IDs section explaining the downstream consumers (SliceSampler, split_trajectories). - Both new pages wired into the corresponding toctrees. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three factual corrections in the glossary's `recurrent mode` entry: - Removed reference to ``LSTMModule.set_recurrent_mode``, which was removed in v0.8 (the method now raises and redirects users to the standalone context manager). - Clarified that ``recurrent_mode_state_manager`` is the backing singleton, not a context manager — the context manager is ``set_recurrent_mode``. Noted the thread / asyncio-task locality via ``contextvars.ContextVar``. - Fixed the sequential/recurrent label swap: collectors run in sequential mode (one step per call), losses in recurrent mode (full sequence per call).
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3796
Note: Links to docs will display an error until the docs builds have been completed. ❌ 5 New FailuresAs of commit 2e2cb9a with merge base 634979d ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
| 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]).
|
| 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 I edited a bunch of things in response to my own comments hope you don't mind |
Adds tutorials/sphinx-tutorials/recurrent_sequence_training.py — the multi-step / sequence-training complement to dqn_with_rnn.py (which covers single-step recurrent DQN at collection time). Walks through the post-pytorch#3695 recurrent contract end-to-end: - Collector auto-wiring of InitTracker + the recurrent-state primer via auto_register_policy_transforms=True - Trajectory-aware sampling with SliceSampler - Multi-step LSTM forward under set_recurrent_mode(True) - Boundary safety: hand-built two-trajectory packed batch + isolation check that proves hidden state does not leak across is_init markers - A tiny end-to-end training loop closing the BC-style sequence path Runs in ~3s on CPU. Cross-references the recurrent state lifecycle guide (pytorch#3792), collector internals page (pytorch#3796), and the glossary. Toctree entry added to docs/source/index.rst next to dqn_with_rnn.
Fixes #3746
Summary
Adds the architecture / internals layer between the API reference and tutorials that contributors and debuggers have been missing for the collector subsystem and TorchRL-specific vocabulary. Docs-only. No runtime changes.
Targets the gap where
SyncDataCollector's per-step mechanics (_carrier, the three sync points, the device-cast flags) are load-bearing for anyone debugging RNN, replay, or device-placement issues but have until now only lived in inline comments insidetorchrl/collectors/_single.py.