rl
rl copied to clipboard
[Feature Request] New Tutorial - Trajectory Assembly internals in the TorchRL Collectors
Feature request: Add tutorial on trajectory assembly internals in TorchRL collectors
Summary
Add a tutorial that explains how collector batches are turned into complete trajectories, padded, and masked, with a focus on:
split_trajectories(...)_traj_ingest(...)_traj_emit(...)- done/terminated boundary handling
- nested vs padded trajectory outputs
Motivation
Users training recurrent or sequence-based policies often need to understand:
- why trajectories are split across collector batches,
- how partial trajectories are buffered and reassembled,
- how
("collector", "traj_ids")and("collector", "mask")are used, - when to use
as_nested=Truevs zero-padded tensors.
Current docs show usage, but not enough collector-internal dataflow.
Proposed tutorial title
TorchRL Collectors Deep Dive: Trajectory IDs, Partial Chunks, and Emission
Learning goals
By the end, users should be able to:
- Build a mental model of collector chunking and trajectory boundaries.
- Use
split_trajectoriescorrectly withtrajectory_key/done_key. - Understand and debug
trajs_per_batch-style workflows. - Choose between padded and nested outputs.
Proposed outline
- Create synthetic batched collector output with
traj_idsand done signals. - Walk through
split_trajectoriesbehavior in common and edge cases. - Demonstrate partial trajectory buffering across multiple batches via
_traj_ingest. - Emit fixed number of full trajectories with
_traj_emit. - Show mask semantics and downstream model usage.
- Performance notes for
as_nested=Trueand layout choices.
Acceptance criteria
- Includes end-to-end runnable code.
- Includes one edge case where a trajectory spans multiple collector iterations.
- Includes visual check of
mask,traj_ids, and final padded batch shape. - Includes troubleshooting section for missing
("collector", "traj_ids").
Nice-to-have
- Benchmark snippet comparing padded vs nested output for sequence models.
I would like to work on this.
@coder-jayp thanks! let me know if you need any help