Skip to content

[Feature] collectors internals docs#3796

Open
theap06 wants to merge 2 commits into
pytorch:mainfrom
theap06:feat/collectors-internals-docs
Open

[Feature] collectors internals docs#3796
theap06 wants to merge 2 commits into
pytorch:mainfrom
theap06:feat/collectors-internals-docs

Conversation

@theap06
Copy link
Copy Markdown
Contributor

@theap06 theap06 commented May 24, 2026

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 inside torchrl/collectors/_single.py.

theap06 and others added 2 commits May 23, 2026 00:26
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).
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 24, 2026

🔗 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.

⚠️ 16 Awaiting Approval

As of commit 918f4ec with merge base 634979d (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 May 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

ghost commented May 24, 2026

⚠️ PR Title Label Error

PR title must start with a label prefix in brackets (e.g., [BugFix]).

Current title: Feat/collectors internals docs

Supported Prefixes (case-sensitive)

Your PR title must start with exactly one of these prefixes:

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 theap06 changed the title Feat/collectors internals docs [Feat] collectors internals docs May 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

ghost commented May 24, 2026

⚠️ PR Title Label Error

Unknown or invalid prefix [Feat].

Current title: [Feat] collectors internals docs

Supported Prefixes (case-sensitive)

Your PR title must start with exactly one of these prefixes:

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 theap06 changed the title [Feat] collectors internals docs [Feature] collectors internals docs May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Collectors Documentation Improvements or additions to documentation Feature New feature Integrations/torch_geometric Integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Doc] Improve navigability for new contributors

1 participant