Skip to content

[Doc] Document LossModule and collector weight sharing - #4231

Open
YeonwooSung wants to merge 2 commits into
pytorch:mainfrom
YeonwooSung:doc/3032-weight-update-propagation
Open

[Doc] Document LossModule and collector weight sharing#4231
YeonwooSung wants to merge 2 commits into
pytorch:mainfrom
YeonwooSung:doc/3032-weight-update-propagation

Conversation

@YeonwooSung

Copy link
Copy Markdown
Contributor

Description

Document how LossModule and collectors share policy weights, and when collector.update_policy_weights_() is actually required.

The objectives landing page (and the DDPG tutorial) said losses "contain a copy of the trainable parameters". That wording made it look like an optimizer step on the loss would not update the original module, and that a collector always needed an explicit sync. Maintainer answers on #3032 already settled the semantics; this PR writes them down.

  • Passing a module into a LossModule does not copy it. The same parameters are used in-place; optimizer steps on the loss update the original module.
  • A CPU policy passed to a collector is moved to shared memory in-place. A CUDA policy is already shared.
  • update_policy_weights_() is required when policy_device or device remaps the policy (a .to(...) copy is made). Calling it anyway is good practice but not load-bearing unless devices were remapped.

Cross-links: LossModule / objectives landing page ↔ collectors weight-sync page.

Motivation and Context

Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax close #15213 if this solves the issue #15213

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

close #3032

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • 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/4231

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

❌ 3 New Failures

As of commit dac9946 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.

@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
Describe synchronization in terms of shared parameter storage. Same-device arguments may preserve storage, while worker-created, copied, and remote policies require a configured update path.
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 Integrations/torch_geometric Integrations Objectives tutorials/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Documentation about weight update propagation

2 participants