Skip to content

[Doc] Add recurrent state lifecycle guide - #3792

Merged
vmoens merged 7 commits into
pytorch:mainfrom
theap06:feat/hidden-understandable
Jun 1, 2026
Merged

[Doc] Add recurrent state lifecycle guide#3792
vmoens merged 7 commits into
pytorch:mainfrom
theap06:feat/hidden-understandable

Conversation

@theap06

@theap06 theap06 commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3746

Summary

Adds a focused recurrent-state lifecycle guide and an integration test for the
full policy. Closes the "recurrent debugging requires jumping across LSTMModule, InitTracker, and
loss-side is_init masking with no unifying doc" gap, and the parallel gap
of having no integration test that exercises a multi-trajectory batch with
mid-batch done.

@pytorch-bot

pytorch-bot Bot commented May 24, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3792

Note: Links to docs will display an error until the docs builds have been completed.

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
@theap06
theap06 force-pushed the feat/hidden-understandable branch from 7d5e1ca to dc6cd0c Compare May 24, 2026 06:15
…andable

# Conflicts:
#	torchrl/modules/tensordict_module/rnn.py
@theap06

theap06 commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

@vmoens feel free to leave some feedback when ur free. also lmk if there is anything I can do to help with general maintainance of the library

@theap06

theap06 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@vmoens thanks for the changes! I had the InitTracker-missing failure mode wrong (the KeyError path vs the silent-content-wrong path), and the "final hidden" caveat is much more accurate now.

plumbing for a PPO-style update. It omits optimization, logging, and
multi-epoch training so the data path stays visible.

.. code-block:: python

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theap06 added an e2e example -- worth showing what we're really talking about

@vmoens
vmoens merged commit 8e64003 into pytorch:main Jun 1, 2026
3 checks passed
theap06 added a commit to theap06/rl that referenced this pull request Jun 12, 2026
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.
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. Documentation Improvements or additions to documentation Integrations/torch_geometric Integrations Modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Doc] Improve navigability for new contributors

2 participants