Skip to content

[Doc] Document multi-agent _step TensorDict layout - #4232

Open
YeonwooSung wants to merge 3 commits into
pytorch:mainfrom
YeonwooSung:doc/2425-multiagent-step-tensordict
Open

[Doc] Document multi-agent _step TensorDict layout#4232
YeonwooSung wants to merge 3 commits into
pytorch:mainfrom
YeonwooSung:doc/2425-multiagent-step-tensordict

Conversation

@YeonwooSung

Copy link
Copy Markdown
Contributor

Description

Extends docs/source/reference/envs_multiagent.rst with a Multiple agent groups section so a native EnvBase._step() is documented beyond the single "agents" group used by VMAS.

The new section:

  • Shows the key tree a custom _step() must write for several groups ("red" / "blue", or "agents" / "adversaries"): per-group nested tensordicts with a stacked agent dimension.
  • States where action (input only), observation, and reward live, and where done / terminated / truncated live when they are shared (root reset signal), per-group / per-agent (stacked), or one-group-per-agent.
  • Requires specs to mirror that nesting, with a two-group spec example and an optional per-group done spec.
  • Includes a copy-paste native TwoTeamEnv(EnvBase) sketch (not a PettingZoo wrapper) that reads (group, "action") and returns observations, rewards, and shared done flags without a "next" wrapper.
  • Cross-links the competitive MADDPG tutorial as the canonical multi-group training loop.

The existing VMAS single-group example is kept as the simple case. The intro now treats "agents" as one group name, not a required key.

Motivation and Context

close #2425

The current multi-agent env page only documented the single "agents" group. Matteo Bettini agreed it needed a more general multi-group description; a later comment pointed at the competitive DDPG tutorial rollout as the pattern.

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Documentation (update in the documentation)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

@pytorch-bot

pytorch-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures

As of commit 853299d with merge base 1d3de3d (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Sep 5, 2026
@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 Sep 5, 2026
Clarify that collectors and replay buffers preserve nested keys without plural-key arguments, and direct users to group policies and per-group loss key configuration.
Construct the placeholder reset observations on self.device so the documented environment satisfies EnvBase placement guarantees when callers pass device=.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document the TensorDict structure of the return of the _step() function for a multi agent environment

2 participants